[gnome-builder/wip/vim] vim: render the phrase status in the position label.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: render the phrase status in the position label.
- Date: Thu, 2 Oct 2014 10:10:25 +0000 (UTC)
commit 1b3a789514c27dd19c6701c564f184746dae0a6c
Author: Christian Hergert <christian hergert me>
Date: Thu Oct 2 03:08:49 2014 -0700
vim: render the phrase status in the position label.
src/editor/gb-editor-tab.c | 26 +++++++++++++++++++++++++-
src/editor/gb-editor-vim.c | 8 ++++++++
src/editor/gb-editor-vim.h | 1 +
3 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 1d04188..ebbb7c1 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -413,6 +413,7 @@ gb_editor_tab_cursor_moved (GbEditorTab *tab,
GtkTextBuffer *buffer;
GtkTextIter iter;
GtkTextMark *mark;
+ const gchar *phrase = NULL;
gchar *text;
guint ln;
guint col;
@@ -429,7 +430,15 @@ gb_editor_tab_cursor_moved (GbEditorTab *tab,
ln = gtk_text_iter_get_line (&iter);
col = gtk_source_view_get_visual_column (source_view, &iter);
- text = g_strdup_printf (_ ("Line %u, Column %u"), ln + 1, col + 1);
+ if (tab->priv->vim)
+ phrase = gb_editor_vim_get_phrase (tab->priv->vim);
+
+ if (!gb_str_empty0 (phrase))
+ text = g_strdup_printf (_ ("%s\tLine %u, Column %u"),
+ phrase, ln + 1, col + 1);
+ else
+ text = g_strdup_printf (_ ("Line %u, Column %u"), ln + 1, col + 1);
+
nautilus_floating_bar_set_primary_label (tab->priv->floating_bar, text);
g_free (text);
@@ -1021,6 +1030,17 @@ on_vim_command_entry_activate (GtkEntry *entry,
gb_editor_vim_execute_command (tab->priv->vim, text);
}
+static void
+on_vim_notify_phrase (GbEditorVim *vim,
+ GParamSpec *pspec,
+ GbEditorTab *tab)
+{
+ g_return_if_fail (GB_IS_EDITOR_VIM (vim));
+ g_return_if_fail (GB_IS_EDITOR_TAB (tab));
+
+ gb_editor_tab_cursor_moved (tab, tab->priv->document);
+}
+
static gboolean
on_vim_command_entry_key_press_event (GtkEntry *entry,
GdkEventKey *event,
@@ -1234,6 +1254,10 @@ gb_editor_tab_constructed (GObject *object)
"command-visibility-toggled",
G_CALLBACK (on_vim_command_visibility_toggled),
tab);
+ g_signal_connect (priv->vim,
+ "notify::phrase",
+ G_CALLBACK (on_vim_notify_phrase),
+ tab);
g_signal_connect (priv->vim_command_entry,
"activate",
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 8b4b515..4844c87 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -352,6 +352,14 @@ gb_editor_vim_get_mode (GbEditorVim *vim)
return vim->priv->mode;
}
+const gchar *
+gb_editor_vim_get_phrase (GbEditorVim *vim)
+{
+ g_return_val_if_fail (GB_IS_EDITOR_VIM (vim), NULL);
+
+ return vim->priv->phrase->str;
+}
+
static void
gb_editor_vim_clear_phrase (GbEditorVim *vim)
{
diff --git a/src/editor/gb-editor-vim.h b/src/editor/gb-editor-vim.h
index b34e8f9..9036e3e 100644
--- a/src/editor/gb-editor-vim.h
+++ b/src/editor/gb-editor-vim.h
@@ -62,6 +62,7 @@ GbEditorVim *gb_editor_vim_new (GtkTextView *text_view);
GbEditorVimMode gb_editor_vim_get_mode (GbEditorVim *vim);
void gb_editor_vim_set_mode (GbEditorVim *vim,
GbEditorVimMode mode);
+const gchar *gb_editor_vim_get_phrase (GbEditorVim *vim);
gboolean gb_editor_vim_get_enabled (GbEditorVim *vim);
void gb_editor_vim_set_enabled (GbEditorVim *vim,
gboolean enabled);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]