[gnome-builder/wip/vim] vim: implement `D` to delete to end of line.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: implement `D` to delete to end of line.
- Date: Tue, 30 Sep 2014 00:51:58 +0000 (UTC)
commit 33d3e85ebd3fd0a7e63f72076466fdcd4316f401
Author: Christian Hergert <christian hergert me>
Date: Mon Sep 29 17:51:53 2014 -0700
vim: implement `D` to delete to end of line.
src/editor/gb-editor-vim.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 33243c7..9efb886 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -628,6 +628,35 @@ gb_editor_vim_insert_nl_after (GbEditorVim *vim)
gtk_text_view_scroll_mark_onscreen (vim->priv->text_view, insert);
}
+static void
+gb_editor_vim_delete_to_line_end (GbEditorVim *vim)
+{
+ GtkTextBuffer *buffer;
+ GtkTextMark *insert;
+ GtkTextIter begin;
+ GtkTextIter end;
+
+ g_return_if_fail (GB_IS_EDITOR_VIM (vim));
+
+ buffer = gtk_text_view_get_buffer (vim->priv->text_view);
+ insert = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, &begin, insert);
+ gtk_text_iter_assign (&end, &begin);
+
+ /*
+ * Move forward to the end of the line, excluding the \n.
+ */
+ while (!gtk_text_iter_ends_line (&end))
+ if (!gtk_text_iter_forward_char (&end))
+ break;
+
+ gtk_text_buffer_begin_user_action (buffer);
+ gtk_text_buffer_delete (buffer, &begin, &end);
+ gtk_text_buffer_end_user_action (buffer);
+
+ vim->priv->target_line_offset = gb_editor_vim_get_line_offset (vim);
+}
+
static gboolean
gb_editor_vim_has_selection (GbEditorVim *vim)
{
@@ -683,6 +712,14 @@ gb_editor_vim_handle_normal (GbEditorVim *vim,
gb_editor_vim_set_mode (vim, GB_EDITOR_VIM_INSERT);
return TRUE;
+ case GDK_KEY_D:
+ /*
+ * Delete from the current position to the end of the line.
+ * Stay in NORMAL mode.
+ */
+ gb_editor_vim_delete_to_line_end (vim);
+ return TRUE;
+
case GDK_KEY_l:
/*
* Move forward in the buffer one character, but stay on the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]