changeset 1926:c1f9a4d47e05

Add option 'completion_ignore_case' By default completion is now case sensitive. (Partially fixes issue #48)
author Mikael Berthe <mikael@lilotux.net>
date Thu, 11 Nov 2010 14:13:16 +0100
parents 3655f52687f0
children 3e3e73bb43f5
files mcabber/mcabber/compl.c mcabber/mcabberrc.example
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/compl.c	Wed Nov 10 17:36:26 2010 +0100
+++ b/mcabber/mcabber/compl.c	Thu Nov 11 14:13:16 2010 +0100
@@ -36,6 +36,7 @@
 #include "utf8.h"
 #include "roster.h"
 #include "events.h"
+#include "settings.h"
 #include "logprint.h"
 
 // Completion structure
@@ -135,17 +136,23 @@
 {
   compl *c;
   GSList *sl_cat;
+  gint (*cmp)(const char *s1, const char *s2, size_t n);
   size_t len = strlen(prefix);
 
   if (InputCompl) { // This should not happen, but hey...
     cancel_completion();
   }
 
+  if (settings_opt_get_int("completion_ignore_case"))
+    cmp = &strncasecmp;
+  else
+    cmp = &strncmp;
+
   c = g_new0(compl, 1);
   // Build the list of matches
   for (sl_cat = compl_cat; sl_cat; sl_cat = g_slist_next(sl_cat)) {
     char *word = sl_cat->data;
-    if (!strncasecmp(prefix, word, len)) {
+    if (!cmp(prefix, word, len)) {
       if (strlen(word) != len) {
         gchar *compval;
         if (suffix)
--- a/mcabber/mcabberrc.example	Wed Nov 10 17:36:26 2010 +0100
+++ b/mcabber/mcabberrc.example	Thu Nov 11 14:13:16 2010 +0100
@@ -126,6 +126,10 @@
 # running you can use "/roster display").
 #set roster_display_filter = ofdna_
 
+# By default command line completion is case-sensitive; this can be changed
+# by setting the option 'completion_ignore_case' to 1.
+#set completion_ignore_case = 0
+
 # Typing notifications, Chat States, Events (XEP-22/85)
 # Set disable_chatstates to 1 if you don't want to use typing notifications.
 # Note: changing this option once mcabber is running has no effect.