[gtksourceview/wip/chergert/vim] ctrl+c exits insert mode
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] ctrl+c exits insert mode
- Date: Fri, 5 Nov 2021 18:44:21 +0000 (UTC)
commit e000e37e1e1e394962622929830cb12f555b0ac5
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 5 11:43:29 2021 -0700
ctrl+c exits insert mode
gtksourceview/vim/gtk-source-vim-insert.c | 5 +++--
gtksourceview/vim/gtk-source-vim-state.h | 7 +++++++
2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-insert.c b/gtksourceview/vim/gtk-source-vim-insert.c
index 0bd8e870..d95ecb3f 100644
--- a/gtksourceview/vim/gtk-source-vim-insert.c
+++ b/gtksourceview/vim/gtk-source-vim-insert.c
@@ -129,8 +129,9 @@ gtk_source_vim_insert_handle_event (GtkSourceVimState *state,
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
return TRUE;
- /* Leave insert mode if Escape/ctrl+[ was pressed */
- if (gtk_source_vim_state_is_escape (keyval, mods))
+ /* Leave insert mode if Escape,ctrl+[,ctrl+c was pressed */
+ if (gtk_source_vim_state_is_escape (keyval, mods) ||
+ gtk_source_vim_state_is_ctrl_c (keyval, mods))
{
gtk_source_vim_state_pop (GTK_SOURCE_VIM_STATE (self));
return TRUE;
diff --git a/gtksourceview/vim/gtk-source-vim-state.h b/gtksourceview/vim/gtk-source-vim-state.h
index 7e55a008..3332ff2c 100644
--- a/gtksourceview/vim/gtk-source-vim-state.h
+++ b/gtksourceview/vim/gtk-source-vim-state.h
@@ -136,4 +136,11 @@ gtk_source_vim_state_is_escape (guint keyval,
(keyval == GDK_KEY_bracketleft && (mods & GDK_CONTROL_MASK) != 0);
}
+static inline gboolean
+gtk_source_vim_state_is_ctrl_c (guint keyval,
+ GdkModifierType mods)
+{
+ return keyval == GDK_KEY_c && (mods & GDK_CONTROL_MASK) != 0;
+}
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]