[rkward-cvs] rkward/rkward rkconsole.cpp,1.3,1.4 rkconsole.h,1.2,1.3 rkwatch.cpp,1.33,1.34 rkwatch.h,1.13,1.14
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Fri Apr 15 14:15:32 UTC 2005
Update of /cvsroot/rkward/rkward/rkward
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17219/rkward
Modified Files:
rkconsole.cpp rkconsole.h rkwatch.cpp rkwatch.h
Log Message:
RKConsole can now handle incomplete (multi-line) statements
Index: rkwatch.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkwatch.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** rkwatch.cpp 27 Feb 2005 16:21:44 -0000 1.33
--- rkwatch.cpp 15 Apr 2005 14:15:29 -0000 1.34
***************
*** 55,60 ****
console = new RKConsole(layout_widget);
bottom_hbox->addWidget (console);
! connect (console, SIGNAL (commandSubmitted (QString)), this, SLOT (submitConsoleCommand (QString)));
!
// add run & reset buttons
--- 55,59 ----
console = new RKConsole(layout_widget);
bottom_hbox->addWidget (console);
! connect (console, SIGNAL (userCommandRunning (RCommand *)), this, SLOT (consoleCommandRunning (RCommand *)));
// add run & reset buttons
***************
*** 134,138 ****
user_command = 0;
interrupt_command->setEnabled (false);
- console->addOutput(command->output (), command->error ());
}
if (!RKSettingsModuleWatch::shouldShowOutput (command)) {
--- 133,136 ----
***************
*** 166,170 ****
watch->append (command->error ());
if (command->failed () && (command->error () == "")) {
! watch->append (i18n ("An unspecified error occured while running the command.\nProbably a syntax error.\nThose - unfortunately - are not handled very well, yet.\n"));
}
--- 164,174 ----
watch->append (command->error ());
if (command->failed () && (command->error () == "")) {
! if (command->errorIncomplete ()) {
! watch->append (i18n ("Incomplete statement.\n"));
! } else if (command->errorSyntax ()) {
! watch->append (i18n ("Syntax error.\n"));
! } else {
! watch->append (i18n ("An unspecified error occured while running the command.\n"));
! }
}
***************
*** 205,214 ****
}
! void RKwatch::submitConsoleCommand (QString c)
! {
RK_TRACE (APP);
! if (! c.isEmpty()){
! r_inter->issueCommand (user_command = new RCommand (c, RCommand::User));
interrupt_command->setEnabled (true);
}
}
--- 209,221 ----
}
! void RKwatch::consoleCommandRunning (RCommand *command) {
RK_TRACE (APP);
!
! if (command) {
! user_command = command;
interrupt_command->setEnabled (true);
+ } else {
+ user_command = 0;
+ interrupt_command->setEnabled (false);
}
}
Index: rkwatch.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkwatch.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rkwatch.h 27 Feb 2005 16:21:44 -0000 1.13
--- rkwatch.h 15 Apr 2005 14:15:29 -0000 1.14
***************
*** 52,56 ****
void clearWatch ();
/** Submits command from the RKConsole */
! void submitConsoleCommand (QString c);
private:
--- 52,56 ----
void clearWatch ();
/** Submits command from the RKConsole */
! void consoleCommandRunning (RCommand *command);
private:
Index: rkconsole.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** rkconsole.cpp 24 Mar 2005 07:34:32 -0000 1.3
--- rkconsole.cpp 15 Apr 2005 14:15:29 -0000 1.4
***************
*** 27,30 ****
--- 27,34 ----
#include "rkconsole.h"
+ #include "rkglobals.h"
+ #include "rbackend/rinterface.h"
+ #include "rbackend/rcommand.h"
+
RKConsole::RKConsole(QWidget *parent, const char *name)
: QTextEdit(parent, name)
***************
*** 34,37 ****
--- 38,42 ----
prefix = "> ";
+ command_incomplete = false;
flush();
***************
*** 87,111 ****
- void RKConsole::addInput (QString s)
- {
- append (i18n (">> input from RKWard >>"));
- append(s);
- append (">>>>");
- }
-
- void RKConsole::addOutput (QString output, QString error)
- {
- if (! output.isEmpty ()){
- append (output);
- }
- if (! error.isEmpty ()){
- append (error);
- }
- newLine ();
- }
-
- #include "rkconsole.moc"
-
-
void RKConsole::newLine()
{
--- 92,95 ----
***************
*** 118,121 ****
--- 102,106 ----
QString s = text (paragraphs () - 1).right(paragraphLength (paragraphs () - 1) - prefix.length () + 1);
s = s.stripWhiteSpace ();
+
return(s);
}
***************
*** 130,135 ****
-
-
void RKConsole::setCurrentCommand(QString command)
{
--- 115,118 ----
***************
*** 156,162 ****
}
QString c = currentCommand ();
! commandsList.append (new QString(c.latin1 ()));
! emit(commandSubmitted (c));
} else {
newLine ();
}
--- 139,151 ----
}
QString c = currentCommand ();
! commandsList.append (new QString (c.latin1 ()));
!
! if (command_incomplete) {
! c.prepend (incomplete_command + "\n");
! }
!
! RKGlobals::rInterface ()->issueCommand (c, RCommand::User, "", this);
} else {
+ command_incomplete = false;
newLine ();
}
***************
*** 205,206 ****
--- 194,219 ----
setCursorPosition (paragraphs () - 1, prefix.length ());
}
+
+
+ void RKConsole::rCommandDone (RCommand *command) {
+ if (command->hasOutput ()) {
+ append (command->output ());
+ }
+ if (command->hasError ()) {
+ append (command->error ());
+ }
+
+ if (command->errorIncomplete ()) {
+ prefix = "# ";
+ command_incomplete = true;
+ incomplete_command = command->command ();
+ } else {
+ prefix = "> ";
+ command_incomplete = false;
+ incomplete_command = "";
+ }
+
+ newLine ();
+ }
+
+ #include "rkconsole.moc"
Index: rkconsole.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rkconsole.h 17 Mar 2005 07:37:42 -0000 1.2
--- rkconsole.h 15 Apr 2005 14:15:29 -0000 1.3
***************
*** 21,24 ****
--- 21,26 ----
#include <qptrlist.h>
+ #include "rbackend/rcommandreceiver.h"
+
/**
\brief Provides an R-like console.
***************
*** 30,35 ****
@author Pierre Ecochard
*/
! class RKConsole : public QTextEdit
! {
Q_OBJECT
public:
--- 32,36 ----
@author Pierre Ecochard
*/
! class RKConsole : public QTextEdit, public RCommandReceiver {
Q_OBJECT
public:
***************
*** 39,62 ****
~RKConsole();
- /** Adds input to the watch-window (i.e. commands issued)
- \param s the input to be added. */
- void addInput (QString s);
- /** Adds output to the watch-window (i.e. replies received)
- \param output the output received
- \param error the optional error */
- void addOutput (QString output, QString error);
/** Empties the console */
! void flush();
/** Sets the current command
\param command the new command */
! void setCurrentCommand(QString command);
!
signals:
! void commandSubmitted (QString c);
protected:
void keyPressEvent ( QKeyEvent * e );
private:
QString prefix;
/** A list to store previous commands */
QPtrList<QString> commandsList;
--- 40,58 ----
~RKConsole();
/** Empties the console */
! void flush ();
/** Sets the current command
\param command the new command */
! void setCurrentCommand (QString command);
signals:
! void userCommandRunning (RCommand *command);
protected:
void keyPressEvent ( QKeyEvent * e );
+ void rCommandDone (RCommand *command);
private:
QString prefix;
+ QString incomplete_command;
+ bool command_incomplete;
/** A list to store previous commands */
QPtrList<QString> commandsList;
More information about the rkward-tracker
mailing list