[gnome-builder/wip/vim] vim: implement `G` command to move to end of document.



commit ebcc47f3b8046b691e801edbdd8116f5fdd42ba7
Author: Christian Hergert <christian hergert me>
Date:   Mon Sep 29 23:29:31 2014 -0700

    vim: implement `G` command to move to end of document.

 src/editor/gb-editor-vim.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index f6b1a2c..f42dd9e 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -835,6 +835,25 @@ gb_editor_vim_paste (GbEditorVim *vim)
   g_free (text);
 }
 
+static void
+gb_editor_vim_move_to_end (GbEditorVim *vim)
+{
+  GtkTextBuffer *buffer;
+  GtkTextMark *insert;
+  GtkTextIter iter;
+
+  g_return_if_fail (GB_IS_EDITOR_VIM (vim));
+
+  buffer = gtk_text_view_get_buffer (vim->priv->text_view);
+  gtk_text_buffer_get_end_iter (buffer, &iter);
+  gtk_text_buffer_select_range (buffer, &iter, &iter);
+
+  insert = gtk_text_buffer_get_insert (buffer);
+  gtk_text_view_scroll_mark_onscreen (vim->priv->text_view, insert);
+
+  vim->priv->target_line_offset = gb_editor_vim_get_line_offset (vim);
+}
+
 static gboolean
 gb_editor_vim_has_selection (GbEditorVim *vim)
 {
@@ -906,6 +925,13 @@ gb_editor_vim_handle_normal (GbEditorVim *vim,
       gb_editor_vim_move_forward (vim);
       return TRUE;
 
+    case GDK_KEY_G:
+      /*
+       * Move to the end of the buffer.
+       */
+      gb_editor_vim_move_to_end (vim);
+      return TRUE;
+
     case GDK_KEY_h:
       /*
        * Move backward in the buffer one character, but stay on the


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