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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Jan 8 17:47:04 UTC 2007


Revision: 1102
          http://svn.sourceforge.net/rkward/?rev=1102&view=rev
Author:   tfry
Date:     2007-01-08 09:47:04 -0800 (Mon, 08 Jan 2007)

Log Message:
-----------
New console RMB actions: Run Selection and Copy Selection Cleaned

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/rkconsole.cpp
    trunk/rkward/rkward/rkconsole.h
    trunk/rkward/rkward/rkconsolepart.rc

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2007-01-08 17:46:37 UTC (rev 1101)
+++ trunk/rkward/ChangeLog	2007-01-08 17:47:04 UTC (rev 1102)
@@ -1,5 +1,6 @@
 - TODO: test auto-detection of pluginmap path!
 
+- new Console RMB actions: "copy selection cleaned" and "run selection"
 - added a basic help system, and some introductory help pages
 - plug-in for skewness and kurtosis added
 - plug-ins for distribution analysis added

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2007-01-08 17:46:37 UTC (rev 1101)
+++ trunk/rkward/rkward/rkconsole.cpp	2007-01-08 17:47:04 UTC (rev 1102)
@@ -538,8 +538,27 @@
 	}
 }
 
+QString RKConsole::cleanedSelection () {
+	RK_TRACE (APP);
+
+	QString ret = doc->selection ();
+	ret.replace ('\n' + QString (nprefix), "\n");
+	ret.replace ('\n' + QString (iprefix), "\n");
+	if (ret.startsWith (nprefix)) {
+		ret = ret.mid (QString (nprefix).length ());
+	}
+
+	return ret;
+}
+
 void RKConsole::copy () {
 	RK_TRACE (APP);
+
+	QApplication::clipboard()->setText (cleanedSelection ());
+}
+
+void RKConsole::literalCopy () {
+	RK_TRACE (APP);
 	view->copy();
 }
 
@@ -596,6 +615,13 @@
 	}
 }
 
+void RKConsole::runSelection () {
+	RK_TRACE (APP);
+
+	QString command = cleanedSelection ();
+	pipeUserCommand (new RCommand (command, RCommand::User));
+}
+
 void RKConsole::showContextHelp () {
 	RK_TRACE (APP);
 	RKGlobals::helpDialog ()->getContextHelp (currentCommand (), currentCursorPositionInCommand ());
@@ -605,13 +631,17 @@
 	RK_TRACE (APP);
 
 	context_help_action = new KAction (i18n ("&Function reference"), KShortcut ("F2"), this, SLOT (showContextHelp ()), ac, "function_reference");
+	run_selection_action = new KAction (i18n ("Run selection"), KShortcut ("F8"), this, SLOT (runSelection ()), ac, "run_selection");
+	run_selection_action->setIcon ("player_play");
+
 	interrupt_command_action = new KAction (i18n ("Interrupt running command"), KShortcut ("Ctrl+C"), this, SLOT (slotInterruptCommand ()), ac, "interrupt");
 	interrupt_command_action->setIcon ("player_stop");
 	interrupt_command_action->setEnabled (false);
 // ugly HACK: we need this to override the default Ctrl+C binding
 	interrupt_command_action->setShortcut ("Ctrl+C");
 
-	copy_action = new KAction (i18n ("Copy selection"), 0, this, SLOT (copy ()), ac, "rkconsole_copy");
+	copy_action = new KAction (i18n ("Copy selection cleaned"), 0, this, SLOT (copy ()), ac, "rkconsole_copy");
+	copy_literal_action = new KAction (i18n ("Copy selection literally"), 0, this, SLOT (literalCopy ()), ac, "rkconsole_copy_literal");
 	KStdAction::clear (this, SLOT (clear ()), ac, "rkconsole_clear");
 	paste_action = KStdAction::paste (this, SLOT (paste ()), ac, "rkconsole_paste");
 	new KAction (i18n ("Configure"), 0, this, SLOT (configure ()), ac, "rkconsole_configure");
@@ -651,9 +681,13 @@
 	RK_TRACE (APP);
 
 	copy_action->setEnabled (hasSelectedText ());
+	copy_literal_action->setEnabled (hasSelectedText ());
+	run_selection_action->setEnabled (hasSelectedText ());
 
 	part->showPopupMenu (pos);
 
+	run_selection_action->setEnabled (true);
+	copy_literal_action->setEnabled (true);
 	copy_action->setEnabled (true);
 }
 

Modified: trunk/rkward/rkward/rkconsole.h
===================================================================
--- trunk/rkward/rkward/rkconsole.h	2007-01-08 17:46:37 UTC (rev 1101)
+++ trunk/rkward/rkward/rkconsole.h	2007-01-08 17:47:04 UTC (rev 1102)
@@ -130,6 +130,8 @@
 \param ac the action collection from which to retrieve the KAction*/
 	void unplugAction (const QString &action, KActionCollection* ac);
 
+	QString cleanedSelection ();
+
 	bool output_continuation;
 
 	RCommand *current_command;
@@ -142,8 +144,10 @@
 	bool tab_key_pressed_before;
 
 	KAction* context_help_action;
+	KAction* run_selection_action;
 	KAction* interrupt_command_action;
 	KAction* copy_action;
+	KAction* copy_literal_action;
 	KAction* paste_action;
 
 	void initializeActions (KActionCollection *ac);
@@ -157,6 +161,7 @@
 @sa submitBatch */
 	void paste ();
 	void copy ();
+	void literalCopy ();
 /** Clear the view, and add a prompt at the top. */
 	void clear ();
 	void configure ();
@@ -164,6 +169,7 @@
 	void showContextHelp ();
 /** interrupt current command. */
 	void slotInterruptCommand ();
+	void runSelection ();
 };
 
 /** A part interface to RKConsole. Provides the context-help functionality

Modified: trunk/rkward/rkward/rkconsolepart.rc
===================================================================
--- trunk/rkward/rkward/rkconsolepart.rc	2007-01-08 17:46:37 UTC (rev 1101)
+++ trunk/rkward/rkward/rkconsolepart.rc	2007-01-08 17:47:04 UTC (rev 1102)
@@ -4,6 +4,7 @@
 		<Menu name="run"><text>&Run</text>
 			<Merge/>
 			<Separator/>
+			<Action name="run_selection"/>
 			<Action name="interrupt"/>
 		</Menu>
 		<Menu name="help"><text>&Help</text>
@@ -17,10 +18,12 @@
 	</ToolBar>
 	<Menu name="rkconsole_context_menu">
 		<Action name="rkconsole_copy"></Action>
+		<Action name="rkconsole_copy_literal"></Action>
 		<Action name="rkconsole_paste"></Action>
 		<Separator/>
 		<Action name="function_reference"></Action>
 		<Separator/>
+		<Action name="run_selection"/>
 		<Action name="interrupt"></Action>
 		<Separator/>
 		<Action name="rkconsole_clear"></Action>


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