From 9c42b0d5383261c8773fcbd8038fe92c9cf184c2 Mon Sep 17 00:00:00 2001 From: Jeremy Paul Wootten Date: Tue, 7 Dec 2021 18:49:05 +0000 Subject: [PATCH 1/2] Change key to trigger rebuild completion word list --- plugins/word-completion/plugin.vala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/word-completion/plugin.vala b/plugins/word-completion/plugin.vala index 0debc5c6b1..9ea865a121 100644 --- a/plugins/word-completion/plugin.vala +++ b/plugins/word-completion/plugin.vala @@ -38,7 +38,7 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable { Gdk.Key.ISO_Left_Tab, }; - private const uint USER_REQUESTED_KEY = Gdk.Key.backslash; + private const string REFRESH_SHORTCUT = "|"; //In combination with will cause refresh private uint timeout_id = 0; private bool completion_visible = false; @@ -130,7 +130,9 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable { * alternative and also purges spelling mistakes and unused words from the list. * If used when a word or part of a word is selected, the selection will be * used as the word to find. */ - if ((mods & Gdk.ModifierType.CONTROL_MASK) > 0 && (kv == USER_REQUESTED_KEY)) { + if ((mods & Gdk.ModifierType.CONTROL_MASK) > 0 && + (uc.to_string () == REFRESH_SHORTCUT)) { + parser.rebuild_word_list (current_view); current_view.show_completion (); return true; From cb698262efe1734f167a0ec0b1b1e18bb73a0b4a Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Fri, 2 Sep 2022 09:01:22 +0100 Subject: [PATCH 2/2] Use keyval for USER_REQUESTED_KEY --- plugins/word-completion/plugin.vala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/word-completion/plugin.vala b/plugins/word-completion/plugin.vala index c3e9c0afcc..d227d12a6a 100644 --- a/plugins/word-completion/plugin.vala +++ b/plugins/word-completion/plugin.vala @@ -39,7 +39,7 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable { Gdk.Key.ISO_Left_Tab, }; - private const string REFRESH_SHORTCUT = "|"; //In combination with will cause refresh + private const uint REFRESH_SHORTCUT = Gdk.Key.bar; //"|" in combination with will cause refresh private uint timeout_id = 0; @@ -121,9 +121,7 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable { } private bool on_key_press (Gtk.Widget view, Gdk.EventKey event) { - uint kv = event.keyval; - unichar uc = (unichar)(Gdk.keyval_to_unicode (kv)); - + var kv = event.keyval; /* Pass through any modified keypress except Shift or Capslock */ Gdk.ModifierType mods = event.state & Gdk.ModifierType.MODIFIER_MASK & ~Gdk.ModifierType.SHIFT_MASK @@ -134,8 +132,9 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable { * alternative and also purges spelling mistakes and unused words from the list. * If used when a word or part of a word is selected, the selection will be * used as the word to find. */ + if ((mods & Gdk.ModifierType.CONTROL_MASK) > 0 && - (uc.to_string () == REFRESH_SHORTCUT)) { + (kv == REFRESH_SHORTCUT)) { parser.rebuild_word_list (current_view); current_view.show_completion (); @@ -143,8 +142,10 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable { } } + var uc = (unichar)(Gdk.keyval_to_unicode (kv)); if (!completion_in_progress && Euclide.Completion.Parser.is_delimiter (uc) && (uc.isprint () || uc.isspace ())) { + var buffer = current_view.buffer; var mark = buffer.get_insert (); Gtk.TextIter cursor_iter;