[gegl] bin: simplify keybindings



commit e2655ff58947d7d19e177e79468b4a4bac7e27ab
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Feb 13 22:46:44 2019 +0100

    bin: simplify keybindings
    
    Use a custom binding for empty commandline buffer, permitting cursor
    keys and more to be bound to ui navigation.

 bin/ui.c | 57 +++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 41 insertions(+), 16 deletions(-)
---
diff --git a/bin/ui.c b/bin/ui.c
index bec87a9db..31fb22314 100644
--- a/bin/ui.c
+++ b/bin/ui.c
@@ -5050,6 +5050,16 @@ static void expand_completion (MrgEvent *event, void *data1, void *data2)
   mrg_event_stop_propagate (event);
 }
 
+static void cmd_unhandled (MrgEvent *event, void *data1, void *data2)
+{
+  if (mrg_utf8_strlen (event->string) != 1)
+    return;
+
+  strcpy (commandline, event->string);
+  mrg_event_stop_propagate (event);
+  mrg_set_cursor_pos (event->mrg, 1);
+  mrg_queue_draw (event->mrg, NULL);
+}
 
 static void ui_commandline (Mrg *mrg, void *data)
 {
@@ -5062,10 +5072,15 @@ static void ui_commandline (Mrg *mrg, void *data)
 
   if (scrollback == NULL && commandline[0]==0)
   {
+#if 0
     mrg_set_xy (mrg, 0,h*2);
     mrg_edit_start (mrg, update_commandline, o);
     mrg_printf (mrg, "%s", commandline);
     mrg_edit_end (mrg);
+#else
+    mrg_add_binding (mrg, "unhandled", NULL, "start entering commandline", cmd_unhandled, NULL);
+#endif
+    /* XXX - a custom listener only for permitted start commandline keys */
     goto jump;
   }
 
@@ -5569,16 +5584,8 @@ static void gegl_ui (Mrg *mrg, void *data)
   }
   mrg_add_binding (mrg, "control-l", NULL, "clear/redraw", run_command, "clear");
 
-  if (!text_editor_active (o) && !o->property_focus)
-  {
-    mrg_add_binding (mrg, "tab", NULL, NULL, run_command, "toggle controls");
-    mrg_add_binding (mrg, "control-f", NULL, NULL,  run_command, "toggle fullscreen");
 
-
-    ui_commandline (mrg, o);
-  }
-
-  if (commandline[0]==0 && !text_editor_active(o))
+  if (!text_editor_active(o))
   {
     /* cursor keys and some more keys are used for commandline entry if there already
        is contents, this frees up some bindings/individual keys for direct binding as
@@ -5597,8 +5604,11 @@ static void gegl_ui (Mrg *mrg, void *data)
       mrg_add_binding (mrg, "home", NULL, NULL, run_command, "collection first");
       mrg_add_binding (mrg, "end", NULL, NULL, run_command, "collection last");
 
-      mrg_add_binding (mrg, "space", NULL, NULL,   run_command, "collection right");
-      mrg_add_binding (mrg, "backspace", NULL, NULL,  run_command, "collection left");
+      if (commandline[0] == 0)
+      {
+        mrg_add_binding (mrg, "space", NULL, NULL,   run_command, "collection right");
+        mrg_add_binding (mrg, "backspace", NULL, NULL,  run_command, "collection left");
+      }
 
     }
     else if (o->show_graph)
@@ -5638,7 +5648,9 @@ static void gegl_ui (Mrg *mrg, void *data)
           mrg_add_binding (mrg, "left", NULL, NULL,        run_command, "graph-cursor left");
         if (o->active) // && gegl_node_has_pad (o->active, "aux"))
           mrg_add_binding (mrg, "right", NULL, NULL, run_command, "graph-cursor right");
-        mrg_add_binding (mrg, "space", NULL, "next image",   run_command, "next");
+
+        if (!o->show_graph)
+          mrg_add_binding (mrg, "space", NULL, "next image",   run_command, "next");
       }
       //mrg_add_binding (mrg, "backspace", NULL, NULL,  run_command, "prev");
     }
@@ -5723,10 +5735,6 @@ static void gegl_ui (Mrg *mrg, void *data)
   mrg_add_binding (mrg, "control-h", NULL, NULL, run_command, "toggle cheatsheet");
   mrg_add_binding (mrg, "control-delete", NULL, NULL,  run_command, "discard");
 
-  if (o->show_bindings)
-  {
-     ui_show_bindings (mrg, o);
-  }
 
   if (o->editing_property)
   {
@@ -5737,6 +5745,23 @@ static void gegl_ui (Mrg *mrg, void *data)
     cairo_new_path (mrg_cr (mrg));
   }
 
+
+  mrg_add_binding (mrg, "control-f", NULL, NULL,  run_command, "toggle fullscreen");
+  if (!text_editor_active (o))// && !o->property_focus)
+  {
+    //mrg_add_binding (mrg, "tab", NULL, NULL, run_command, "toggle controls");
+    ui_commandline (mrg, o);
+  }
+  else
+  {
+
+  }
+
+  if (o->show_bindings)
+  {
+     ui_show_bindings (mrg, o);
+  }
+
 }
 
 /***********************************************/


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