[gnome-builder] sourceview: Add begin-word-completion signal
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] sourceview: Add begin-word-completion signal
- Date: Sat, 2 Sep 2017 01:20:04 +0000 (UTC)
commit 1805ed78d2c1020c78a1a6b9a33db4f7b95a70ac
Author: Umang Jain <mailumangjain gmail com>
Date: Tue Aug 29 21:47:18 2017 +0530
sourceview: Add begin-word-completion signal
https://bugzilla.gnome.org/show_bug.cgi?id=786151
data/keybindings/vim.css | 4 +-
libide/sourceview/ide-source-view.c | 46 +++++++++++++++++++++++++++++++++++
libide/sourceview/ide-source-view.h | 2 +
3 files changed, 50 insertions(+), 2 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index 826bf21..55ec239 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -1900,8 +1900,8 @@
"delete-selection" () };
bind "<ctrl>w" { "movement" (previous-word-start, 1, 1, 0)
"delete-selection" () };
- bind "<ctrl>n" { "cycle-completion" (down) };
- bind "<ctrl>p" { "cycle-completion" (up) };
+ bind "<ctrl>n" { "begin-word-completion" (1) };
+ bind "<ctrl>p" { "begin-word-completion" (-1) };
bind "<ctrl>e" { "movement" (screen-up, 0, 0, 1) };
bind "<ctrl>y" { "movement" (screen-down, 0, 0, 1) };
diff --git a/libide/sourceview/ide-source-view.c b/libide/sourceview/ide-source-view.c
index ed181d1..e03a01d 100644
--- a/libide/sourceview/ide-source-view.c
+++ b/libide/sourceview/ide-source-view.c
@@ -250,6 +250,7 @@ enum {
BEGIN_MACRO,
BEGIN_RENAME,
BEGIN_USER_ACTION,
+ BEGIN_WORD_COMPLETION,
CAPTURE_MODIFIER,
CLEAR_COUNT,
CLEAR_MODIFIER,
@@ -5048,6 +5049,33 @@ ide_source_view_focus_out_event (GtkWidget *widget,
}
static void
+ide_source_view_real_begin_word_completion (IdeSourceView *self,
+ gint direction)
+{
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+ IdeContext *context;
+
+ g_assert (IDE_IS_SOURCE_VIEW (self));
+
+ if ((priv->buffer != NULL) && (context = ide_buffer_get_context (priv->buffer)))
+ {
+ IdeBufferManager *bufmgr;
+ IdeWordCompletionProvider *words;
+ GValue *value;
+
+ bufmgr = ide_context_get_buffer_manager (context);
+ words = ide_buffer_manager_get_word_completion (bufmgr);
+
+ value = g_new0(GValue, 1);
+ g_value_init (value, G_TYPE_INT);
+ g_value_set_int (value, direction);
+ g_object_set_property (G_OBJECT(words), "direction", value);
+
+ g_signal_emit_by_name (self, "show-completion");
+ }
+}
+
+static void
ide_source_view_real_begin_macro (IdeSourceView *self)
{
IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
@@ -6559,6 +6587,7 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
klass->remove_cursors = ide_source_view_real_remove_cursors;
klass->append_to_count = ide_source_view_real_append_to_count;
klass->begin_macro = ide_source_view_real_begin_macro;
+ klass->begin_word_completion = ide_source_view_real_begin_word_completion;
klass->begin_rename = ide_source_view_real_begin_rename;
klass->capture_modifier = ide_source_view_real_capture_modifier;
klass->clear_count = ide_source_view_real_clear_count;
@@ -6836,6 +6865,23 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
G_STRUCT_OFFSET (IdeSourceViewClass, begin_rename),
NULL, NULL, NULL, G_TYPE_NONE, 0);
+ /**
+ * IdeSourceView::begin-word-completion:
+ *
+ * This signal is emitted when the user requests word completion using
+ * Ctrl-n for forward matches and Ctrl-p for backward matches as happens
+ * in Vim.
+ */
+ signals [BEGIN_WORD_COMPLETION] =
+ g_signal_new ("begin-word-completion",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (IdeSourceViewClass, begin_word_completion),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+
signals [BEGIN_USER_ACTION] =
g_signal_new_class_handler ("begin-user-action",
G_TYPE_FROM_CLASS (klass),
diff --git a/libide/sourceview/ide-source-view.h b/libide/sourceview/ide-source-view.h
index 8b66765..c4c95ec 100644
--- a/libide/sourceview/ide-source-view.h
+++ b/libide/sourceview/ide-source-view.h
@@ -223,6 +223,8 @@ struct _IdeSourceViewClass
gint digit);
void (*auto_indent) (IdeSourceView *self);
void (*begin_macro) (IdeSourceView *self);
+ void (*begin_word_completion) (IdeSourceView *self,
+ gint direction);
void (*capture_modifier) (IdeSourceView *self);
void (*clear_count) (IdeSourceView *self);
void (*clear_modifier) (IdeSourceView *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]