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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Nov 23 11:36:59 UTC 2010


Revision: 3209
          http://rkward.svn.sourceforge.net/rkward/?rev=3209&view=rev
Author:   tfry
Date:     2010-11-23 11:36:59 +0000 (Tue, 23 Nov 2010)

Log Message:
-----------
While at it, also support pasting into the middle of the command line.

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

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2010-11-23 11:18:10 UTC (rev 3208)
+++ trunk/rkward/ChangeLog	2010-11-23 11:36:59 UTC (rev 3209)
@@ -1,4 +1,5 @@
 - Moved automated testing framework moved to a dedicated R package "rkwardtests", and added documentation
+- Support pasting to the middle of the current command line in the R Console
 - Better handling of script-editor commands while the R Console is busy
 - Correct interleaving of multi-line commands and the corresponding output in the R Console
 - Fixed: Portions of multi-line commands entered on the R Console would be run twice under some circumstances

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2010-11-23 11:18:10 UTC (rev 3208)
+++ trunk/rkward/rkward/rkconsole.cpp	2010-11-23 11:36:59 UTC (rev 3209)
@@ -123,7 +123,7 @@
 // KDE4: a way to do this?
 //	doc->setUndoSteps (0);
 	clear ();
-	doc->setHighlightingMode ("RKWard output");
+	doc->setHighlightingMode ("R interactive session");
 
 	commands_history = RKSettingsModuleConsole::loadCommandHistory ();
 	commands_history_position = commands_history.constEnd ();
@@ -422,6 +422,7 @@
 	int word_start;
 	int word_end;
 	int cursor_pos = currentCursorPositionInCommand ();
+	if (cursor_pos < 0) cursor_pos = current_line.length ();
 	RKCommonFunctions::getCurrentSymbolOffset (current_line, cursor_pos, false, &word_start, &word_end);
 	QString current_symbol = current_line.mid (word_start, word_end - word_start);
 
@@ -717,6 +718,14 @@
 
 	previous_chunk_was_piped = false;
 	input_buffer.append (batch);
+	if (!current_command) {		// pasting into the middle of the command line
+		QString line = currentEditingLine ();
+		int pos = currentCursorPositionInCommand ();
+		if (pos >= 0) {
+			setCurrentEditingLine (line.left (pos));
+			input_buffer.append (line.mid (pos));
+		}
+	}
 	if (!current_command) tryNextInBuffer ();
 }
 
@@ -815,14 +824,12 @@
 	QApplication::clipboard()->setText (view->selectionText ());
 }
 
-int RKConsole::currentCursorPosition () const {
-	KTextEditor::Cursor c = view->cursorPosition ();
-	return(c.column ());
-}
-
 int RKConsole::currentCursorPositionInCommand(){
 	RK_TRACE (APP);
-	return (currentCursorPosition() - prefix.length());
+
+	KTextEditor::Cursor c = view->cursorPosition ();
+	if (c.line () < (doc->lines () - 1)) return -1;
+	return (c.column () - prefix.length());
 }
 
 void RKConsole::resetConsole () {
@@ -913,6 +920,7 @@
 			}
 		}
 	}
+	cursorAtTheEnd ();
 	submitBatch (command_string + '\n');
 	previous_chunk_was_piped = true;
 }

Modified: trunk/rkward/rkward/rkconsole.h
===================================================================
--- trunk/rkward/rkward/rkconsole.h	2010-11-23 11:18:10 UTC (rev 3208)
+++ trunk/rkward/rkward/rkconsole.h	2010-11-23 11:36:59 UTC (rev 3209)
@@ -57,9 +57,7 @@
 
 /** Returns the command currently being edited (not executed yet) */
 	QString currentEditingLine () const;
-/** Returns the current cursor position. Returns the column on which is the cursor.  */
-	int currentCursorPosition () const;
-/** Returns the current cursor position, within the current command (without taking into account the prefix).*/
+/** Returns the current cursor position, within the current command (without taking into account the prefix). Returns -1 if the cursor is not on the line containing the command. */
 	int currentCursorPositionInCommand ();
 	void doTabCompletion ();
 	bool provideContext (unsigned int line_rev, QString *context, int *cursor_position);


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