[gnome-builder/wip/vim] vim: add selection support for `l`
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: add selection support for `l`
- Date: Tue, 30 Sep 2014 20:11:22 +0000 (UTC)
commit ee2f8561ca8668e4cf14a03d5ce492b936fed6dd
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 30 13:11:16 2014 -0700
vim: add selection support for `l`
src/editor/gb-editor-vim.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 7d58085..bbfb8a3 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -323,8 +323,9 @@ gb_editor_vim_move_forward (GbEditorVim *vim)
{
GbEditorVimPrivate *priv;
GtkTextBuffer *buffer;
- GtkTextMark *insert;
- GtkTextIter iter;
+ GtkTextIter begin;
+ GtkTextIter end;
+ gboolean has_selection;
guint line;
g_assert (GB_IS_EDITOR_VIM (vim));
@@ -332,19 +333,18 @@ gb_editor_vim_move_forward (GbEditorVim *vim)
priv = vim->priv;
buffer = gtk_text_view_get_buffer (priv->text_view);
- insert = gtk_text_buffer_get_insert (buffer);
- gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
- line = gtk_text_iter_get_line (&iter);
-
- /*
- * TODO: handle there being a selection.
- */
-
- if (gtk_text_iter_forward_char (&iter) &&
- (line == gtk_text_iter_get_line (&iter)))
- gtk_text_buffer_select_range (buffer, &iter, &iter);
+ has_selection = gtk_text_buffer_get_selection_bounds (buffer, &begin, &end);
+ line = gtk_text_iter_get_line (&end);
- vim->priv->target_line_offset = gb_editor_vim_get_line_offset (vim);
+ if (gtk_text_iter_forward_char (&end) &&
+ (line == gtk_text_iter_get_line (&end)))
+ {
+ if (has_selection)
+ gtk_text_buffer_select_range (buffer, &begin, &end);
+ else
+ gtk_text_buffer_select_range (buffer, &end, &end);
+ vim->priv->target_line_offset = gb_editor_vim_get_line_offset (vim);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]