SF.net SVN: geany:[4376] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Oct 27 13:06:04 UTC 2009
Revision: 4376
http://geany.svn.sourceforge.net/geany/?rev=4376&view=rev
Author: ntrel
Date: 2009-10-27 13:06:04 +0000 (Tue, 27 Oct 2009)
Log Message:
-----------
Sort document word completion list.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-10-26 22:23:14 UTC (rev 4375)
+++ trunk/ChangeLog 2009-10-27 13:06:04 UTC (rev 4376)
@@ -1,3 +1,9 @@
+2009-10-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/editor.c:
+ Sort document word completion list.
+
+
2009-10-26 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/build.c:
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2009-10-26 22:23:14 UTC (rev 4375)
+++ trunk/src/editor.c 2009-10-27 13:06:04 UTC (rev 4376)
@@ -1776,15 +1776,13 @@
/* Algorithm based on based on Scite's StartAutoCompleteWord() */
-static gboolean autocomplete_doc_word(GeanyEditor *editor, gchar *root, gsize rootlen)
+static GString *get_doc_words(ScintillaObject *sci, gchar *root, gsize rootlen)
{
- ScintillaObject *sci = editor->sci;
gchar *word;
gint len, current, word_end;
gint pos_find, flags;
guint word_length;
gsize nmatches = 0;
- gboolean ret = FALSE;
GString *words;
struct Sci_TextToFind ttf;
@@ -1841,14 +1839,54 @@
{
g_strdelimit(words->str, " ", '\n');
words->str[words->len - 1] = '\0'; /* remove the trailing '\n' */
- show_autocomplete(sci, rootlen, words->str + 1);
- ret = TRUE;
+ return words;
}
- else
+ g_string_free(words, TRUE);
+ return NULL;
+}
+
+
+static gboolean autocomplete_doc_word(GeanyEditor *editor, gchar *root, gsize rootlen)
+{
+ ScintillaObject *sci = editor->sci;
+ GString *words;
+ GString *str;
+ gchar *ptr;
+ GSList *node, *list = NULL;
+
+ words = get_doc_words(sci, root, rootlen);
+ if (!words)
+ {
scintilla_send_message(sci, SCI_AUTOCCANCEL, 0, 0);
+ return FALSE;
+ }
+ /* words are unsorted, make list of words */
+ foreach_str(ptr, words->str)
+ {
+ if (*ptr == '\n')
+ {
+ list = g_slist_prepend(list, ptr + 1);
+ /* terminate previous string in list */
+ ptr[0] = 0x0;
+ ptr++;
+ }
+ }
+ list = g_slist_sort(list, (GCompareFunc)utils_str_casecmp);
+
+ str = g_string_sized_new(256);
+ foreach_slist(node, list)
+ {
+ g_string_append(str, node->data);
+ if (node->next)
+ g_string_append_c(str, '\n');
+ }
+ g_slist_free(list);
g_string_free(words, TRUE);
- return ret;
+
+ show_autocomplete(sci, rootlen, str->str);
+ g_string_free(str, TRUE);
+ return TRUE;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list