[gtksourceview/wip/chergert/vim: 97/363] normal implement D
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 97/363] normal implement D
- Date: Mon, 8 Nov 2021 19:53:47 +0000 (UTC)
commit c253b98b209353faee3b7726ab2f5dd891128cd8
Author: Christian Hergert <chergert redhat com>
Date: Wed Oct 27 15:30:45 2021 -0700
normal implement D
still doesn't handle movement quite right, but its a start
gtksourceview/vim/gtk-source-vim-normal.c | 38 +++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 7 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index 2fa97f28..d65a43aa 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -22,6 +22,7 @@
#include "config.h"
#include "gtk-source-vim-command-bar.h"
+#include "gtk-source-vim-delete.h"
#include "gtk-source-vim-insert.h"
#include "gtk-source-vim-motion.h"
#include "gtk-source-vim-normal.h"
@@ -169,13 +170,23 @@ key_handler_undo (GtkSourceVimNormal *self,
return TRUE;
}
-typedef enum
+G_GNUC_NULL_TERMINATED
+static void
+gtk_source_vim_normal_begin_delete (GtkSourceVimNormal *self,
+ GtkSourceVimState *motion,
+ ...)
{
- INSERT_HERE,
- INSERT_AFTER_CHAR,
- INSERT_AFTER_CHAR_UNLESS_BOF,
- INSERT_AFTER_CHAR_UNLESS_SOL,
-} InsertAt;
+ GtkSourceVimState *del;
+
+ g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
+ g_assert (GTK_SOURCE_IS_VIM_MOTION (motion));
+
+ del = gtk_source_vim_delete_new (GTK_SOURCE_VIM_MOTION (motion));
+
+ gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), del);
+ if (motion != NULL)
+ gtk_source_vim_state_pop (del);
+}
G_GNUC_NULL_TERMINATED
static GtkSourceVimState *
@@ -221,6 +232,14 @@ gtk_source_vim_normal_begin_change (GtkSourceVimNormal *self,
return ret;
}
+typedef enum
+{
+ INSERT_HERE,
+ INSERT_AFTER_CHAR,
+ INSERT_AFTER_CHAR_UNLESS_BOF,
+ INSERT_AFTER_CHAR_UNLESS_SOL,
+} InsertAt;
+
G_GNUC_NULL_TERMINATED
static GtkSourceVimState *
gtk_source_vim_normal_begin_insert (GtkSourceVimNormal *self,
@@ -336,8 +355,13 @@ key_handler_command (GtkSourceVimNormal *self,
NULL);
return TRUE;
- case GDK_KEY_asciitilde:
case GDK_KEY_D:
+ gtk_source_vim_normal_begin_delete (self,
+ gtk_source_vim_motion_new_line_end (),
+ NULL);
+ return TRUE;
+
+ case GDK_KEY_asciitilde:
case GDK_KEY_J:
case GDK_KEY_p:
case GDK_KEY_P:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]