[gnome-builder] vim: add helper to get current word
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vim: add helper to get current word
- Date: Thu, 11 Dec 2014 00:14:07 +0000 (UTC)
commit 4e9da356e6e6912546103e20444144eef88cef56
Author: Christian Hergert <christian hergert me>
Date: Tue Dec 9 20:43:17 2014 -0800
vim: add helper to get current word
src/vim/gb-source-vim.c | 27 +++++++++++++++++++++++++++
src/vim/gb-source-vim.h | 3 +++
2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/vim/gb-source-vim.c b/src/vim/gb-source-vim.c
index c4325ea..2278efe 100644
--- a/src/vim/gb-source-vim.c
+++ b/src/vim/gb-source-vim.c
@@ -2242,6 +2242,33 @@ gb_source_vim_yank (GbSourceVim *vim)
vim->priv->target_line_offset = gb_source_vim_get_line_offset (vim);
}
+gchar *
+gb_source_vim_get_current_word (GbSourceVim *vim,
+ GtkTextIter *begin,
+ GtkTextIter *end)
+{
+ GtkTextBuffer *buffer;
+ GtkTextMark *insert;
+
+ g_return_val_if_fail (GB_IS_SOURCE_VIM (vim), NULL);
+ g_return_val_if_fail (begin, NULL);
+ g_return_val_if_fail (end, NULL);
+
+ 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, begin, insert);
+
+ if (text_iter_forward_vim_word_end (begin))
+ {
+ gtk_text_iter_assign (end, begin);
+ gtk_text_iter_forward_char (end);
+ if (text_iter_backward_vim_word (begin))
+ return gtk_text_iter_get_slice (begin, end);
+ }
+
+ return NULL;
+}
+
static gboolean
gb_source_vim_select_current_word (GbSourceVim *vim,
GtkTextIter *begin,
diff --git a/src/vim/gb-source-vim.h b/src/vim/gb-source-vim.h
index f91086d..7f7479a 100644
--- a/src/vim/gb-source-vim.h
+++ b/src/vim/gb-source-vim.h
@@ -83,6 +83,9 @@ GtkWidget *gb_source_vim_get_text_view (GbSourceVim *vim);
gboolean gb_source_vim_execute_command (GbSourceVim *vim,
const gchar *command);
gboolean gb_source_vim_is_command (const gchar *command_text);
+gchar *gb_source_vim_get_current_word (GbSourceVim *vim,
+ GtkTextIter *begin,
+ GtkTextIter *end);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]