[gnome-builder/wip/vim] vim: support overwrite mode with `R` command.



commit 66e1a33f30e1f2ed3e88da34a3b8d0ad11d6f760
Author: Christian Hergert <christian hergert me>
Date:   Mon Sep 29 21:02:36 2014 -0700

    vim: support overwrite mode with `R` command.

 src/editor/gb-editor-vim.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index b4e94d2..b9fe8fa 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -91,6 +91,13 @@ gb_editor_vim_set_mode (GbEditorVim     *vim,
   if (mode == GB_EDITOR_VIM_NORMAL)
     vim->priv->target_line_offset = gb_editor_vim_get_line_offset (vim);
 
+  /*
+   * Switch to the "block mode" cursor for non-insert mode. We are totally
+   * abusing "overwrite" here simply to look more like VIM.
+   */
+  gtk_text_view_set_overwrite (vim->priv->text_view,
+                               (mode != GB_EDITOR_VIM_INSERT));
+
   g_object_notify_by_pspec (G_OBJECT (vim), gParamSpecs [PROP_MODE]);
 }
 
@@ -857,6 +864,14 @@ gb_editor_vim_handle_normal (GbEditorVim *vim,
 
       break;
 
+    case GDK_KEY_R:
+      /*
+       * Go into insert mode with overwrite.
+       */
+      gb_editor_vim_set_mode (vim, GB_EDITOR_VIM_INSERT);
+      gtk_text_view_set_overwrite (vim->priv->text_view, TRUE);
+      return TRUE;
+
     case GDK_KEY_greater:
       /*
        * If we have a selection, try to indent it.
@@ -1006,6 +1021,8 @@ gb_editor_vim_connect (GbEditorVim *vim)
                       G_CALLBACK (gb_editor_vim_key_press_event_cb),
                       vim);
 
+  gb_editor_vim_set_mode (vim, GB_EDITOR_VIM_NORMAL);
+
   vim->priv->connected = TRUE;
 }
 


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