[gnome-builder/wip/vim] vim: clear selection with Escape.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: clear selection with Escape.
- Date: Tue, 30 Sep 2014 21:15:14 +0000 (UTC)
commit 5c4607261e18fcc39b12d11a0f8aca6d23c33463
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 30 14:15:02 2014 -0700
vim: clear selection with Escape.
src/editor/gb-editor-vim.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 8ef276f..c9a75cd 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -1084,6 +1084,25 @@ gb_editor_vim_get_has_selection (GbEditorVim *vim)
return gtk_text_buffer_get_has_selection (buffer);
}
+static void
+gb_editor_vim_clear_selection (GbEditorVim *vim)
+{
+ GtkTextBuffer *buffer;
+ GtkTextMark *insert;
+ GtkTextIter iter;
+
+ g_assert (GB_IS_EDITOR_VIM (vim));
+
+ buffer = gtk_text_view_get_buffer (vim->priv->text_view);
+ insert = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
+ gtk_text_buffer_select_range (buffer, &iter, &iter);
+
+ vim->priv->target_line_offset = gb_editor_vim_get_line_offset (vim);
+
+ gtk_text_view_move_mark_onscreen (vim->priv->text_view, insert);
+}
+
static gboolean
gb_editor_vim_handle_normal (GbEditorVim *vim,
GdkEventKey *event)
@@ -1093,6 +1112,13 @@ gb_editor_vim_handle_normal (GbEditorVim *vim,
switch (event->keyval)
{
+ case GDK_KEY_Escape:
+ /*
+ * Escape any selections we currently have.
+ */
+ gb_editor_vim_clear_selection (vim);
+ break;
+
case GDK_KEY_e:
/*
* Move to the end of the current word if there is one. Otherwise
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]