[rkward-cvs] rkward/rkward rkconsole.cpp,1.18,1.19 rkconsole.h,1.12,1.13 rkwatch.cpp,1.40,1.41
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Wed Nov 2 21:11:40 UTC 2005
- Previous message: [rkward-cvs] rkward/debian control,1.4,1.5
- Next message: [rkward-cvs] rkward/rkward/rbackend rcommand.h,1.21,1.22 rcommandreceiver.h,1.4,1.5 rembedinternal.cpp,1.26,1.27 rinterface.cpp,1.36,1.37 rthread.cpp,1.25,1.26 rthread.h,1.18,1.19
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/rkward/rkward/rkward
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14096/rkward
Modified Files:
rkconsole.cpp rkconsole.h rkwatch.cpp
Log Message:
real time display of output in console (and only in console, so far)
Index: rkwatch.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkwatch.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** rkwatch.cpp 24 Oct 2005 19:29:42 -0000 1.40
--- rkwatch.cpp 2 Nov 2005 21:11:38 -0000 1.41
***************
*** 44,47 ****
--- 44,48 ----
watch = new QTextEdit (this);
watch->setTextFormat (PlainText);
+ watch->setUndoRedoEnabled (false);
watch->setReadOnly (true);
***************
*** 158,163 ****
if (RKSettingsModuleWatch::maxLogLines ()) {
uint c = (uint) watch->paragraphs ();
! for (uint ui = c; ui > RKSettingsModuleWatch::maxLogLines (); --ui) {
! watch->removeParagraph (0);
}
}
--- 159,165 ----
if (RKSettingsModuleWatch::maxLogLines ()) {
uint c = (uint) watch->paragraphs ();
! if (c > RKSettingsModuleWatch::maxLogLines ()) {
! watch->setSelection (0, 0, c - RKSettingsModuleWatch::maxLogLines (), 0, 1);
! watch->removeSelectedText (1);
}
}
Index: rkconsole.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** rkconsole.cpp 18 Oct 2005 11:48:24 -0000 1.18
--- rkconsole.cpp 2 Nov 2005 21:11:38 -0000 1.19
***************
*** 33,37 ****
#include "settings/rksettingsmoduleconsole.h"
! RKConsole::RKConsole () : KTextEdit (0) {
RK_TRACE (APP);
--- 33,37 ----
#include "settings/rksettingsmoduleconsole.h"
! RKConsole::RKConsole () : QTextEdit (0) {
RK_TRACE (APP);
***************
*** 45,49 ****
prefix = nprefix;
command_incomplete = false;
! clear();
commands_history.setAutoDelete (true);
--- 45,51 ----
prefix = nprefix;
command_incomplete = false;
! setTextFormat (PlainText);
! setUndoRedoEnabled (false);
! clear ();
commands_history.setAutoDelete (true);
***************
*** 108,112 ****
}
! KTextEdit::keyPressEvent (e);
}
--- 110,114 ----
}
! QTextEdit::keyPressEvent (e);
}
***************
*** 145,150 ****
if (!currentCommand ().isEmpty ()) {
! current_command = new RCommand (c, RCommand::User | RCommand::Console, QString::null, this);
RKGlobals::rInterface ()->issueCommand (current_command);
emit (doingCommand (true));
} else {
--- 147,153 ----
if (!currentCommand ().isEmpty ()) {
! current_command = new RCommand (c, RCommand::User | RCommand::Console | RCommand::ImmediateOutput, QString::null, this);
RKGlobals::rInterface ()->issueCommand (current_command);
+ append (""); // new line
emit (doingCommand (true));
} else {
***************
*** 189,198 ****
void RKConsole::rCommandDone (RCommand *command) {
RK_TRACE (APP);
! if (command->hasOutput ()) {
! append (command->output ());
}
! if (command->hasError ()) {
! append (command->error ());
! } else if (command->errorSyntax ()) {
append (i18n ("Syntax error"));
}
--- 192,204 ----
void RKConsole::rCommandDone (RCommand *command) {
RK_TRACE (APP);
! if (!(command->type () & RCommand::ImmediateOutput)) { // I don't think we'll have the other case, but for future extension
! if (command->hasOutput ()) {
! append (command->output ());
! }
! if (command->hasError ()) {
! append (command->error ());
! }
}
! if (command->errorSyntax ()) {
append (i18n ("Syntax error"));
}
***************
*** 211,214 ****
--- 217,239 ----
}
+ void RKConsole::newOutput (RCommand *, ROutput *output) {
+ RK_TRACE (APP);
+
+ // TODO: handle different types of output, once we can differentiate between them
+ // insertAt (output->output, paragraphs ()-1, paragraphLength (paragraphs () - 1));
+ cursorAtTheEnd ();
+ insert (output->output, (uint) CheckNewLines);
+
+ if (RKSettingsModuleConsole::maxConsoleLines ()) {
+ uint c = (uint) paragraphs ();
+ // TODO: WORKAROUND: Somehow, when removing paragraph 0, the QTextEdit scrolls to the top in between (yes, this also happens when using removeParagaph (0)). Since this may happen very often in newOutput, we're a bit sloppy, and only remove lines after a certain threshold (20) is exceeded. When the command is finished, this will be cleaned up automatically.
+ if (c > (RKSettingsModuleConsole::maxConsoleLines () + 20)) {
+ setSelection (0, 0, c - RKSettingsModuleConsole::maxConsoleLines (), 0, 1);
+ removeSelectedText (1);
+ }
+ }
+ cursorAtTheEnd ();
+ }
+
void RKConsole::submitBatch (QString batch) {
RK_TRACE (APP);
***************
*** 257,261 ****
void RKConsole::clear () {
RK_TRACE (APP);
! KTextEdit::clear ();
tryNextInBatch ();
}
--- 282,286 ----
void RKConsole::clear () {
RK_TRACE (APP);
! QTextEdit::clear ();
tryNextInBatch ();
}
***************
*** 280,284 ****
if (mp) return mp;
! return KTextEdit::createPopupMenu (pos);
}
--- 305,309 ----
if (mp) return mp;
! return QTextEdit::createPopupMenu (pos);
}
Index: rkconsole.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** rkconsole.h 16 Oct 2005 22:01:48 -0000 1.12
--- rkconsole.h 2 Nov 2005 21:11:38 -0000 1.13
***************
*** 38,41 ****
--- 38,42 ----
Do not construct directly. Construct an RKConsolePart instead.
+ TODO: Text display in the QTextEdit is rather slow. Find out how Konsole manages to be so much faster
** \sa RKwatch, KTextEdit
**
***************
*** 43,47 ****
**/
! class RKConsole : public KTextEdit, public RCommandReceiver {
Q_OBJECT
public:
--- 44,48 ----
**/
! class RKConsole : public QTextEdit, public RCommandReceiver {
Q_OBJECT
public:
***************
*** 59,62 ****
--- 60,65 ----
/** reimplemented to provide our own context menu */
QPopupMenu *createPopupMenu (const QPoint &pos);
+ /** reimplemented from RCommandReceiver::newOutput () to handle output of console commands */
+ void newOutput (RCommand *command, ROutput *output);
signals:
void doingCommand (bool busy);
- Previous message: [rkward-cvs] rkward/debian control,1.4,1.5
- Next message: [rkward-cvs] rkward/rkward/rbackend rcommand.h,1.21,1.22 rcommandreceiver.h,1.4,1.5 rembedinternal.cpp,1.26,1.27 rinterface.cpp,1.36,1.37 rthread.cpp,1.25,1.26 rthread.h,1.18,1.19
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the rkward-tracker
mailing list