[gnome-builder/wip/vim] vim: plumb some basic event handling for command mode.



commit 86943d9896cad8b51e11feea94c6fb21e52bac0d
Author: Christian Hergert <christian hergert me>
Date:   Tue Sep 30 17:46:58 2014 -0700

    vim: plumb some basic event handling for command mode.

 src/editor/gb-editor-vim.c |   50 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 121fc2b..0d20b5c 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -1613,6 +1613,13 @@ gb_editor_vim_handle_normal (GbEditorVim *vim,
       gb_editor_vim_reverse_search (vim);
       return TRUE;
 
+    case GDK_KEY_colon:
+      /*
+       * Switch to command mode.
+       */
+      gb_editor_vim_set_mode (vim, GB_EDITOR_VIM_COMMAND);
+      return TRUE;
+
     default:
       break;
     }
@@ -1658,7 +1665,48 @@ static gboolean
 gb_editor_vim_handle_command (GbEditorVim *vim,
                               GdkEventKey *event)
 {
-  return FALSE;
+  switch (event->keyval)
+    {
+    case GDK_KEY_Escape:
+      /*
+       * Escape back into NORMAL mode.
+       */
+      gb_editor_vim_set_mode (vim, GB_EDITOR_VIM_NORMAL);
+      return TRUE;
+
+    case GDK_KEY_KP_Enter:
+    case GDK_KEY_Return:
+      /*
+       * Execute the command line and then go back to normal mode.
+       */
+      g_printerr ("Execute Command Line: %s\n", vim->priv->command_line->str);
+      gb_editor_vim_set_mode (vim, GB_EDITOR_VIM_NORMAL);
+      return TRUE;
+
+    case GDK_KEY_u:
+      /*
+       * Delete everything before the cursor upon <Control>U.
+       */
+      if ((event->state & GDK_CONTROL_MASK) != 0)
+        {
+          g_string_truncate (vim->priv->command_line, 0);
+          return TRUE;
+        }
+
+      break;
+
+    default:
+      break;
+    }
+
+  /*
+   * TODO: This is not sufficient, since we can't handle control text.
+   *       We really need to display an entry that we own somewhere.
+   *       Possibly on our behalf by the editor container.
+   */
+  g_string_append (vim->priv->command_line, event->string);
+
+  return TRUE;
 }
 
 static gboolean


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