--- a/completion-sorting.diff Thu Oct 18 21:54:26 2012 +0300
+++ b/completion-sorting.diff Sat Oct 20 18:29:49 2012 +0300
@@ -1,5 +1,5 @@
# HG changeset patch
-# Parent c6fafa6e6be9e56ad327450b2d7f01f2a8505a5e
+# Parent 88836b149cfab6e695f70b3c7e52fe8b99b09900
Make completion sorting order configurable
* Use allocated plain array for categories
@@ -7,9 +7,9 @@
* Add compl_set_flags() to allow user to set completion order
* Bump api to 24-24
-diff -r c6fafa6e6be9 mcabber/ChangeLog.api
---- a/mcabber/ChangeLog.api Thu Oct 18 21:48:25 2012 +0300
-+++ b/mcabber/ChangeLog.api Thu Oct 18 21:48:47 2012 +0300
+diff -r 88836b149cfa mcabber/ChangeLog.api
+--- a/mcabber/ChangeLog.api Sat Oct 20 18:02:25 2012 +0300
++++ b/mcabber/ChangeLog.api Sat Oct 20 18:27:46 2012 +0300
@@ -1,3 +1,10 @@
+dev (24)
+ * MQ patch completion-sorting.diff
@@ -21,9 +21,9 @@
dev (23)
* Changeset 8dc418af3e72
Add buddy_(get|set)activeresource() functions
-diff -r c6fafa6e6be9 mcabber/mcabber/api.h
---- a/mcabber/mcabber/api.h Thu Oct 18 21:48:25 2012 +0300
-+++ b/mcabber/mcabber/api.h Thu Oct 18 21:48:47 2012 +0300
+diff -r 88836b149cfa mcabber/mcabber/api.h
+--- a/mcabber/mcabber/api.h Sat Oct 20 18:02:25 2012 +0300
++++ b/mcabber/mcabber/api.h Sat Oct 20 18:27:46 2012 +0300
@@ -4,12 +4,15 @@
#include <glib.h>
#include <mcabber/config.h> // For MCABBER_BRANCH
@@ -42,9 +42,9 @@
extern const gchar *mcabber_branch;
extern const guint mcabber_api_version;
-diff -r c6fafa6e6be9 mcabber/mcabber/compl.c
---- a/mcabber/mcabber/compl.c Thu Oct 18 21:48:25 2012 +0300
-+++ b/mcabber/mcabber/compl.c Thu Oct 18 21:48:47 2012 +0300
+diff -r 88836b149cfa mcabber/mcabber/compl.c
+--- a/mcabber/mcabber/compl.c Sat Oct 20 18:02:25 2012 +0300
++++ b/mcabber/mcabber/compl.c Sat Oct 20 18:27:46 2012 +0300
@@ -2,7 +2,7 @@
* compl.c -- Completion system
*
@@ -54,7 +54,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
-@@ -47,82 +47,148 @@
+@@ -47,82 +47,150 @@
GSList *next; // pointer to next completion to try
} compl;
@@ -110,7 +110,7 @@
+ compl = g_slist_append(compl, g_strdup("list"));
+ return compl;
+}
-+
++
+static inline void register_builtin_cat(guint c, compl_handler_t dynamic) {
+ Categories[c-1].flags = COMPL_CAT_BUILTIN | COMPL_CAT_ACTIVE;
+ Categories[c-1].words = NULL;
@@ -122,12 +122,11 @@
void compl_init_system(void)
{
++ num_categories = COMPL_MAX_ID;
+#ifdef MODULES_ENABLE
-+ num_categories = 64; // XXX
-+#else
-+ num_categories = COMPL_MODULE;
++ num_categories = ((num_categories / 16) + 1) * 16;
+#endif
-+ Categories = g_new(category, num_categories);
++ Categories = g_new0(category, num_categories);
+
// Builtin completion categories:
- register_builtin_cat(COMPL_CMD);
@@ -188,7 +187,7 @@
+guint compl_new_category(guint flags)
{
- const guint maxcat = 8 * sizeof (registered_cats);
- guint i = 0;
+- guint i = 0;
- while ((registered_cats >> i) & 1 && i < maxcat)
- i++;
- if (i >= maxcat)
@@ -197,10 +196,12 @@
- guint64 id = 1 << i;
- registered_cats |= id;
- return i+1;
-+ for (; i < num_categories; i++)
++ guint i;
++ for (i = 0; i < num_categories; i++)
+ if (!(Categories[i].flags & COMPL_CAT_ACTIVE))
+ break;
+ if (i >= num_categories ) {
++ guint j;
+ if (num_categories > G_MAXUINT - 16) {
+ scr_log_print(LPRINT_LOGNORM, "Warning: Too many "
+ "completion categories!");
@@ -208,6 +209,8 @@
+ }
+ num_categories += 16;
+ Categories = g_renew(category, Categories, num_categories);
++ for (j = i+1; j < num_categories; j++)
++ Categories[j].flags = 0;
}
+ Categories[i].flags = COMPL_CAT_ACTIVE | (flags & COMPL_CAT_USERFLAGS);
+ Categories[i].words = NULL;
@@ -228,7 +231,7 @@
+
+ if (!compl) {
+ scr_log_print(LPRINT_DEBUG, "Error: compl_del_category() - "
-+ "Invalid category.");
++ "Invalid category (0).");
return;
}
- id--;
@@ -250,7 +253,7 @@
}
#endif
-@@ -136,12 +202,15 @@
+@@ -136,12 +204,15 @@
guint new_completion(const char *prefix, GSList *compl_cat, const gchar *suffix)
{
compl *c;
@@ -261,13 +264,13 @@
if (InputCompl) { // This should not happen, but hey...
- cancel_completion();
-+ scr_log_print(LPRINT_DEBUG, "Warinng: new_completion() - "
++ scr_log_print(LPRINT_DEBUG, "Warning: new_completion() - "
+ "Previous completion exists!");
+ done_completion();
}
if (settings_opt_get_int("completion_ignore_case"))
-@@ -160,14 +229,15 @@
+@@ -160,14 +231,15 @@
compval = g_strdup_printf("%s%s", word+len, suffix);
else
compval = g_strdup(word+len);
@@ -287,7 +290,7 @@
}
// done_completion();
-@@ -222,35 +292,46 @@
+@@ -222,35 +294,46 @@
/* Categories functions */
@@ -322,24 +325,23 @@
if (!categ) {
- scr_log_print(LPRINT_LOGNORM, "Error: compl_add_category_word() - "
+- "Invalid category.");
+ scr_log_print(LPRINT_DEBUG, "Error: compl_add_category_word() - "
- "Invalid category.");
++ "Invalid category (0).");
return;
}
--
-+
+
categ--;
- catv = 1UL << categ;
--
+
- // Look for category
- for (sl_cat=Categories; sl_cat; sl_cat = g_slist_next(sl_cat)) {
- if (catv == ((category*)sl_cat->data)->flag)
- break;
-+
+ if ((categ >= num_categories) ||
+ !(Categories[categ].flags & COMPL_CAT_ACTIVE)) {
+ scr_log_print(LPRINT_DEBUG, "Error: compl_add_category_word() - "
-+ "Not existing category.");
++ "Category does not exist.");
+ return;
}
- if (!sl_cat) { // Category not found, let's create it
@@ -351,7 +353,7 @@
// If word is not space-terminated, we add one trailing space
for (nword = (char*)word; *nword; nword++)
-@@ -262,59 +343,64 @@
+@@ -262,59 +345,64 @@
nword = g_strdup(word);
}
@@ -388,8 +390,9 @@
if (!categ) {
- scr_log_print(LPRINT_LOGNORM, "Error: compl_del_category_word() - "
+- "Invalid category.");
+ scr_log_print(LPRINT_DEBUG, "Error: compl_del_category_word() - "
- "Invalid category.");
++ "Invalid category (0).");
return;
}
@@ -403,7 +406,7 @@
+ if ((categ >= num_categories) ||
+ !(Categories[categ].flags & COMPL_CAT_ACTIVE)) {
+ scr_log_print(LPRINT_DEBUG, "Error: compl_del_category_word() - "
-+ "Not existing category.");
++ "Category does not exist.");
+ return;
}
- if (!sl_cat) return; // Category not found, finished!
@@ -445,7 +448,7 @@
}
// compl_get_category_list()
-@@ -323,48 +409,28 @@
+@@ -323,48 +411,28 @@
// whole list after use.
GSList *compl_get_category_list(guint categ, guint *dynlist)
{
@@ -454,8 +457,9 @@
-
if (!categ) {
- scr_log_print(LPRINT_LOGNORM, "Error: compl_get_category_list() - "
+- "Invalid category.");
+ scr_log_print(LPRINT_DEBUG, "Error: compl_get_category_list() - "
- "Invalid category.");
++ "Invalid category (0).");
return NULL;
}
@@ -492,7 +496,7 @@
+ if ((categ > num_categories) ||
+ !(Categories[categ].flags & COMPL_CAT_ACTIVE)) {
+ scr_log_print(LPRINT_DEBUG, "Error: compl_get_category_list() - "
-+ "Not existing category.");
++ "Category does not exist.");
+ return NULL;
}
@@ -508,15 +512,18 @@
}
/* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2: For Vim users... */
-diff -r c6fafa6e6be9 mcabber/mcabber/compl.h
---- a/mcabber/mcabber/compl.h Thu Oct 18 21:48:25 2012 +0300
-+++ b/mcabber/mcabber/compl.h Thu Oct 18 21:48:47 2012 +0300
-@@ -28,9 +28,15 @@
+diff -r 88836b149cfa mcabber/mcabber/compl.h
+--- a/mcabber/mcabber/compl.h Sat Oct 20 18:02:25 2012 +0300
++++ b/mcabber/mcabber/compl.h Sat Oct 20 18:27:46 2012 +0300
+@@ -27,10 +27,18 @@
+ #define COMPL_OTR 20
#define COMPL_OTRPOLICY 21
#define COMPL_MODULE 22
-
++/* private */
++#define COMPL_MAX_ID 22
++
+void compl_init_system(void); /* private */
-+
+
#ifdef MODULES_ENABLE
-void compl_init_system(void);
-guint compl_new_category(void);
@@ -529,9 +536,9 @@
void compl_del_category(guint id);
#endif
-diff -r c6fafa6e6be9 mcabber/mcabber/main.c
---- a/mcabber/mcabber/main.c Thu Oct 18 21:48:25 2012 +0300
-+++ b/mcabber/mcabber/main.c Thu Oct 18 21:48:47 2012 +0300
+diff -r 88836b149cfa mcabber/mcabber/main.c
+--- a/mcabber/mcabber/main.c Sat Oct 20 18:02:25 2012 +0300
++++ b/mcabber/mcabber/main.c Sat Oct 20 18:27:46 2012 +0300
@@ -364,13 +364,13 @@
}
@@ -547,9 +554,9 @@
modules_init();
#endif
/* Initialize charset */
-diff -r c6fafa6e6be9 mcabber/modules/beep/beep.c
---- a/mcabber/modules/beep/beep.c Thu Oct 18 21:48:25 2012 +0300
-+++ b/mcabber/modules/beep/beep.c Thu Oct 18 21:48:47 2012 +0300
+diff -r 88836b149cfa mcabber/modules/beep/beep.c
+--- a/mcabber/modules/beep/beep.c Sat Oct 20 18:02:25 2012 +0300
++++ b/mcabber/modules/beep/beep.c Sat Oct 20 18:27:46 2012 +0300
@@ -89,7 +89,7 @@
static void beep_init(void)
{