[gnome-builder] vim: add goto line through command bar
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vim: add goto line through command bar
- Date: Mon, 19 Jan 2015 10:56:06 +0000 (UTC)
commit 901d114a921df48c63338c56c6f3bc5cf49f5fbe
Author: Florian Bäuerle <florian bae gmail com>
Date: Mon Jan 19 11:14:55 2015 +0100
vim: add goto line through command bar
https://bugzilla.gnome.org/show_bug.cgi?id=743138
Signed-off-by: Florian Bäuerle <florian bae gmail com>
src/vim/gb-source-vim.c | 42 +++++++++++++++++++++++++++++++++---------
1 files changed, 33 insertions(+), 9 deletions(-)
---
diff --git a/src/vim/gb-source-vim.c b/src/vim/gb-source-vim.c
index a217d42..58a385b 100644
--- a/src/vim/gb-source-vim.c
+++ b/src/vim/gb-source-vim.c
@@ -3245,7 +3245,7 @@ gb_source_vim_event_after_cb (GtkTextView *text_view,
GbSourceVim *vim)
{
if (vim->priv->mode == GB_SOURCE_VIM_INSERT)
- gb_source_vim_ensure_scroll_off (vim, GB_SOURCE_VIM_ITER_BOUND_START);
+ gb_source_vim_ensure_scroll_off (vim, GB_SOURCE_VIM_ITER_BOUND_START);
}
static gboolean
@@ -3916,6 +3916,21 @@ gb_source_vim_op_nohl (GbSourceVim *vim,
}
static void
+gb_source_vim_op_goto_line (GbSourceVim *vim,
+ const gchar *command_text)
+{
+ if (command_text[0] == '$')
+ gb_source_vim_move_to_end (vim);
+ else
+ {
+ int line = atoi (command_text);
+ line = line > 0 ? line - 1 : 0;
+
+ gb_source_vim_move_to_line_n (vim, line);
+ }
+}
+
+static void
gb_source_vim_op_set_pair (GbSourceVim *vim,
const gchar *key,
const gchar *value)
@@ -4024,24 +4039,33 @@ gb_source_vim_op_set (GbSourceVim *vim,
static GbSourceVimOperation
gb_source_vim_parse_operation (const gchar *command_text)
{
+ GRegex *goto_line_regex;
+ GbSourceVimOperation ret = NULL;
+
g_return_val_if_fail (command_text, NULL);
+ goto_line_regex = g_regex_new ("^([0-9]+|\\$)$", 0, 0, NULL);
+
if (g_str_equal (command_text, "sort"))
- return gb_source_vim_op_sort;
+ ret = gb_source_vim_op_sort;
else if (g_str_equal (command_text, "nohl"))
- return gb_source_vim_op_nohl;
+ ret = gb_source_vim_op_nohl;
else if (g_str_has_prefix (command_text, "set "))
- return gb_source_vim_op_set;
+ ret = gb_source_vim_op_set;
else if (g_str_has_prefix (command_text, "syntax "))
- return gb_source_vim_op_syntax;
+ ret = gb_source_vim_op_syntax;
else if (g_str_has_prefix (command_text, "colorscheme "))
- return gb_source_vim_op_colorscheme;
+ ret = gb_source_vim_op_colorscheme;
else if (g_str_has_prefix (command_text, "%s"))
- return gb_source_vim_op_search_and_replace;
+ ret = gb_source_vim_op_search_and_replace;
else if (g_str_has_prefix (command_text, "s")) /* not ideal */
- return gb_source_vim_op_search_and_replace;
+ ret = gb_source_vim_op_search_and_replace;
+ else if (g_regex_match (goto_line_regex, command_text, 0, NULL))
+ ret = gb_source_vim_op_goto_line;
- return NULL;
+ g_regex_unref (goto_line_regex);
+
+ return ret;
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]