diff mcabber/src/compl.c @ 121:94b251102069

[/trunk] Changeset 134 by mikael * Completion: add a space after each completion option... * Completion: does not work when there are several spaces after the command
author mikael
date Tue, 26 Apr 2005 09:36:50 +0000
parents fe7257d251ac
children d5ae42cbe1fa
line wrap: on
line diff
--- a/mcabber/src/compl.c	Mon Apr 25 20:56:23 2005 +0000
+++ b/mcabber/src/compl.c	Tue Apr 26 09:36:50 2005 +0000
@@ -135,6 +135,7 @@
 {
   GSList *sl_cat;
   category *cat;
+  char *nword;
   // Look for category
   for (sl_cat=Categories; sl_cat; sl_cat = g_slist_next(sl_cat)) {
     if (categ == ((category*)sl_cat->data)->flag)
@@ -147,8 +148,20 @@
   } else
     cat = (category*)sl_cat->data;
 
+  // If word is not space-terminated, we add one trailing space
+  for (nword = (char*)word; *nword; nword++)
+    ;
+  if (nword > word) nword--;
+  if (*nword != ' ') {  // Add a space
+    nword = g_new(char, strlen(word)+2);
+    strcpy(nword, word);
+    strcat(nword, " ");
+  } else {              // word is fine
+    nword = g_strdup(word);
+  }
+
   // TODO Check word does not already exist
-  cat->words = g_slist_append(cat->words, g_strdup(word)); // TODO sort
+  cat->words = g_slist_append(cat->words, nword); // TODO sort
 }
 
 //  compl_get_category_list()