[gnome-builder] snippets: Add decapitalize filter
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] snippets: Add decapitalize filter
- Date: Sun, 28 Aug 2016 18:31:27 +0000 (UTC)
commit 98da01894ba79ae2b6b764dc11a80b36a4b1181f
Author: Philip Chimento <philip endlessm com>
Date: Thu Aug 18 00:44:34 2016 +0200
snippets: Add decapitalize filter
Works like the capitalize filter, but makes the first character
lowercase. Used, for example, for finding the name of JS module files:
const Lang = imports.lang;
https://bugzilla.gnome.org/show_bug.cgi?id=770055
libide/snippets/ide-source-snippet-context.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/libide/snippets/ide-source-snippet-context.c b/libide/snippets/ide-source-snippet-context.c
index 9dee2f9..6083318 100644
--- a/libide/snippets/ide-source-snippet-context.c
+++ b/libide/snippets/ide-source-snippet-context.c
@@ -160,6 +160,25 @@ filter_capitalize (const gchar *input)
}
static gchar *
+filter_decapitalize (const gchar *input)
+{
+ gunichar c;
+ GString *str;
+
+ c = g_utf8_get_char (input);
+
+ if (g_unichar_islower (c))
+ return g_strdup (input);
+
+ str = g_string_new (NULL);
+ input = g_utf8_next_char (input);
+ g_string_append_unichar (str, g_unichar_tolower (c));
+ g_string_append (str, input);
+
+ return g_string_free (str, FALSE);
+}
+
+static gchar *
filter_html (const gchar *input)
{
gunichar c;
@@ -642,6 +661,7 @@ ide_source_snippet_context_class_init (IdeSourceSnippetContextClass *klass)
g_hash_table_insert (filters, (gpointer) "lower", filter_lower);
g_hash_table_insert (filters, (gpointer) "upper", filter_upper);
g_hash_table_insert (filters, (gpointer) "capitalize", filter_capitalize);
+ g_hash_table_insert (filters, (gpointer) "decapitalize", filter_decapitalize);
g_hash_table_insert (filters, (gpointer) "html", filter_html);
g_hash_table_insert (filters, (gpointer) "camelize", filter_camelize);
g_hash_table_insert (filters, (gpointer) "functify", filter_functify);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]