[gnome-builder/wip/vim] vim: `x` should move the cut text into the selection clipboard.



commit 297e8b09b3e251718f73a2a4bdb77ecf3cf68c7b
Author: Christian Hergert <christian hergert me>
Date:   Mon Sep 29 21:07:49 2014 -0700

    vim: `x` should move the cut text into the selection clipboard.

 src/editor/gb-editor-vim.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index b9fe8fa..9acb549 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -431,6 +431,8 @@ gb_editor_vim_delete_selection (GbEditorVim *vim)
   GtkTextMark *insert;
   GtkTextIter begin;
   GtkTextIter end;
+  GtkClipboard *clipboard;
+  gchar *text;
 
   g_assert (GB_IS_EDITOR_VIM (vim));
 
@@ -465,6 +467,15 @@ gb_editor_vim_delete_selection (GbEditorVim *vim)
     }
 
   /*
+   * Yank the selection text and apply it to the clipboard.
+   */
+  text = gtk_text_iter_get_slice (&begin, &end);
+  clipboard = gtk_widget_get_clipboard (GTK_WIDGET (vim->priv->text_view),
+                                        GDK_SELECTION_CLIPBOARD);
+  gtk_clipboard_set_text (clipboard, text, -1);
+  g_free (text);
+
+  /*
    * If this selection is an entire line, delete the trailing newline as
    * VIM does in both `v` and `V` selection modes.
    */


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