Revision: 253 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=253&view=rev Author: eht16 Date: 2008-10-25 16:10:46 +0000 (Sat, 25 Oct 2008)
Log Message: ----------- If showing suggestions in the messages window is disabled, don't check for suggestions at all, this heavily reduces the time needed for a full document check.
Modified Paths: -------------- trunk/spellcheck/ChangeLog trunk/spellcheck/src/speller.c trunk/spellcheck/src/speller.h
Modified: trunk/spellcheck/ChangeLog =================================================================== --- trunk/spellcheck/ChangeLog 2008-10-25 15:33:03 UTC (rev 252) +++ trunk/spellcheck/ChangeLog 2008-10-25 16:10:46 UTC (rev 253) @@ -4,6 +4,9 @@ Add some error checking and prevent crashes if Enchant doesn't provide any dictionaries. Plug a little memory leak. + If showing suggestions in the messages window is disabled, don't + check for suggestions at all, this heavily reduces the time needed + for a full document check. * src/gui.c: Ignore numbers when updating the editor menu. Rename the editor menu item to 'Spelling Suggestions'.
Modified: trunk/spellcheck/src/speller.c =================================================================== --- trunk/spellcheck/src/speller.c 2008-10-25 15:33:03 UTC (rev 252) +++ trunk/spellcheck/src/speller.c 2008-10-25 16:10:46 UTC (rev 253) @@ -57,16 +57,16 @@ }
-gint speller_check_word(GeanyDocument *doc, gint line_number, const gchar *word, +static gint speller_check_word(GeanyDocument *doc, gint line_number, const gchar *word, gint start_pos, gint end_pos) { - gsize j; gsize n_suggs = 0; - gchar **suggs; - GString *str;
g_return_val_if_fail(speller_dict != NULL, 0);
+ if (! NZV(word)) + return 0; + /* ignore numbers or words starting with digits */ if (isdigit(*word)) return 0; @@ -75,33 +75,39 @@ if (enchant_dict_check(speller_dict, word, -1) == 0) return 0;
- str = g_string_sized_new(256); - suggs = enchant_dict_suggest(speller_dict, word, -1, &n_suggs); + if (start_pos == -1) + start_pos = end_pos - strlen(word);
- if (suggs != NULL) + p_editor->set_indicator(doc->editor, start_pos, end_pos); + + if (sc->use_msgwin) { - g_string_append_printf(str, "line %d: %s | ", line_number + 1, word); + gsize j; + gchar **suggs; + GString *str;
- g_string_append(str, _("Try: ")); - - /* Now find the misspellings in the line, limit suggestions to a maximum of 15 (for now) */ - for (j = 0; j < MIN(n_suggs, 15); j++) + str = g_string_sized_new(256); + suggs = enchant_dict_suggest(speller_dict, word, -1, &n_suggs); + if (suggs != NULL) { - g_string_append(str, suggs[j]); - g_string_append_c(str, ' '); - } + g_string_append_printf(str, "line %d: %s | ", line_number + 1, word);
- if (start_pos == -1) - start_pos = end_pos - strlen(word); + g_string_append(str, _("Try: "));
- p_editor->set_indicator(doc->editor, start_pos, end_pos); - if (sc->use_msgwin) + /* Now find the misspellings in the line, limit suggestions to a maximum of 15 (for now) */ + for (j = 0; j < MIN(n_suggs, 15); j++) + { + g_string_append(str, suggs[j]); + g_string_append_c(str, ' '); + } + p_msgwindow->msg_add(COLOR_RED, line_number + 1, doc, "%s", str->str);
- if (suggs != NULL && n_suggs) - enchant_dict_free_string_list(speller_dict, suggs); + if (suggs != NULL && n_suggs > 0) + enchant_dict_free_string_list(speller_dict, suggs); + } + g_string_free(str, TRUE); } - g_string_free(str, TRUE);
return n_suggs; } @@ -194,7 +200,6 @@
g_free(line); } - if (suggestions_found == 0 && sc->use_msgwin) p_msgwindow->msg_add(COLOR_BLUE, -1, NULL, _("The checked text is spelled correctly.")); }
Modified: trunk/spellcheck/src/speller.h =================================================================== --- trunk/spellcheck/src/speller.h 2008-10-25 15:33:03 UTC (rev 252) +++ trunk/spellcheck/src/speller.h 2008-10-25 16:10:46 UTC (rev 253) @@ -27,9 +27,6 @@ #define SC_SPELLER_H 1
-gint speller_check_word(GeanyDocument *doc, gint line_number, const gchar *word, - gint start_pos, gint end_pos); - gint speller_process_line(GeanyDocument *doc, gint line_number, const gchar *line);
void speller_check_document(GeanyDocument *doc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org