[rkward] rkward/windows: Direct up/down to document navigation, alt+up/down for navigating completion list. TODO: Allow configuration.

Thomas Friedrichsmeier null at kde.org
Tue Feb 19 08:39:38 GMT 2019


Git commit 7c00c4b628d1d9e8670a3fb52117f3592416454a by Thomas Friedrichsmeier.
Committed on 19/02/2019 at 08:39.
Pushed by tfry into branch 'master'.

Direct up/down to document navigation, alt+up/down for navigating completion list. TODO: Allow configuration.

M  +20   -0    rkward/windows/rkcommandeditorwindow.cpp

https://commits.kde.org/rkward/7c00c4b628d1d9e8670a3fb52117f3592416454a

diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index 20f40d28..f1ebc105 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -1471,6 +1471,26 @@ bool RKCompletionManager::eventFilter (QObject* watched, QEvent* event) {
 				}
 				return true;
 			}
+		} else if ((k->key () == Qt::Key_Up || k->key () == Qt::Key_Down) && cc_iface->isCompletionActive ()) {
+			// Make up / down-keys (without alt) navigate in the document (aborting the completion)
+			// Meke alt+up / alt+down naviate in the completion list
+			if (k->modifiers () & Qt::AltModifier) {
+				if (k->type() != QKeyEvent::KeyPress) return true;  // eat the release event
+
+				// No, we cannot just send a fake key event, easily...
+				KActionCollection *kate_edit_actions = view ()->findChild<KActionCollection*> ("edit_actions");
+				QAction *action = kate_edit_actions ? (kate_edit_actions->action (k->key () == Qt::Key_Up ? "move_line_up" : "move_line_down")) : 0;
+				if (!action) {
+					kate_edit_actions = view ()->actionCollection ();
+					action = kate_edit_actions ? (kate_edit_actions->action (k->key () == Qt::Key_Up ? "move_line_up" : "move_line_down")) : 0;
+				}
+				if (action) action->trigger ();
+				else RK_ASSERT (action);
+				return true;
+			} else {
+				cc_iface->abortCompletion ();
+				return false;
+			}
 		}
 	}
 



More information about the rkward-tracker mailing list