[rkward-cvs] SF.net SVN: rkward:[2492] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue May 19 16:13:10 UTC 2009


Revision: 2492
          http://rkward.svn.sourceforge.net/rkward/?rev=2492&view=rev
Author:   tfry
Date:     2009-05-19 16:13:10 +0000 (Tue, 19 May 2009)

Log Message:
-----------
Add option to add only single line commands from script editor to the console history.
See https://sourceforge.net/tracker/?func=detail&aid=1808432&group_id=50231&atid=459010

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/rkconsole.cpp
    trunk/rkward/rkward/settings/rksettingsmoduleconsole.cpp
    trunk/rkward/rkward/settings/rksettingsmoduleconsole.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-05-19 15:23:12 UTC (rev 2491)
+++ trunk/rkward/ChangeLog	2009-05-19 16:13:10 UTC (rev 2492)
@@ -1,3 +1,4 @@
+- Add option to add only single line commands from script editor to the console history
 - Add action to change working directory to that of the current script file
 - Fixed: No warning was shown, when an open script file was changed on disk, externally
 - Fixed: Opening most file types (e.g. PDF) from the help browser was broken		TODO: output refresh is somewhat broken, now

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2009-05-19 15:23:12 UTC (rev 2491)
+++ trunk/rkward/rkward/rkconsole.cpp	2009-05-19 16:13:10 UTC (rev 2492)
@@ -2,7 +2,7 @@
                           rkconsole  -  description
                              -------------------
     begin                : Thu Aug 19 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -850,10 +850,12 @@
 	} else {
 		QString command_string = command->command ();
 		QString text = command_string;
-		if (RKSettingsModuleConsole::addPipedCommandsToHistory()) {
-			QStringList lines = text.split ('\n');
-			for (QStringList::const_iterator it = lines.constBegin (); it != lines.constEnd (); ++it) {
-				addCommandToHistory (*it);
+		if (RKSettingsModuleConsole::addPipedCommandsToHistory() != RKSettingsModuleConsole::DontAdd) {
+			QStringList lines = text.split ('\n', QString::SkipEmptyParts);
+			if ((RKSettingsModuleConsole::addPipedCommandsToHistory() == RKSettingsModuleConsole::AlwaysAdd) || (lines.count () == 1)) {
+				for (int i = 0; i < lines.count (); ++i) {
+					addCommandToHistory (lines[i]);
+				}
 			}
 		}
 		text.replace ('\n', QString ("\n") + iprefix);

Modified: trunk/rkward/rkward/settings/rksettingsmoduleconsole.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduleconsole.cpp	2009-05-19 15:23:12 UTC (rev 2491)
+++ trunk/rkward/rkward/settings/rksettingsmoduleconsole.cpp	2009-05-19 16:13:10 UTC (rev 2492)
@@ -2,7 +2,7 @@
                           rksettingsmoduleconsole  -  description
                              -------------------
     begin                : Sun Oct 16 2005
-    copyright            : (C) 2005, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -27,6 +27,7 @@
 #include <qcheckbox.h>
 #include <qlabel.h>
 #include <QVBoxLayout>
+#include <QComboBox>
 
 #include "../rbackend/rcommand.h"
 #include "../rkglobals.h"
@@ -38,7 +39,7 @@
 uint RKSettingsModuleConsole::max_history_length;
 uint RKSettingsModuleConsole::max_console_lines;
 bool RKSettingsModuleConsole::pipe_user_commands_through_console;
-bool RKSettingsModuleConsole::add_piped_commands_to_history;
+RKSettingsModuleConsole::PipedCommandsHistoryMode RKSettingsModuleConsole::add_piped_commands_to_history;
 bool RKSettingsModuleConsole::context_sensitive_history_by_default;
 
 RKSettingsModuleConsole::RKSettingsModuleConsole (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
@@ -70,9 +71,13 @@
 	connect (pipe_user_commands_through_console_box, SIGNAL (stateChanged (int)), this, SLOT (changedSetting (int)));
 	vbox->addWidget (pipe_user_commands_through_console_box);
 
-	add_piped_commands_to_history_box = new QCheckBox (i18n ("Also add those commands to console history"), this);
-	add_piped_commands_to_history_box->setChecked (add_piped_commands_to_history);
-	connect (add_piped_commands_to_history_box, SIGNAL (stateChanged (int)), this, SLOT (changedSetting (int)));
+	vbox->addWidget (new QLabel (i18n ("Also add those commands to console history"), this));
+	add_piped_commands_to_history_box = new QComboBox (this);
+	add_piped_commands_to_history_box->insertItem ((int) DontAdd, i18n ("Do not add"));
+	add_piped_commands_to_history_box->insertItem ((int) AddSingleLine, i18n ("Add only if single line"));
+	add_piped_commands_to_history_box->insertItem ((int) AlwaysAdd, i18n ("Add all commands"));
+	add_piped_commands_to_history_box->setCurrentIndex ((int) add_piped_commands_to_history);
+	connect (add_piped_commands_to_history_box, SIGNAL (currentIndexChanged (int)), this, SLOT (changedSetting (int)));
 	add_piped_commands_to_history_box->setEnabled (pipe_user_commands_through_console_box->isChecked ());
 	vbox->addWidget (add_piped_commands_to_history_box);
 
@@ -114,7 +119,7 @@
 	cg.writeEntry ("max history length", max_history_length);
 	cg.writeEntry ("max console lines", max_console_lines);
 	cg.writeEntry ("pipe user commands through console", pipe_user_commands_through_console);
-	cg.writeEntry ("add piped commands to history", add_piped_commands_to_history);
+	cg.writeEntry ("add piped commands to history", (int) add_piped_commands_to_history);
 	cg.writeEntry ("command history defaults to context sensitive", context_sensitive_history_by_default);
 }
 
@@ -127,7 +132,7 @@
 	max_history_length = cg.readEntry ("max history length", 100);
 	max_console_lines = cg.readEntry ("max console lines", 500);
 	pipe_user_commands_through_console = cg.readEntry ("pipe user commands through console", true);
-	add_piped_commands_to_history = cg.readEntry ("add piped commands to history", true);
+	add_piped_commands_to_history = (PipedCommandsHistoryMode) cg.readEntry ("add piped commands to history", (int) AddSingleLine);
 	context_sensitive_history_by_default = cg.readEntry ("command history defaults to context sensitive", false);
 }
 
@@ -164,7 +169,7 @@
 	max_history_length = max_history_length_spinner->value ();
 	max_console_lines = max_console_lines_spinner->value ();
 	pipe_user_commands_through_console = pipe_user_commands_through_console_box->isChecked ();
-	add_piped_commands_to_history = add_piped_commands_to_history_box->isChecked ();
+	add_piped_commands_to_history = (PipedCommandsHistoryMode) add_piped_commands_to_history_box->currentIndex ();
 	context_sensitive_history_by_default = reverse_context_mode_box->isChecked ();
 }
 

Modified: trunk/rkward/rkward/settings/rksettingsmoduleconsole.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduleconsole.h	2009-05-19 15:23:12 UTC (rev 2491)
+++ trunk/rkward/rkward/settings/rksettingsmoduleconsole.h	2009-05-19 16:13:10 UTC (rev 2492)
@@ -2,7 +2,7 @@
                           rksettingsmoduleconsole  -  description
                              -------------------
     begin                : Sun Oct 16 2005
-    copyright            : (C) 2005, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -22,8 +22,8 @@
 #include <qnamespace.h>
 
 class QCheckBox;
+class QComboBox;
 class KIntSpinBox;
-class RKConsole;
 
 /**
 Settings module for the console. Allows you to configure whether to store command history, command history length. Future extensions: color for warnings/errors, etc.
@@ -48,7 +48,12 @@
 	static uint maxHistoryLength () { return max_history_length; };
 	static uint maxConsoleLines () { return max_console_lines; };
 	static bool pipeUserCommandsThroughConsole () { return pipe_user_commands_through_console; };
-	static bool addPipedCommandsToHistory () { return add_piped_commands_to_history; };
+	enum PipedCommandsHistoryMode {
+		DontAdd = 0,
+		AddSingleLine = 1,
+		AlwaysAdd = 2
+	};
+	static PipedCommandsHistoryMode addPipedCommandsToHistory () { return add_piped_commands_to_history; };
 	/** Given the button state, return whether the command history should be navigated context sensitive or insensitive
 	@param current_state the current button state
 	@returns true, if a the search should be context sensitive, false for a normal search */
@@ -67,13 +72,13 @@
 	static uint max_history_length;
 	static uint max_console_lines;
 	static bool pipe_user_commands_through_console;
-	static bool add_piped_commands_to_history;
+	static PipedCommandsHistoryMode add_piped_commands_to_history;
 	static bool context_sensitive_history_by_default;
 
 	QCheckBox *save_history_box;
 	QCheckBox *reverse_context_mode_box;
 	QCheckBox *pipe_user_commands_through_console_box;
-	QCheckBox *add_piped_commands_to_history_box;
+	QComboBox *add_piped_commands_to_history_box;
 	KIntSpinBox *max_history_length_spinner;
 	KIntSpinBox *max_console_lines_spinner;
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list