[rkward-cvs] SF.net SVN: rkward:[4075] trunk/rkward/rkward/rkconsole.cpp

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Dec 7 16:13:36 UTC 2011


Revision: 4075
          http://rkward.svn.sourceforge.net/rkward/?rev=4075&view=rev
Author:   tfry
Date:     2011-12-07 16:13:36 +0000 (Wed, 07 Dec 2011)
Log Message:
-----------
Fix issue with cursor keys not working in the R Console window on Mac

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

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2011-12-06 22:52:13 UTC (rev 4074)
+++ trunk/rkward/rkward/rkconsole.cpp	2011-12-07 16:13:36 UTC (rev 4075)
@@ -237,18 +237,22 @@
 
 	previous_chunk_was_piped = false;
 
+	// Apparently, on MacOSX, additional modifiers may sometimes be present (KeypadModifier?), which we want to ignore.
+	const int modifier_mask = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier;
+	Qt::KeyboardModifiers modifier = e->modifiers () & modifier_mask;
+
 	if (e->key () == Qt::Key_Up) {
-		commandsListUp (RKSettingsModuleConsole::shouldDoHistoryContextSensitive (e->modifiers ()));
+		commandsListUp (RKSettingsModuleConsole::shouldDoHistoryContextSensitive (modifier));
 		return true;
 	}
 	else if (e->key () == Qt::Key_Down) {
-		commandsListDown (RKSettingsModuleConsole::shouldDoHistoryContextSensitive (e->modifiers ()));
+		commandsListDown (RKSettingsModuleConsole::shouldDoHistoryContextSensitive (modifier));
 		return true;
 	}
 	command_edited = true; // all other keys are considered as "editing" the current comand
 
 	if (e->key () == Qt::Key_Home) {
-		if (e->modifiers () == Qt::ShiftModifier) {
+		if (modifier == Qt::ShiftModifier) {
 			int lastline = doc->lines () - 1;
 			int firstcol = prefix.length ();
 			KTextEditor::Range newrange (lastline, firstcol, lastline, pos);
@@ -266,7 +270,7 @@
 		cursorAtTheBeginning ();
 		return true;
 	} else if (e->key () == Qt::Key_End) {
-		if (e->modifiers () == Qt::ShiftModifier) {
+		if (modifier == Qt::ShiftModifier) {
 			int lastline = doc->lines () - 1;
 			int lastcol = doc->lineLength (lastline);
 			KTextEditor::Range newrange (lastline, pos, lastline, lastcol);
@@ -291,20 +295,20 @@
 	} else if (e->key () == Qt::Key_Left){
 		if (pos <= prefix.length ()) return true;
 
-		if (e->modifiers () == Qt::NoModifier) setCursorClear (para, pos - 1);
-		else if (e->modifiers () == Qt::ShiftModifier) triggerEditAction ("select_char_left");
-		else if (e->modifiers () == Qt::ControlModifier) triggerEditAction ("word_left");
-		else if (e->modifiers () == (Qt::ControlModifier + Qt::ShiftModifier)) triggerEditAction ("select_word_left");
+		if (modifier == Qt::NoModifier) setCursorClear (para, pos - 1);
+		else if (modifier == Qt::ShiftModifier) triggerEditAction ("select_char_left");
+		else if (modifier == Qt::ControlModifier) triggerEditAction ("word_left");
+		else if (modifier == (Qt::ControlModifier + Qt::ShiftModifier)) triggerEditAction ("select_word_left");
 		else return false;
 
 		return true;
 	} else if (e->key () == Qt::Key_Right){
 		if (pos >= doc->lineLength (para)) return true;
 
-		if (e->modifiers () == Qt::NoModifier) setCursorClear (para, pos + 1);
-		else if (e->modifiers () == Qt::ShiftModifier) triggerEditAction ("select_char_right");
-		else if (e->modifiers () == Qt::ControlModifier) triggerEditAction ("word_right");
-		else if (e->modifiers () == (Qt::ControlModifier + Qt::ShiftModifier)) triggerEditAction ("select_word_right");
+		if (modifier == Qt::NoModifier) setCursorClear (para, pos + 1);
+		else if (modifier == Qt::ShiftModifier) triggerEditAction ("select_char_right");
+		else if (modifier == Qt::ControlModifier) triggerEditAction ("word_right");
+		else if (modifier == (Qt::ControlModifier + Qt::ShiftModifier)) triggerEditAction ("select_word_right");
 		else return false;
 
 		return true;

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