[polari/wip/kunaljain/polari-search: 14/18] chatView: Add shortcuts to jump to top/bottom



commit 616d7d0f17d8935170267c06ff12609ca93de6bc
Author: Danny Mølgaard <moelgaard dmp gmail com>
Date:   Wed Jun 1 18:21:31 2016 +0200

    chatView: Add shortcuts to jump to top/bottom
    
    GtkTextView's built-in bindings, <ctrl>Home and <ctrl>End, don't work,
    as they are used by the first-room/last-room application shortcuts. As
    we hide the cursor and don't have horizontal scrolling in the chat log,
    the built-in bindings for jumping to the beginning/end of the current
    line aren't useful, so use them to move to the top/bottom of the
    chatlog instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755549

 src/chatView.js |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 25350cb..7a7f530 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -598,6 +598,21 @@ const ChatView = new Lang.Class({
 
     _onKeyPress: function(w, event) {
         let [, keyval] = event.get_keyval();
+
+        if (keyval === Gdk.KEY_Home ||
+            keyval === Gdk.KEY_KP_Home) {
+            this._view.emit('move-cursor',
+                            Gtk.MovementStep.BUFFER_ENDS,
+                            -1, false);
+            return Gdk.EVENT_STOP;
+        } else if (keyval === Gdk.KEY_End ||
+                   keyval === Gdk.KEY_KP_End) {
+            this._view.emit('move-cursor',
+                            Gtk.MovementStep.BUFFER_ENDS,
+                            1, false);
+            return Gdk.EVENT_STOP;
+        }
+
         if (keyval != Gdk.KEY_Up &&
             keyval != Gdk.KEY_KP_Up &&
             keyval != Gdk.KEY_Page_Up &&


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]