[gnome-builder/tweak] vim: adjust initial state of cursor
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/tweak] vim: adjust initial state of cursor
- Date: Wed, 17 Dec 2014 03:39:15 +0000 (UTC)
commit 549826ea2e77f25e1900bd6b64354db047cc0ac0
Author: Christian Hergert <christian hergert me>
Date: Tue Dec 16 19:05:15 2014 -0800
vim: adjust initial state of cursor
We might be past where we would normally be, boundary wise. So possibly
adjust the cursor position backwards if we are at the end of the line.
src/vim/gb-source-vim.c | 38 ++++++++++++++++++++++++++++----------
1 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/src/vim/gb-source-vim.c b/src/vim/gb-source-vim.c
index c1b9e1a..087cb2f 100644
--- a/src/vim/gb-source-vim.c
+++ b/src/vim/gb-source-vim.c
@@ -3062,6 +3062,31 @@ gb_source_vim_focus_in_event_cb (GtkTextView *text_view,
}
static void
+gb_source_vim_maybe_adjust_insert (GbSourceVim *vim)
+{
+ GtkTextBuffer *buffer;
+ GtkTextMark *insert;
+ GtkTextIter iter;
+
+ g_return_if_fail (GB_IS_SOURCE_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);
+
+ if (gtk_text_iter_ends_line (&iter) &&
+ !gtk_text_iter_starts_line (&iter) &&
+ !gtk_text_buffer_get_has_selection (buffer))
+ {
+ /*
+ * Probably want to add a canary here for dealing with reentrancy.
+ */
+ if (gtk_text_iter_backward_char (&iter))
+ gtk_text_buffer_select_range (buffer, &iter, &iter);
+ }
+}
+
+static void
gb_source_vim_mark_set_cb (GtkTextBuffer *buffer,
GtkTextIter *iter,
GtkTextMark *mark,
@@ -3081,16 +3106,7 @@ gb_source_vim_mark_set_cb (GtkTextBuffer *buffer,
if (mark != gtk_text_buffer_get_insert (buffer))
return;
- if (gtk_text_iter_ends_line (iter) &&
- !gtk_text_iter_starts_line (iter) &&
- !gtk_text_buffer_get_has_selection (buffer))
- {
- /*
- * Probably want to add a canary here for dealing with reentrancy.
- */
- if (gtk_text_iter_backward_char (iter))
- gtk_text_buffer_select_range (buffer, iter, iter);
- }
+ gb_source_vim_maybe_adjust_insert (vim);
}
static void
@@ -3294,8 +3310,10 @@ gb_source_vim_set_enabled (GbSourceVim *vim,
if (enabled)
{
+
gb_source_vim_connect (vim);
priv->enabled = TRUE;
+ gb_source_vim_maybe_adjust_insert (vim);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]