[gtksourceview/wip/chergert/vim] add yank command
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] add yank command
- Date: Fri, 29 Oct 2021 21:04:14 +0000 (UTC)
commit 61b57d1d8a63f9c721cf6c1785be49ef01e0c592
Author: Christian Hergert <chergert redhat com>
Date: Fri Oct 29 14:04:09 2021 -0700
add yank command
gtksourceview/vim/gtk-source-vim-command.c | 16 ++++++++++++++++
gtksourceview/vim/gtk-source-vim-normal.c | 9 +++++++--
2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command.c b/gtksourceview/vim/gtk-source-vim-command.c
index 89d48872..134b9f1e 100644
--- a/gtksourceview/vim/gtk-source-vim-command.c
+++ b/gtksourceview/vim/gtk-source-vim-command.c
@@ -78,6 +78,20 @@ gtk_source_vim_command_join (GtkSourceVimCommand *self)
gtk_source_vim_state_set_can_repeat (GTK_SOURCE_VIM_STATE (self), TRUE);
}
+static void
+gtk_source_vim_command_yank (GtkSourceVimCommand *self)
+{
+ GtkSourceBuffer *buffer;
+ GtkSourceView *view;
+ GdkClipboard *clipboard;
+
+ buffer = gtk_source_vim_state_get_buffer (GTK_SOURCE_VIM_STATE (self), NULL, NULL);
+ view = gtk_source_vim_state_get_view (GTK_SOURCE_VIM_STATE (self));
+ clipboard = gtk_widget_get_primary_clipboard (GTK_WIDGET (view));
+
+ gtk_text_buffer_copy_clipboard (GTK_TEXT_BUFFER (buffer), clipboard);
+}
+
static void
gtk_source_vim_command_undo (GtkSourceVimCommand *self)
{
@@ -283,6 +297,8 @@ gtk_source_vim_command_class_init (GtkSourceVimCommandClass *klass)
ADD_COMMAND (":undo", gtk_source_vim_command_undo);
ADD_COMMAND (":u", gtk_source_vim_command_undo);
ADD_COMMAND (":redo", gtk_source_vim_command_redo);
+ ADD_COMMAND (":yank", gtk_source_vim_command_yank);
+ ADD_COMMAND (":y", gtk_source_vim_command_yank);
#undef ADD_COMMAND
}
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index f4bb1cc7..3547aad3 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -409,13 +409,18 @@ key_handler_command (GtkSourceVimNormal *self,
}
break;
+ case GDK_KEY_Y:
+ gtk_source_vim_normal_begin_command (self,
+ gtk_source_vim_motion_new_line_end_with_nl (),
+ gtk_source_vim_motion_new_line_start (),
+ ":yank");
+ return TRUE;
+
case GDK_KEY_asciitilde:
case GDK_KEY_p:
case GDK_KEY_P:
case GDK_KEY_equal:
case GDK_KEY_plus:
- case GDK_KEY_Y:
- /* synonum for yy */
default:
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]