[gnome-builder] vim: move vim code into src/vim
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vim: move vim code into src/vim
- Date: Sat, 18 Oct 2014 00:20:32 +0000 (UTC)
commit a1e1e3762984a318f28ba273c856a3273fff3aa6
Author: Christian Hergert <christian hergert me>
Date: Fri Oct 17 17:15:27 2014 -0700
vim: move vim code into src/vim
src/commands/gb-command-vim-provider.c | 2 +-
src/commands/gb-command-vim.c | 13 ++++---
src/editor/gb-editor-tab-private.h | 6 ---
src/editor/gb-editor-tab.c | 35 ++++++-------------
src/editor/gb-source-view.c | 16 +++++++++
src/editor/gb-source-view.h | 2 +
src/gnome-builder.mk | 5 ++-
.../gb-editor-vim.c => vim/gb-source-vim.c} | 2 +-
.../gb-editor-vim.h => vim/gb-source-vim.h} | 0
9 files changed, 42 insertions(+), 39 deletions(-)
---
diff --git a/src/commands/gb-command-vim-provider.c b/src/commands/gb-command-vim-provider.c
index 67e2b2d..bae523e 100644
--- a/src/commands/gb-command-vim-provider.c
+++ b/src/commands/gb-command-vim-provider.c
@@ -21,7 +21,7 @@
#include "gb-command-vim.h"
#include "gb-command-vim-provider.h"
#include "gb-editor-tab.h"
-#include "gb-editor-vim.h"
+#include "gb-source-vim.h"
G_DEFINE_TYPE (GbCommandVimProvider, gb_command_vim_provider,
GB_TYPE_COMMAND_PROVIDER)
diff --git a/src/commands/gb-command-vim.c b/src/commands/gb-command-vim.c
index e9b890c..8d34c3d 100644
--- a/src/commands/gb-command-vim.c
+++ b/src/commands/gb-command-vim.c
@@ -21,6 +21,7 @@
#include "gb-command-vim.h"
#include "gb-editor-tab.h"
#include "gb-editor-tab-private.h"
+#include "gb-source-vim.h"
struct _GbCommandVimPrivate
{
@@ -101,14 +102,16 @@ gb_command_vim_set_command_text (GbCommandVim *vim,
static GbCommandResult *
gb_command_vim_execute (GbCommand *command)
{
- GbCommandVim *vim = (GbCommandVim *)command;
+ GbCommandVim *self = (GbCommandVim *)command;
- g_return_val_if_fail (GB_IS_COMMAND_VIM (vim), NULL);
+ g_return_val_if_fail (GB_IS_COMMAND_VIM (self), NULL);
- if (vim->priv->tab && vim->priv->command_text)
+ if (self->priv->tab && self->priv->command_text)
{
- gb_editor_vim_execute_command (vim->priv->tab->priv->vim,
- vim->priv->command_text);
+ GbEditorVim *vim;
+
+ vim = gb_source_view_get_vim (self->priv->tab->priv->source_view);
+ gb_editor_vim_execute_command (vim, self->priv->command_text);
}
return NULL;
diff --git a/src/editor/gb-editor-tab-private.h b/src/editor/gb-editor-tab-private.h
index fba8d66..2854b3e 100644
--- a/src/editor/gb-editor-tab-private.h
+++ b/src/editor/gb-editor-tab-private.h
@@ -26,7 +26,6 @@
#include "gb-box-theatric.h"
#include "gb-editor-document.h"
#include "gb-editor-settings.h"
-#include "gb-editor-vim.h"
#include "gb-markdown-preview.h"
#include "gb-notebook.h"
#include "gb-source-change-monitor.h"
@@ -68,11 +67,6 @@ struct _GbEditorTabPrivate
GbEditorSettings *settings;
/*
- * VIM mode helper.
- */
- GbEditorVim *vim;
-
- /*
* Weak reference bindings for tracking settings.
*/
GBinding *auto_indent_binding;
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index fac8e0a..ffedb90 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -397,9 +397,10 @@ gb_editor_tab_cursor_moved (GbEditorTab *tab,
{
GtkSourceView *source_view;
GtkTextBuffer *buffer;
+ GbEditorVim *vim;
GtkTextIter iter;
GtkTextMark *mark;
- const gchar *phrase = NULL;
+ const gchar *phrase;
gchar *text;
guint ln;
guint col;
@@ -416,8 +417,8 @@ gb_editor_tab_cursor_moved (GbEditorTab *tab,
ln = gtk_text_iter_get_line (&iter);
col = gtk_source_view_get_visual_column (source_view, &iter);
- if (tab->priv->vim)
- phrase = gb_editor_vim_get_phrase (tab->priv->vim);
+ vim = gb_source_view_get_vim (tab->priv->source_view);
+ phrase = gb_editor_vim_get_phrase (vim);
if (!gb_str_empty0 (phrase))
text = g_strdup_printf (_("%s\tLine %u, Column %u"),
@@ -1108,9 +1109,9 @@ gb_editor_tab_constructed (GObject *object)
GtkSourceCompletion *comp;
GbEditorTabPrivate *priv;
GbEditorTab *tab = (GbEditorTab *) object;
+ GbEditorVim *vim;
GtkSourceGutter *gutter;
GSettings *settings;
- gboolean vim_enabled;
ENTRY;
@@ -1133,21 +1134,6 @@ gb_editor_tab_constructed (GObject *object)
priv->document, "style-scheme-name",
G_SETTINGS_BIND_GET);
- /*
- * WORKAROUND:
- *
- * We need to connect VIM in the proper mode as early as possible
- * so that our key-press-event signal is connected before the
- * GtkSourceCompletion connects to key-press-event of the GtkSourceView.
- * Otherwise, Escape when in insert mode may only hide the completion
- * window and not escape us back into VIM normal mode as VIM would.
- */
- vim_enabled = g_settings_get_boolean (settings, "vim-mode");
- priv->vim = g_object_new (GB_TYPE_EDITOR_VIM,
- "enabled", vim_enabled,
- "text-view", priv->source_view,
- NULL);
-
if (!priv->settings)
gb_editor_tab_set_settings (tab, NULL);
@@ -1287,24 +1273,25 @@ gb_editor_tab_constructed (GObject *object)
NULL);
gtk_source_gutter_insert (gutter, priv->change_renderer, 0);
- g_signal_connect (priv->vim,
+ vim = gb_source_view_get_vim (priv->source_view);
+ g_signal_connect (vim,
"command-visibility-toggled",
G_CALLBACK (on_vim_command_visibility_toggled),
tab);
- g_signal_connect (priv->vim,
+ g_signal_connect (vim,
"begin-search",
G_CALLBACK (on_vim_begin_search),
tab);
- g_signal_connect (priv->vim,
+ g_signal_connect (vim,
"notify::phrase",
G_CALLBACK (on_vim_notify_phrase),
tab);
- g_signal_connect (priv->vim,
+ g_signal_connect (vim,
"notify::mode",
G_CALLBACK (on_vim_notify_mode),
tab);
- g_settings_bind (settings, "vim-mode", priv->vim, "enabled",
+ g_settings_bind (settings, "vim-mode", vim, "enabled",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (settings, "word-completion", tab, "enable-word-completion",
G_SETTINGS_BIND_DEFAULT);
diff --git a/src/editor/gb-source-view.c b/src/editor/gb-source-view.c
index e53f45a..a412af5 100644
--- a/src/editor/gb-source-view.c
+++ b/src/editor/gb-source-view.c
@@ -37,6 +37,7 @@
#include "gb-source-snippet-context.h"
#include "gb-source-snippet-private.h"
#include "gb-source-view.h"
+#include "gb-source-vim.h"
#include "gb-widget.h"
struct _GbSourceViewPrivate
@@ -46,6 +47,7 @@ struct _GbSourceViewPrivate
GtkTextBuffer *buffer;
GbSourceAutoIndenter *auto_indenter;
GtkSourceCompletionProvider *snippets_provider;
+ GbEditorVim *vim;
guint buffer_insert_text_handler;
guint buffer_insert_text_after_handler;
@@ -84,6 +86,14 @@ enum {
static GParamSpec *gParamSpecs [LAST_PROP];
static guint gSignals [LAST_SIGNAL];
+GbEditorVim *
+gb_source_view_get_vim (GbSourceView *view)
+{
+ g_return_val_if_fail (GB_IS_SOURCE_VIEW (view), NULL);
+
+ return view->priv->vim;
+}
+
void
gb_source_view_begin_search (GbSourceView *view,
GtkDirectionType direction,
@@ -1415,6 +1425,7 @@ gb_source_view_finalize (GObject *object)
g_clear_object (&priv->search_highlighter);
g_clear_object (&priv->auto_indenter);
g_clear_object (&priv->snippets_provider);
+ g_clear_object (&priv->vim);
G_OBJECT_CLASS (gb_source_view_parent_class)->finalize (object);
}
@@ -1581,4 +1592,9 @@ gb_source_view_init (GbSourceView *view)
g_object_new (GB_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER,
"source-view", view,
NULL);
+
+ view->priv->vim = g_object_new (GB_TYPE_EDITOR_VIM,
+ "enabled", FALSE,
+ "text-view", view,
+ NULL);
}
diff --git a/src/editor/gb-source-view.h b/src/editor/gb-source-view.h
index 6c66db1..7945592 100644
--- a/src/editor/gb-source-view.h
+++ b/src/editor/gb-source-view.h
@@ -23,6 +23,7 @@
#include "gb-source-auto-indenter.h"
#include "gb-source-snippet.h"
+#include "gb-source-vim.h"
G_BEGIN_DECLS
@@ -76,6 +77,7 @@ void gb_source_view_set_font_name (GbSourceView *v
void gb_source_view_set_show_shadow (GbSourceView *view,
gboolean show_shadow);
void gb_source_view_unindent_selection (GbSourceView *view);
+GbEditorVim *gb_source_view_get_vim (GbSourceView *view);
G_END_DECLS
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 36aa68f..d4fb945 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -58,8 +58,6 @@ libgnome_builder_la_SOURCES = \
src/editor/gb-editor-tab.c \
src/editor/gb-editor-tab.h \
src/editor/gb-editor-tab-private.h \
- src/editor/gb-editor-vim.c \
- src/editor/gb-editor-vim.h \
src/editor/gb-editor-workspace.c \
src/editor/gb-editor-workspace.h \
src/editor/gb-editor-workspace-private.h \
@@ -150,6 +148,8 @@ libgnome_builder_la_SOURCES = \
src/util/gb-string.h \
src/util/gb-widget.c \
src/util/gb-widget.h \
+ src/vim/gb-source-vim.c \
+ src/vim/gb-source-vim.h \
src/workbench/gb-workbench.c \
src/workbench/gb-workbench.h \
src/workbench/gb-workbench-actions.c \
@@ -196,6 +196,7 @@ libgnome_builder_la_CFLAGS = \
-I$(top_srcdir)/src/trie \
-I$(top_srcdir)/src/theatrics \
-I$(top_srcdir)/src/util \
+ -I$(top_srcdir)/src/vim \
-I$(top_srcdir)/src/workbench
if ENABLE_TRACING
diff --git a/src/editor/gb-editor-vim.c b/src/vim/gb-source-vim.c
similarity index 99%
rename from src/editor/gb-editor-vim.c
rename to src/vim/gb-source-vim.c
index 8172ec7..f9f1ef3 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/vim/gb-source-vim.c
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "gb-editor-vim.h"
+#include "gb-source-vim.h"
#ifndef GB_EDITOR_VIM_EXTERNAL
# include "gb-source-view.h"
diff --git a/src/editor/gb-editor-vim.h b/src/vim/gb-source-vim.h
similarity index 100%
rename from src/editor/gb-editor-vim.h
rename to src/vim/gb-source-vim.h
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]