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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Mar 14 12:28:31 UTC 2007


Revision: 1574
          http://svn.sourceforge.net/rkward/?rev=1574&view=rev
Author:   tfry
Date:     2007-03-14 05:28:31 -0700 (Wed, 14 Mar 2007)

Log Message:
-----------
Make run current line action advance cursor to next line after running. Some internal simplifications

Modified Paths:
--------------
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h
    trunk/rkward/rkward/windows/rkcommandeditorwindowpart.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindowpart.h

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2007-03-13 22:43:24 UTC (rev 1573)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2007-03-14 12:28:31 UTC (rev 1574)
@@ -49,6 +49,7 @@
 
 #include "../misc/rkcommonfunctions.h"
 #include "../core/robjectlist.h"
+#include "../rkconsole.h"
 #include "../rkglobals.h"
 #include "../rkward.h"
 #include "rkhelpsearchwindow.h"
@@ -156,21 +157,6 @@
 	}
 }
 
-QString RKCommandEditorWindow::getSelection () {
-	RK_TRACE (COMMANDEDITOR);
-	return m_doc->selection ();
-}
-
-QString RKCommandEditorWindow::getLine () {
-	RK_TRACE (COMMANDEDITOR);
-	return m_view->currentTextLine ();
-}
-
-QString RKCommandEditorWindow::getText () {
-	RK_TRACE (COMMANDEDITOR);
-	return m_doc->text ();
-}
-
 void RKCommandEditorWindow::copy () {
 	RK_TRACE (COMMANDEDITOR);
 
@@ -196,7 +182,6 @@
 	return (m_doc->url ());
 }
 
-
 bool RKCommandEditorWindow::isModified() {
 	RK_TRACE (COMMANDEDITOR);
 	return m_doc->isModified();
@@ -243,7 +228,7 @@
 
 	uint para=0; uint cursor_pos=0;
 	m_view->cursorPosition (&para, &cursor_pos);
-	QString current_line = getLine ();
+	QString current_line = m_view->currentTextLine ();
 	if (current_line.findRev ("#", cursor_pos) >= 0) return;	// do not hint while in comments
 
 	QString current_symbol = RKCommonFunctions::getCurrentSymbol (current_line, cursor_pos, false);
@@ -275,7 +260,7 @@
 
 	uint current_line_num=0; uint cursor_pos=0;
 	m_view->cursorPosition (&current_line_num, &cursor_pos);
-	QString current_line = getLine ();
+	QString current_line = m_view->currentTextLine ();
 
 	int word_start;
 	int word_end;
@@ -303,6 +288,37 @@
 	return true;
 }
 
+void RKCommandEditorWindow::runSelection() {
+	RK_TRACE (COMMANDEDITOR);
+
+	QString command = m_doc->selection ();
+	if (command.isEmpty ()) return;
+
+	RKConsole::pipeUserCommand (new RCommand (command, RCommand::User, QString::null));
+}
+
+void RKCommandEditorWindow::runLine() {
+	RK_TRACE (COMMANDEDITOR);
+
+	QString command = m_view->currentTextLine ();
+	if (command.isEmpty ()) return;
+
+	RKConsole::pipeUserCommand (new RCommand (command, RCommand::User, QString::null));
+
+	m_view->down ();		// advance to next line
+}
+
+
+void RKCommandEditorWindow::runAll() {
+	RK_TRACE (COMMANDEDITOR);
+
+	QString command = m_doc->text ();
+	if (command.isEmpty ()) return;
+
+	RKConsole::pipeUserCommand (new RCommand (command, RCommand::User, QString::null));
+}
+
+
 //////////////////////// RKFunctionArgHinter //////////////////////////////
 
 #include <qvbox.h>

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2007-03-13 22:43:24 UTC (rev 1573)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2007-03-14 12:28:31 UTC (rev 1574)
@@ -85,12 +85,6 @@
 	RKCommandEditorWindow (QWidget *parent = 0, bool use_r_highlighting=true);
 /** destructor */
 	~RKCommandEditorWindow ();
-/** return text of current selection */
-	QString getSelection ();
-/** return text in current line */
-	QString getLine ();
-/** return entire text */
-	QString getText ();
 /** open given URL. 
 @param use_r_highlighting Initialize the view to use R syntax highlighting. Use, if you're going to edit an R syntax file
 @param read_only Open the file in read-only mode */
@@ -99,8 +93,6 @@
 	bool isModified ();
 /** insert the given text into the document at the current cursor position. Additionally, focuses the view */
 	void insertText (const QString &text);
-/** Show help about the current word. */
-	void showHelp ();
 /** set the current text (clear all previous text, and sets new text) */
 	void setText (const QString &text);
 /** copy current selection. Wrapper for use by external classes */
@@ -123,6 +115,14 @@
 	void fixCompletion (KTextEditor::CompletionEntry *, QString *);
 	void setPopupMenu (Kate::View *);
 	void setPopupMenu ();
+/** Show help about the current word. */
+	void showHelp ();
+/** run the currently selected command(s) */
+	void runSelection ();
+/** run the current line */
+	void runLine ();
+/** run the entire script */
+	void runAll ();
 protected:
 /** reimplemented from KMdiChildView: give the editor window a chance to object to being closed (if unsaved) */
 	void closeEvent (QCloseEvent *e);

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindowpart.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindowpart.cpp	2007-03-13 22:43:24 UTC (rev 1573)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindowpart.cpp	2007-03-14 12:28:31 UTC (rev 1574)
@@ -25,9 +25,6 @@
 #include <qpopupmenu.h>
 
 #include "rkcommandeditorwindow.h"
-#include "../rkglobals.h"
-#include "../rkconsole.h"
-#include "../rbackend/rinterface.h"
 #include "../debug.h"
 
 RKCommandEditorWindowPart::RKCommandEditorWindowPart (QWidget *parent, RKCommandEditorWindow *editor_widget) : KParts::Part (parent) {
@@ -50,42 +47,11 @@
 void RKCommandEditorWindowPart::initializeActions () {
 	RK_TRACE (COMMANDEDITOR);
 
-	runAll = new KAction (i18n ("Run all"), "player_fwd", KShortcut ("F9"), this, SLOT (slotRunAll ()), actionCollection (), "run_all");
-	runSelection = new KAction (i18n ("Run selection"), "player_play", KShortcut ("F8"), this, SLOT (slotRunSelection ()), actionCollection (), "run_selection");
-	runLine = new KAction (i18n ("Run current line"), "player_end", KShortcut ("Ctrl+L"), this, SLOT (slotRunLine ()), actionCollection (), "run_line");
+	runAll = new KAction (i18n ("Run all"), "player_fwd", KShortcut ("F9"), command_editor, SLOT (runAll()), actionCollection (), "run_all");
+	runSelection = new KAction (i18n ("Run selection"), "player_play", KShortcut ("F8"), command_editor, SLOT (runSelection()), actionCollection (), "run_selection");
+	runLine = new KAction (i18n ("Run current line"), "player_end", KShortcut ("Ctrl+L"), command_editor, SLOT (runLine()), actionCollection (), "run_line");
 
-	helpFunction = new KAction (i18n ("&Function reference"), KShortcut ("F2"), this, SLOT (slotFunctionReference ()), actionCollection (), "function_reference");
+	helpFunction = new KAction (i18n ("&Function reference"), KShortcut ("F2"), command_editor, SLOT (showHelp()), actionCollection (), "function_reference");
 }
 
-void RKCommandEditorWindowPart::slotRunSelection() {
-	RK_TRACE (COMMANDEDITOR);
-
-	if (command_editor->getSelection ().isEmpty () || command_editor->getSelection ().isNull ()) return;
-
-	RKConsole::pipeUserCommand (new RCommand (command_editor->getSelection (), RCommand::User, QString::null));
-}
-
-void RKCommandEditorWindowPart::slotRunLine() {
-	RK_TRACE (COMMANDEDITOR);
-
-	if (command_editor->getLine ().isEmpty () || command_editor->getLine().isNull ()) return;
-
-	RKConsole::pipeUserCommand (new RCommand (command_editor->getLine (), RCommand::User, QString::null));
-}
-
-
-void RKCommandEditorWindowPart::slotRunAll() {
-	RK_TRACE (COMMANDEDITOR);
-
-	if (command_editor->getText ().isEmpty () || command_editor->getText ().isNull ()) return;
-
-	RKConsole::pipeUserCommand (new RCommand (command_editor->getText (), RCommand::User, QString::null));
-}
-
-void RKCommandEditorWindowPart::slotFunctionReference () {
-	RK_TRACE (COMMANDEDITOR);
-
-	command_editor->showHelp ();
-}
-
 #include "rkcommandeditorwindowpart.moc"

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindowpart.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindowpart.h	2007-03-13 22:43:24 UTC (rev 1573)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindowpart.h	2007-03-14 12:28:31 UTC (rev 1574)
@@ -33,16 +33,11 @@
 	RKCommandEditorWindowPart (QWidget *parent, RKCommandEditorWindow *editor_widget);
 
 	~RKCommandEditorWindowPart ();
-public slots:
-	void slotRunSelection ();
-	void slotRunLine ();
-	void slotRunAll ();
-	void slotFunctionReference ();
 private:
 	RKCommandEditorWindow *command_editor;
 
 	void initializeActions ();
-
+// TODO: move these to RKCommandEditorWindow as well, disable runSelection, when there is no selection
 	KAction* runAll;
 	KAction* runSelection;
 	KAction* runLine;


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