[gnome-builder] vim: support ctrl+n/ctrl+p in global search



commit cf289165ba29a920946052b220f489935c6b9623
Author: Christian Hergert <chergert redhat com>
Date:   Tue Nov 14 14:34:16 2017 -0800

    vim: support ctrl+n/ctrl+p in global search
    
    This adds keybindings to the VIM keybinding engine that matches what
    we do in other places for movements.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790333

 src/libide/keybindings/vim.css       |   22 ++++++++++++++++++++++
 src/libide/search/ide-search-entry.c |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/libide/keybindings/vim.css b/src/libide/keybindings/vim.css
index 6bf849f..eb81613 100644
--- a/src/libide/keybindings/vim.css
+++ b/src/libide/keybindings/vim.css
@@ -2528,6 +2528,24 @@ bind "KP_Multiply" { "save-insert-mark" ()
   bind "<ctrl>period" { "action" ("win", "global-search", "") };
 }
 
+@binding-set builder-vim-global-search
+{
+  bind "Escape" { "unfocus" () };
+  bind "Return" { "activate-suggestion" () };
+
+  bind "Up" { "move-suggestion" (-1) };
+  bind "<ctrl>p" { "move-suggestion" (-1) };
+  bind "Page_Up" { "move-suggestion" (-10) };
+  bind "KP_Page_Up" { "move-suggestion" (-10) };
+  bind "Prior" { "move-suggestion" (-10) };
+
+  bind "Down" { "move-suggestion" (1) };
+  bind "<ctrl>n" { "move-suggestion" (1) };
+  bind "Page_Down" { "move-suggestion" (10) };
+  bind "KP_Page_Down" { "move-suggestion" (10) };
+  bind "Next" { "move-suggestion" (10) };
+}
+
 /*
  * Sadly, this will draw from the middle, so it does not result in our
  * cursor being over the actual character, but between two characters.
@@ -2841,3 +2859,7 @@ list {
 window.workbench {
   -gtk-key-bindings: builder-vim-workbench;
 }
+
+window.workbench entry.global-search {
+  -gtk-key-bindings: builder-vim-global-search;
+}
diff --git a/src/libide/search/ide-search-entry.c b/src/libide/search/ide-search-entry.c
index 74a9ead..2db92a7 100644
--- a/src/libide/search/ide-search-entry.c
+++ b/src/libide/search/ide-search-entry.c
@@ -220,5 +220,7 @@ ide_search_entry_init (IdeSearchEntry *self)
 {
   self->max_results = DEFAULT_SEARCH_MAX;
 
+  dzl_gtk_widget_add_style_class (GTK_WIDGET (self), "global-search");
+
   g_signal_connect (self, "changed", G_CALLBACK (ide_search_entry_changed), NULL);
 }


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