154 |
154 |
155 // TODO Check word does not already exist |
155 // TODO Check word does not already exist |
156 cat->words = g_slist_append(cat->words, nword); // TODO sort |
156 cat->words = g_slist_append(cat->words, nword); // TODO sort |
157 } |
157 } |
158 |
158 |
|
159 // compl_del_category_word(categ, command) |
|
160 // Removes a keyword from category categ in completion list. |
|
161 void compl_del_category_word(guint categ, const char *word) |
|
162 { |
|
163 GSList *sl_cat, *sl_elt; |
|
164 category *cat; |
|
165 char *nword; |
|
166 // Look for category |
|
167 for (sl_cat=Categories; sl_cat; sl_cat = g_slist_next(sl_cat)) { |
|
168 if (categ == ((category*)sl_cat->data)->flag) |
|
169 break; |
|
170 } |
|
171 if (!sl_cat) return; // Category not found, finished! |
|
172 |
|
173 cat = (category*)sl_cat->data; |
|
174 |
|
175 // If word is not space-terminated, we add one trailing space |
|
176 for (nword = (char*)word; *nword; nword++) |
|
177 ; |
|
178 if (nword > word) nword--; |
|
179 if (*nword != ' ') { // Add a space |
|
180 nword = g_new(char, strlen(word)+2); |
|
181 strcpy(nword, word); |
|
182 strcat(nword, " "); |
|
183 } else { // word is fine |
|
184 nword = g_strdup(word); |
|
185 } |
|
186 |
|
187 sl_elt = cat->words; |
|
188 while (sl_elt) { |
|
189 if (!strcasecmp((char*)sl_elt->data, nword)) { |
|
190 g_free(sl_elt->data); |
|
191 cat->words = g_slist_delete_link(cat->words, sl_elt); |
|
192 break; // Only remove first occurence |
|
193 } |
|
194 sl_elt = g_slist_next(sl_elt); |
|
195 } |
|
196 } |
|
197 |
159 // compl_get_category_list() |
198 // compl_get_category_list() |
160 // Returns a slist of all words in the categories specified by the given flags |
199 // Returns a slist of all words in the categories specified by the given flags |
161 GSList *compl_get_category_list(guint cat_flags) |
200 GSList *compl_get_category_list(guint cat_flags) |
162 { |
201 { |
163 GSList *sl_cat; |
202 GSList *sl_cat; |