[gtksourceview/wip/chergert/vim] reuse unescaped helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] reuse unescaped helper
- Date: Wed, 3 Nov 2021 21:20:37 +0000 (UTC)
commit 1ded11f27fa5c780a3bc2fc2bb462052d8c06628
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 3 14:20:06 2021 -0700
reuse unescaped helper
gtksourceview/vim/gtk-source-vim-insert-literal.c | 33 ++---------------------
gtksourceview/vim/gtk-source-vim-state.c | 8 +++++-
2 files changed, 9 insertions(+), 32 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-insert-literal.c
b/gtksourceview/vim/gtk-source-vim-insert-literal.c
index 87ff40af..3ae941f8 100644
--- a/gtksourceview/vim/gtk-source-vim-insert-literal.c
+++ b/gtksourceview/vim/gtk-source-vim-insert-literal.c
@@ -78,40 +78,11 @@ gtk_source_vim_insert_literal_handle_keypress (GtkSourceVimState *state,
const char *string)
{
GtkSourceVimInsertLiteral *self = (GtkSourceVimInsertLiteral *)state;
- char outbuf[8] = {0};
- gunichar ch;
+ char outbuf[16] = {0};
g_assert (GTK_SOURCE_IS_VIM_INSERT_LITERAL (self));
- switch (keyval)
- {
- case GDK_KEY_Return:
- case GDK_KEY_KP_Enter:
- case GDK_KEY_ISO_Enter:
- return do_literal (self, "\n");
-
- case GDK_KEY_BackSpace:
- return do_literal (self, "\b");
-
- case GDK_KEY_Tab:
- return do_literal (self, "\t");
-
- case GDK_KEY_Escape:
- return do_literal (self, "\e");
-
- case GDK_KEY_l:
- if ((mods & GDK_CONTROL_MASK) != 0)
- return do_literal (self, "\f");
- break;
-
- default:
- break;
- }
-
- ch = gdk_keyval_to_unicode (keyval);
-
- if (g_unichar_to_utf8 (ch, outbuf) <= 0)
- outbuf[0] = 0;
+ gtk_source_vim_state_keyval_unescaped (keyval, mods, outbuf);
return do_literal (self, outbuf);
}
diff --git a/gtksourceview/vim/gtk-source-vim-state.c b/gtksourceview/vim/gtk-source-vim-state.c
index e2cc5456..78efed96 100644
--- a/gtksourceview/vim/gtk-source-vim-state.c
+++ b/gtksourceview/vim/gtk-source-vim-state.c
@@ -87,12 +87,18 @@ gtk_source_vim_state_keyval_unescaped (guint keyval,
switch (keyval)
{
+ case GDK_KEY_Tab:
+ case GDK_KEY_KP_Tab:
+ case GDK_KEY_ISO_Left_Tab:
+ return_str ("\t");
+
case GDK_KEY_BackSpace:
return_str ("\b");
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
- return_str ("\r");
+ case GDK_KEY_ISO_Enter:
+ return_str ("\n");
default:
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]