comparison 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
comparison
equal deleted inserted replaced
120:cfd3df636d5f 121:94b251102069
133 // Adds a keyword as a possible completion in category categ. 133 // Adds a keyword as a possible completion in category categ.
134 void compl_add_category_word(guint categ, const char *word) 134 void compl_add_category_word(guint categ, const char *word)
135 { 135 {
136 GSList *sl_cat; 136 GSList *sl_cat;
137 category *cat; 137 category *cat;
138 char *nword;
138 // Look for category 139 // Look for category
139 for (sl_cat=Categories; sl_cat; sl_cat = g_slist_next(sl_cat)) { 140 for (sl_cat=Categories; sl_cat; sl_cat = g_slist_next(sl_cat)) {
140 if (categ == ((category*)sl_cat->data)->flag) 141 if (categ == ((category*)sl_cat->data)->flag)
141 break; 142 break;
142 } 143 }
145 cat->flag = categ; 146 cat->flag = categ;
146 Categories = g_slist_append(Categories, cat); 147 Categories = g_slist_append(Categories, cat);
147 } else 148 } else
148 cat = (category*)sl_cat->data; 149 cat = (category*)sl_cat->data;
149 150
151 // If word is not space-terminated, we add one trailing space
152 for (nword = (char*)word; *nword; nword++)
153 ;
154 if (nword > word) nword--;
155 if (*nword != ' ') { // Add a space
156 nword = g_new(char, strlen(word)+2);
157 strcpy(nword, word);
158 strcat(nword, " ");
159 } else { // word is fine
160 nword = g_strdup(word);
161 }
162
150 // TODO Check word does not already exist 163 // TODO Check word does not already exist
151 cat->words = g_slist_append(cat->words, g_strdup(word)); // TODO sort 164 cat->words = g_slist_append(cat->words, nword); // TODO sort
152 } 165 }
153 166
154 // compl_get_category_list() 167 // compl_get_category_list()
155 // Returns a slist of all words in the categories specified by the given flags 168 // Returns a slist of all words in the categories specified by the given flags
156 GSList *compl_get_category_list(guint cat_flags) 169 GSList *compl_get_category_list(guint cat_flags)