[gtksourceview/wip/chergert/snippets: 4/4] snippets: (TEST ONLY) expand current word into snippet
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/snippets: 4/4] snippets: (TEST ONLY) expand current word into snippet
- Date: Mon, 27 Jan 2020 22:38:39 +0000 (UTC)
commit a1a45a1b562aa71cc7bfc0d3f26044e1ac8201a3
Author: Christian Hergert <chergert redhat com>
Date: Sat Jan 25 08:41:20 2020 -0800
snippets: (TEST ONLY) expand current word into snippet
This is just for testing the snippet engine with a particularly difficult
test case (neighboring interactive/linked snippets). It should not be
merged, but replaced with snippet manager integration.
gtksourceview/gtksourceview-snippets.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/gtksourceview-snippets.c b/gtksourceview/gtksourceview-snippets.c
index 07cd5b97..5004f793 100644
--- a/gtksourceview/gtksourceview-snippets.c
+++ b/gtksourceview/gtksourceview-snippets.c
@@ -308,7 +308,30 @@ lookup_snippet_by_trigger (GtkSourceViewSnippets *snippets,
const gchar *word)
{
/* TODO: integrate with snippet manager */
- return NULL;
+ GtkSourceSnippetChunk *chunk;
+ GtkSourceSnippet *snippet;
+
+ g_assert (snippets != NULL);
+ g_assert (word != NULL);
+
+ snippet = gtk_source_snippet_new (word, NULL);
+
+ for (guint i = 0; i < 3; i++)
+ {
+ chunk = gtk_source_snippet_chunk_new ();
+ if (i == 0)
+ gtk_source_snippet_chunk_set_spec (chunk, word);
+ else
+ gtk_source_snippet_chunk_set_spec (chunk, "$1");
+ gtk_source_snippet_chunk_set_focus_position (chunk, i+1);
+ gtk_source_snippet_add_chunk (snippet, chunk);
+ }
+
+ chunk = gtk_source_snippet_chunk_new ();
+ gtk_source_snippet_chunk_set_focus_position (chunk, 0);
+ gtk_source_snippet_add_chunk (snippet, chunk);
+
+ return snippet;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]