[rkward-cvs] rkward/rkward rkconsole.cpp,1.13,1.14 rkconsole.h,1.9,1.10 rkconsolepart.rc,1.1,1.2 rkward.cpp,1.106,1.107 rkward.h,1.48,1.49 rkwardui.rc,1.24,1.25
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Sun Oct 16 18:48:36 UTC 2005
- Previous message: [rkward-cvs] rkward/rkward/settings Makefile.am,1.3,1.4 rksettings.cpp,1.7,1.8 rksettings.h,1.5,1.6
- Next message: [rkward-cvs] rkward/rkward rkconsole.cpp,1.14,1.15 rkconsole.h,1.10,1.11 rkconsolepart.rc,1.2,1.3 rkwardui.rc,1.25,1.26
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/rkward/rkward/rkward
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28579/rkward
Modified Files:
rkconsole.cpp rkconsole.h rkconsolepart.rc rkward.cpp rkward.h
rkwardui.rc
Log Message:
Add option to save command history. Limit command history length. Allow interrupting console command (but Ctrl+C shortcut not yet working).
Index: rkconsole.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rkconsole.cpp 16 Oct 2005 16:01:59 -0000 1.13
--- rkconsole.cpp 16 Oct 2005 18:48:34 -0000 1.14
***************
*** 15,23 ****
* *
***************************************************************************/
!
!
!
! // TODO : use QStringList::split to enter several lines at a time.
!
#include <qfont.h>
--- 15,19 ----
* *
***************************************************************************/
! #include "rkconsole.h"
#include <qfont.h>
***************
*** 28,33 ****
#include <klocale.h>
#include <kaction.h>
-
- #include "rkconsole.h"
#include "rkglobals.h"
--- 24,27 ----
***************
*** 37,42 ****
#include "rbackend/rinterface.h"
#include "rbackend/rcommand.h"
! RKConsole::RKConsole (QWidget *parent, const char *name) : KTextEdit (parent, name) {
RK_TRACE (APP);
--- 31,37 ----
#include "rbackend/rinterface.h"
#include "rbackend/rcommand.h"
+ #include "settings/rksettingsmoduleconsole.h"
! RKConsole::RKConsole () : KTextEdit (0) {
RK_TRACE (APP);
***************
*** 52,59 ****
clear();
- commands_history.append (new QString (""));
commands_history.setAutoDelete (true);
! RKGlobals::rkApp()->m_manager->addPart (new RKConsolePart (this), false);
}
--- 47,58 ----
clear();
commands_history.setAutoDelete (true);
+ commands_history.append (new QString (""));
+ QStringList history = RKSettingsModuleConsole::loadCommandHistory ();
+ for (QStringList::const_iterator it = history.begin (); it != history.end (); ++it) {
+ commands_history.append (new QString (*it));
+ }
! current_command = 0;
}
***************
*** 61,72 ****
RKConsole::~RKConsole () {
RK_TRACE (APP);
}
void RKConsole::keyPressEvent (QKeyEvent *e) {
int para=0; int p=0;
getCursorPosition (¶, &p);
// Explicitely converting so we get less warnings.
uint pos=(uint) p;
!
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
submitCommand ();
--- 60,84 ----
RKConsole::~RKConsole () {
RK_TRACE (APP);
+
+ QStringList savelist;
+ QString *str;
+ for (str = commands_history.first (); str; str = commands_history.next ()) {
+ savelist.append (*str);
+ }
+
+ RKSettingsModuleConsole::saveCommandHistory (savelist);
}
void RKConsole::keyPressEvent (QKeyEvent *e) {
+ if (current_command) {
+ e->ignore ();
+ return;
+ }
+
int para=0; int p=0;
getCursorPosition (¶, &p);
// Explicitely converting so we get less warnings.
uint pos=(uint) p;
!
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
submitCommand ();
***************
*** 100,104 ****
QString RKConsole::currentCommand () {
! QString s = text (paragraphs () - 1).right(paragraphLength (paragraphs () - 1) - prefix.length () + 1);
s = s.stripWhiteSpace ();
--- 112,116 ----
QString RKConsole::currentCommand () {
! QString s = text (paragraphs () - 1).right (paragraphLength (paragraphs () - 1) - prefix.length () + 1);
s = s.stripWhiteSpace ();
***************
*** 122,126 ****
}
QString c = currentCommand ();
! commands_history.append (new QString (c.latin1 ()));
if (command_incomplete) {
--- 134,138 ----
}
QString c = currentCommand ();
! addCommandToHistory (c);
if (command_incomplete) {
***************
*** 129,133 ****
if (!currentCommand ().isEmpty ()) {
! RKGlobals::rInterface ()->issueCommand (c, RCommand::User, QString::null, this);
} else {
tryNextInBatch ();
--- 141,147 ----
if (!currentCommand ().isEmpty ()) {
! current_command = new RCommand (c, RCommand::User, QString::null, this);
! RKGlobals::rInterface ()->issueCommand (current_command);
! emit (doingCommand (true));
} else {
tryNextInBatch ();
***************
*** 141,145 ****
// We add the current line to the list.
if (commands_history.getLast () == commands_history.current ()) {
! commands_history.append (new QString (currentCommand ().latin1 ()));
}
commands_history.prev ();
--- 155,159 ----
// We add the current line to the list.
if (commands_history.getLast () == commands_history.current ()) {
! addCommandToHistory (currentCommand ());
}
commands_history.prev ();
***************
*** 206,209 ****
--- 220,224 ----
if (!commands_batch.isEmpty ()){
submitCommand ();
+ return;
}
// We would put this here if we would want the last line to be executed. We generally don't want this, as there is an empty last item, if there is a newline at the end.
***************
*** 211,214 ****
--- 226,232 ----
//commands_batch.erase(commands_batch.begin());
}
+
+ current_command = 0;
+ emit (doingCommand (false));
}
***************
*** 223,230 ****
}
///################### END RKConsole ########################
///################### BEGIN RKConsolePart ####################
! RKConsolePart::RKConsolePart (RKConsole *console) : KParts::Part (0) {
RK_TRACE (APP);
--- 241,259 ----
}
+ void RKConsole::addCommandToHistory (const QString &command) {
+ commands_history.append (new QString (command.latin1 ()));
+
+ if (RKSettingsModuleConsole::maxHistoryLength ()) {
+ uint c = commands_history.count ();
+ for (uint ui = c; c > RKSettingsModuleConsole::maxHistoryLength (); --ui) {
+ commands_history.removeFirst ();
+ }
+ }
+ }
+
///################### END RKConsole ########################
///################### BEGIN RKConsolePart ####################
! RKConsolePart::RKConsolePart () : KParts::Part (0) {
RK_TRACE (APP);
***************
*** 232,241 ****
setInstance (instance);
! setWidget (console);
! RKConsolePart::console = console;
setXMLFile ("rkconsolepart.rc");
context_help = new KAction (i18n ("&Function reference"), KShortcut ("F2"), this, SLOT (showContextHelp ()), actionCollection (), "function_reference");
}
--- 261,273 ----
setInstance (instance);
! setWidget (RKConsolePart::console = new RKConsole ());
! connect (console, SIGNAL (doingCommand (bool)), this, SLOT (setDoingCommand (bool)));
setXMLFile ("rkconsolepart.rc");
context_help = new KAction (i18n ("&Function reference"), KShortcut ("F2"), this, SLOT (showContextHelp ()), actionCollection (), "function_reference");
+ interrupt_command = new KAction (i18n ("Interrupt running command"), KShortcut ("Ctrl+C"), this, SLOT (slotInterruptCommand ()), actionCollection (), "interrupt");
+ interrupt_command->setIcon ("player_stop");
+ interrupt_command->setEnabled (false);
}
***************
*** 253,255 ****
--- 285,302 ----
}
+ void RKConsolePart::setDoingCommand (bool busy) {
+ RK_TRACE (APP);
+
+ interrupt_command->setEnabled (busy);
+ }
+
+ void RKConsolePart::slotInterruptCommand () {
+ RK_TRACE (APP);
+ RK_ASSERT (console->current_command);
+
+ console->commands_batch.clear ();
+ RKGlobals::rInterface ()->cancelCommand (console->current_command);
+ setDoingCommand (false);
+ }
+
#include "rkconsole.moc"
Index: rkward.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** rkward.h 17 Sep 2005 19:23:52 -0000 1.48
--- rkward.h 16 Oct 2005 18:48:34 -0000 1.49
***************
*** 56,60 ****
class RKMenuList;
class RKCommandEditorWindow;
- class RKConsole;
/**
--- 56,59 ----
***************
*** 197,203 ****
void slotChildWindowCloseRequest (KMdiChildView * window);
- /** interrupt current command. TODO: defunct!!! */
- void slotInterruptCommand();
-
/** close current window (Windows->Close). Note: the only reason we need to implement this, is so we can set a default shortcut (Ctrl+W). Usually, KMdiMainFrm would provide an action like this by itselt */
void slotCloseWindow ();
--- 196,199 ----
***************
*** 237,241 ****
KAction* window_detach;
- KAction* interruptCommand;
KAction* configure;
--- 233,236 ----
***************
*** 251,255 ****
RObjectBrowser *object_browser;
- RKConsole * console;
KURL *initial_url;
--- 246,249 ----
Index: rkconsole.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** rkconsole.h 16 Oct 2005 16:01:59 -0000 1.9
--- rkconsole.h 16 Oct 2005 18:48:34 -0000 1.10
***************
*** 25,30 ****
#include "rbackend/rcommandreceiver.h"
-
class QStringList;
/**
--- 25,31 ----
#include "rbackend/rcommandreceiver.h"
class QStringList;
+ class KAction;
+ class RCommand;
/**
***************
*** 34,37 ****
--- 35,40 ----
** the user to enter commands manualy. It is basically just a modified KTextEdit.
**
+ Do not construct directly. Construct an RKConsolePart instead.
+
** \sa RKwatch, KTextEdit
**
***************
*** 42,58 ****
Q_OBJECT
public:
! /** Constructor */
! RKConsole(QWidget *parent = 0, const char *name = 0);
! /** Destructor */
! ~RKConsole();
!
! /** Submits a batch of commands, line by line.
! \param batch a QString containing the batch of commands to be executed */
! void submitBatch(QString batch);
!
protected:
! void keyPressEvent ( QKeyEvent * e );
void rCommandDone (RCommand *command);
private:
QString incomplete_command;
bool command_incomplete;
--- 45,63 ----
Q_OBJECT
public:
! /** Submits a batch of commands, line by line.
! \param batch a QString containing the batch of commands to be executed */
! void submitBatch (QString batch);
protected:
! /** Constructor. Protected. Construct an RKConsolePart instead */
! RKConsole ();
! /** Destructor */
! ~RKConsole ();
!
! void keyPressEvent (QKeyEvent * e);
void rCommandDone (RCommand *command);
+ signals:
+ void doingCommand (bool busy);
private:
+ friend class RKConsolePart;
QString incomplete_command;
bool command_incomplete;
***************
*** 62,65 ****
--- 67,71 ----
QStringList commands_batch;
/** Sets the cursor position to the end of the last line. */
+
void cursorAtTheEnd();
/** Returns the command currently being edited (not executed yet) */
***************
*** 83,87 ****
/** Add a new line, and try to submit the next item in a batch of (pasted) commands. If there is no batch, only add the new line. */
void tryNextInBatch ();
! private:
QString prefix;
/** This string stores the regular prefix printed at the beginning of each line. */
--- 89,95 ----
/** Add a new line, and try to submit the next item in a batch of (pasted) commands. If there is no batch, only add the new line. */
void tryNextInBatch ();
! /** Add given command to command history. Also checks, wether the history is longer than max length, and chops it if so. */
! void addCommandToHistory (const QString &command);
!
QString prefix;
/** This string stores the regular prefix printed at the beginning of each line. */
***************
*** 89,92 ****
--- 97,102 ----
/** This string stores the continuation prefix. */
const char *iprefix;
+
+ RCommand *current_command;
};
***************
*** 100,104 ****
/** constructor.
@param console The console for this part */
! RKConsolePart (RKConsole *console);
/** destructor */
~RKConsolePart ();
--- 110,114 ----
/** constructor.
@param console The console for this part */
! RKConsolePart ();
/** destructor */
~RKConsolePart ();
***************
*** 106,111 ****
--- 116,125 ----
/** show context help on the current word */
void showContextHelp ();
+ void setDoingCommand (bool busy);
+ /** interrupt current command. */
+ void slotInterruptCommand ();
private:
KAction *context_help;
+ KAction* interrupt_command;
RKConsole *console;
Index: rkconsolepart.rc
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsolepart.rc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** rkconsolepart.rc 17 Sep 2005 19:23:52 -0000 1.1
--- rkconsolepart.rc 16 Oct 2005 18:48:34 -0000 1.2
***************
*** 2,8 ****
--- 2,18 ----
<kpartgui name="rkward" version="0.3.3">
<MenuBar>
+ <Menu name="run"><text>&Run</text>
+ <Merge/>
+ <Separator/>
+ <Action name="interrupt"/>
+ </Menu>
<Menu name="help"><text>&Help</text>
<Action name="function_reference"></Action>
</Menu>
</MenuBar>
+ <ToolBar fullWidth="true" name="runToolBar">
+ <Action name="interrupt"/>
+ <Separator/>
+ <Merge/>
+ </ToolBar>
</kpartgui>
\ No newline at end of file
Index: rkward.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkward.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -C2 -d -r1.106 -r1.107
*** rkward.cpp 14 Oct 2005 15:57:43 -0000 1.106
--- rkward.cpp 16 Oct 2005 18:48:34 -0000 1.107
***************
*** 187,193 ****
addToolWindow(object_browser,KDockWidget::DockLeft, getMainDockWidget(), 30 , i18n ("Existing objects in your workspace.") , i18n ("Workspace"));
! RKGlobals::rInterface ()->watch->setName("Command log");
! RKGlobals::rInterface ()->watch->setIcon(SmallIcon("text_block"));
! addToolWindow(RKGlobals::rInterface ()->watch,KDockWidget::DockBottom, getMainDockWidget (), 10);
RControlWindowPart *rcpart = new RControlWindowPart ();
--- 187,193 ----
addToolWindow(object_browser,KDockWidget::DockLeft, getMainDockWidget(), 30 , i18n ("Existing objects in your workspace.") , i18n ("Workspace"));
! RKGlobals::rInterface ()->watch->setName ("Command log");
! RKGlobals::rInterface ()->watch->setIcon (SmallIcon ("text_block"));
! addToolWindow(RKGlobals::rInterface ()->watch, KDockWidget::DockBottom, getMainDockWidget (), 10);
RControlWindowPart *rcpart = new RControlWindowPart ();
***************
*** 198,205 ****
RKGlobals::rcontrol->hide (); // this line is important! RControlWindow must do some initializations on first show, and be hidden until then.
! console = new RKConsole (0);
! console->setIcon (SmallIcon ("konsole"));
! console->setName ("r_console");
! addToolWindow (console, KDockWidget::DockBottom, getMainDockWidget (), 10);
RKGlobals::helpdlg = new KHelpDlg (0);
--- 198,206 ----
RKGlobals::rcontrol->hide (); // this line is important! RControlWindow must do some initializations on first show, and be hidden until then.
! RKConsolePart *consolepart = new RKConsolePart ();
! consolepart->widget ()->setIcon (SmallIcon ("konsole"));
! consolepart->widget ()->setName ("r_console");
! addToolWindow (consolepart->widget (), KDockWidget::DockBottom, getMainDockWidget (), 10);
! m_manager->addPart (consolepart, false);
RKGlobals::helpdlg = new KHelpDlg (0);
***************
*** 301,310 ****
file_load_libs = new KAction (i18n ("Configure Packages"), 0, 0, this, SLOT (slotFileLoadLibs ()), actionCollection (), "file_load_libs");
-
viewToolBar = KStdAction::showToolbar(this, SLOT (slotViewToolBar()), actionCollection());
viewStatusBar = KStdAction::showStatusbar(this, SLOT (slotViewStatusBar()), actionCollection());
-
- interruptCommand = new KAction (i18n ("Interrupt running command"), 0, 0, this, SLOT (slotInterruptCommand ()), actionCollection (), "interrupt");
- interruptCommand->setIcon("player_stop");
close_all_editors = new KAction (i18n ("Close All Data"), 0, 0, this, SLOT (slotCloseAllEditors ()), actionCollection (), "close_all_editors");
--- 302,307 ----
***************
*** 739,746 ****
}
- void RKwardApp::slotInterruptCommand () {
- // TODO!
- }
-
void RKwardApp::openHTML(const KURL &url) {
RK_TRACE (APP);
--- 736,739 ----
Index: rkwardui.rc
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkwardui.rc,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** rkwardui.rc 16 Sep 2005 16:08:11 -0000 1.24
--- rkwardui.rc 16 Oct 2005 18:48:34 -0000 1.25
***************
*** 35,44 ****
<Merge/>
</Menu>
-
- <Menu name="run"><text>&Run</text>
- <Merge/>
- <Separator/>
- <Action name="interrupt"/>
- </Menu>
<Menu name="windows"><text>&Windows</text>
--- 35,38 ----
***************
*** 74,78 ****
</ToolBar>
<ToolBar fullWidth="true" name="runToolBar">
- <Action name="interrupt"/>
<Separator/>
<Action name="run_selection"/>
--- 68,71 ----
- Previous message: [rkward-cvs] rkward/rkward/settings Makefile.am,1.3,1.4 rksettings.cpp,1.7,1.8 rksettings.h,1.5,1.6
- Next message: [rkward-cvs] rkward/rkward rkconsole.cpp,1.14,1.15 rkconsole.h,1.10,1.11 rkconsolepart.rc,1.2,1.3 rkwardui.rc,1.25,1.26
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the rkward-tracker
mailing list