[gnome-builder] view: improve command_str recording



commit db9a7e349f3c7c32b645d1dfeca8954c26df1635
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Wed Nov 18 15:58:33 2015 +0100

    view: improve command_str recording
    
    GDK_KEY_KP_0 to GDK_KEY_KP_9 are recorded as 0 to 9
    
    '!' to '~' excluding '[' and ']' are recorded as plain ascii.
    
    Named keys are recorded as [name] including
    [bracketleft] and [bracketright]
    
    This facilitate the search of a key in command_str
    and also using g_str_has_suffix() to find
    the last key.

 libide/ide-source-view.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index cace971..2131d40 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -2087,17 +2087,15 @@ command_string_append_to (GString         *command_str,
   if (state & GDK_MOD1_MASK)
     g_string_append (command_str, "<alt>");
 
-  if (keyval >= '!' && keyval <= '~' )
+  if ((keyval >= '!' && keyval <= '~' ) && keyval != GDK_KEY_bracketleft && keyval != GDK_KEY_bracketright)
     g_string_append_c (command_str, keyval);
+  else if (keyval >= GDK_KEY_KP_0 && keyval <= GDK_KEY_KP_9)
+    g_string_append_c (command_str, keyval - GDK_KEY_KP_0 + '0');
   else
     {
-      if (!ide_str_empty0 (command_str->str) &&
-          (state & ALL_ACCELS_MASK) == 0 &&
-          *(command_str->str + command_str->len - 1) != ' ')
-        g_string_append (command_str, " ");
-
+      g_string_append_c (command_str, '[');
       g_string_append (command_str, gdk_keyval_name (keyval));
-      g_string_append (command_str, " ");
+      g_string_append_c (command_str, ']');
     }
 }
 


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