Mercurial > pidgin.yaz
comparison plugins/spellchk.c @ 1081:efcacae6acdb
[gaim-migrate @ 1091]
libfaim connects non-blocking
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 10 Nov 2000 22:49:02 +0000 |
parents | ece2d1543b20 |
children | 72a30a73f689 |
comparison
equal
deleted
inserted
replaced
1080:e6637ff33957 | 1081:efcacae6acdb |
---|---|
24 char *good; | 24 char *good; |
25 }; | 25 }; |
26 | 26 |
27 GList *words = NULL; | 27 GList *words = NULL; |
28 | 28 |
29 int num_words(char *); | 29 static int num_words(char *); |
30 int get_word(char *, int); | 30 static int get_word(char *, int); |
31 char *have_word(char *, int); | 31 static char *have_word(char *, int); |
32 void substitute(char **, int, int, char *); | 32 static void substitute(char **, int, int, char *); |
33 | 33 |
34 void substitute_words(struct gaim_connection *gc, char *who, char **message, void *m) { | 34 static void substitute_words(struct gaim_connection *gc, char *who, char **message, void *m) { |
35 int i, l; | 35 int i, l; |
36 int word; | 36 int word; |
37 GList *w; | 37 GList *w; |
38 char *tmp; | 38 char *tmp; |
39 | 39 |
58 w = w->next; | 58 w = w->next; |
59 } | 59 } |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 int buf_get_line(char *ibuf, char **buf, int *position, int len) { | 63 static int buf_get_line(char *ibuf, char **buf, int *position, int len) { |
64 int pos = *position, spos = pos; | 64 int pos = *position, spos = pos; |
65 | 65 |
66 if (pos == len) | 66 if (pos == len) |
67 return 0; | 67 return 0; |
68 | 68 |
76 pos++; | 76 pos++; |
77 *position = pos; | 77 *position = pos; |
78 return 1; | 78 return 1; |
79 } | 79 } |
80 | 80 |
81 void load_conf() { | 81 static void load_conf() { |
82 char *defaultconf = "BAD r\nGOOD are\n\n" | 82 char *defaultconf = "BAD r\nGOOD are\n\n" |
83 "BAD u\nGOOD you\n\n" | 83 "BAD u\nGOOD you\n\n" |
84 "BAD teh\nGOOD the\n\n"; | 84 "BAD teh\nGOOD the\n\n"; |
85 char *buf, *ibuf; | 85 char *buf, *ibuf; |
86 char name[82]; | 86 char name[82]; |
153 | 153 |
154 char *description() { | 154 char *description() { |
155 return "Watches outgoing IM text and corrects common spelling errors."; | 155 return "Watches outgoing IM text and corrects common spelling errors."; |
156 } | 156 } |
157 | 157 |
158 int num_words(char *m) { | 158 static int num_words(char *m) { |
159 int count = 0; | 159 int count = 0; |
160 int pos; | 160 int pos; |
161 int state = 0; | 161 int state = 0; |
162 | 162 |
163 for (pos = 0; pos < strlen(m); pos++) { | 163 for (pos = 0; pos < strlen(m); pos++) { |
182 } | 182 } |
183 } | 183 } |
184 return count; | 184 return count; |
185 } | 185 } |
186 | 186 |
187 int get_word(char *m, int word) { | 187 static int get_word(char *m, int word) { |
188 int count = 0; | 188 int count = 0; |
189 int pos = 0; | 189 int pos = 0; |
190 int state = 0; | 190 int state = 0; |
191 | 191 |
192 for (pos = 0; pos < strlen(m) && count <= word; pos++) { | 192 for (pos = 0; pos < strlen(m) && count <= word; pos++) { |
211 } | 211 } |
212 } | 212 } |
213 return pos - 1; | 213 return pos - 1; |
214 } | 214 } |
215 | 215 |
216 char *have_word(char *m, int pos) { | 216 static char *have_word(char *m, int pos) { |
217 char *tmp = strpbrk(&m[pos], "' \t\f\r\n\".?!-,"); | 217 char *tmp = strpbrk(&m[pos], "' \t\f\r\n\".?!-,"); |
218 int len = (int)(tmp - &m[pos]); | 218 int len = (int)(tmp - &m[pos]); |
219 | 219 |
220 if (tmp == NULL) { | 220 if (tmp == NULL) { |
221 tmp = strdup(&m[pos]); | 221 tmp = strdup(&m[pos]); |
227 strncat(tmp, &m[pos], len); | 227 strncat(tmp, &m[pos], len); |
228 | 228 |
229 return tmp; | 229 return tmp; |
230 } | 230 } |
231 | 231 |
232 void substitute(char **mes, int pos, int m, char *text) { | 232 static void substitute(char **mes, int pos, int m, char *text) { |
233 char *new = g_malloc(strlen(*mes) + strlen(text) + 1); | 233 char *new = g_malloc(strlen(*mes) + strlen(text) + 1); |
234 char *tmp; | 234 char *tmp; |
235 new[0] = 0; | 235 new[0] = 0; |
236 | 236 |
237 strncat(new, *mes, pos); | 237 strncat(new, *mes, pos); |
241 tmp = *mes; | 241 tmp = *mes; |
242 *mes = new; | 242 *mes = new; |
243 g_free(tmp); | 243 g_free(tmp); |
244 } | 244 } |
245 | 245 |
246 GtkWidget *configwin = NULL; | 246 static GtkWidget *configwin = NULL; |
247 GtkWidget *list; | 247 static GtkWidget *list; |
248 GtkWidget *bad_entry; | 248 static GtkWidget *bad_entry; |
249 GtkWidget *good_entry; | 249 static GtkWidget *good_entry; |
250 | 250 |
251 void row_unselect() { | 251 static void row_unselect() { |
252 gtk_entry_set_text(GTK_ENTRY(bad_entry), ""); | 252 gtk_entry_set_text(GTK_ENTRY(bad_entry), ""); |
253 gtk_entry_set_text(GTK_ENTRY(good_entry), ""); | 253 gtk_entry_set_text(GTK_ENTRY(good_entry), ""); |
254 } | 254 } |
255 | 255 |
256 void row_select() { | 256 static void row_select() { |
257 char *badwrd, *goodwrd; | 257 char *badwrd, *goodwrd; |
258 int row; | 258 int row; |
259 | 259 |
260 if (GTK_CLIST(list)->selection) | 260 if (GTK_CLIST(list)->selection) |
261 row = (int) GTK_CLIST (list)->selection->data; | 261 row = (int) GTK_CLIST (list)->selection->data; |
269 } else { | 269 } else { |
270 row_unselect(); | 270 row_unselect(); |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 void list_add_new() { | 274 static void list_add_new() { |
275 int i; | 275 int i; |
276 gchar *item[2] = {"*NEW*", "EDIT ME"}; | 276 gchar *item[2] = {"*NEW*", "EDIT ME"}; |
277 | 277 |
278 i = gtk_clist_append(GTK_CLIST(list), item); | 278 i = gtk_clist_append(GTK_CLIST(list), item); |
279 gtk_clist_select_row(GTK_CLIST(list), i, 0); | 279 gtk_clist_select_row(GTK_CLIST(list), i, 0); |
280 gtk_clist_moveto(GTK_CLIST(list), i, 0, 0.5, 0); | 280 gtk_clist_moveto(GTK_CLIST(list), i, 0, 0.5, 0); |
281 } | 281 } |
282 | 282 |
283 void list_delete() { | 283 static void list_delete() { |
284 int row; | 284 int row; |
285 | 285 |
286 if (GTK_CLIST(list)->selection) | 286 if (GTK_CLIST(list)->selection) |
287 row = (int) GTK_CLIST (list)->selection->data; | 287 row = (int) GTK_CLIST (list)->selection->data; |
288 else | 288 else |
291 gtk_clist_unselect_all(GTK_CLIST(list)); | 291 gtk_clist_unselect_all(GTK_CLIST(list)); |
292 gtk_clist_remove(GTK_CLIST(list), row); | 292 gtk_clist_remove(GTK_CLIST(list), row); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 void close_config() { | 296 static void close_config() { |
297 if (configwin) | 297 if (configwin) |
298 gtk_widget_destroy(configwin); | 298 gtk_widget_destroy(configwin); |
299 configwin = NULL; | 299 configwin = NULL; |
300 } | 300 } |
301 | 301 |
302 void save_list() { | 302 static void save_list() { |
303 int fh, i = 0; | 303 int fh, i = 0; |
304 char buf[512]; | 304 char buf[512]; |
305 char *a, *b; | 305 char *a, *b; |
306 | 306 |
307 snprintf(buf, sizeof buf, "%s/.gaim/dict", getenv("HOME")); | 307 snprintf(buf, sizeof buf, "%s/.gaim/dict", getenv("HOME")); |
317 } | 317 } |
318 close_config(); | 318 close_config(); |
319 load_conf(); | 319 load_conf(); |
320 } | 320 } |
321 | 321 |
322 void bad_changed() { | 322 static void bad_changed() { |
323 int row; | 323 int row; |
324 char *m; | 324 char *m; |
325 | 325 |
326 if (GTK_CLIST(list)->selection) | 326 if (GTK_CLIST(list)->selection) |
327 row = (int) GTK_CLIST (list)->selection->data; | 327 row = (int) GTK_CLIST (list)->selection->data; |
331 m = gtk_entry_get_text(GTK_ENTRY(bad_entry)); | 331 m = gtk_entry_get_text(GTK_ENTRY(bad_entry)); |
332 gtk_clist_set_text(GTK_CLIST(list), row, 0, m); | 332 gtk_clist_set_text(GTK_CLIST(list), row, 0, m); |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 void good_changed() { | 336 static void good_changed() { |
337 int row; | 337 int row; |
338 char *m; | 338 char *m; |
339 | 339 |
340 if (GTK_CLIST(list)->selection) | 340 if (GTK_CLIST(list)->selection) |
341 row = (int) GTK_CLIST (list)->selection->data; | 341 row = (int) GTK_CLIST (list)->selection->data; |