From 5a6caf0ca835c0b774705ba3128bfe596a90c3e3 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Wed, 15 Jun 2005 19:21:04 +0000 Subject: [PATCH] in do_int_spell_fix(), display highlighted misspelled words using display_string(), as do_replace_loop() does git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2679 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ src/nano.c | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c67abf84..c4412bc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -171,6 +171,9 @@ CVS code - erroneously translated twice. (DLR) do_tab() - Remove unneeded variable kbinput. (DLR) + do_int_spell_fix() + - Display highlighted misspelled words using display_string(), + as do_replace_loop() does. (DLR) do_alt_speller() - Replace a set_modified() with SET(MODIFIED) to avoid an unnecessary update, and remove an unneeded clearok(FALSE). diff --git a/src/nano.c b/src/nano.c index b0ca75a6..222ee8f1 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1920,6 +1920,7 @@ bool do_wrap(filestruct *line) bool do_int_spell_fix(const char *word) { char *save_search, *save_replace; + size_t match_len; size_t current_x_save = current_x, pww_save = placewewant; filestruct *edittop_save = edittop, *current_save = current; /* Save where we are. */ @@ -1986,11 +1987,17 @@ bool do_int_spell_fix(const char *word) /* Find the first whole-word occurrence of word. */ findnextstr_wrap_reset(); - while (findnextstr(TRUE, TRUE, FALSE, fileage, 0, word, NULL)) { + while (findnextstr(TRUE, TRUE, FALSE, fileage, 0, word, + &match_len)) { if (is_whole_word(current_x, current->data, word)) { + size_t xpt = xplustabs(); + char *exp_word = display_string(current->data, xpt, + strnlenpt(current->data, current_x + match_len) - xpt, + FALSE); + edit_refresh(); - do_replace_highlight(TRUE, word); + do_replace_highlight(TRUE, exp_word); /* Allow all instances of the word to be corrected. */ canceled = (statusq(FALSE, spell_list, word, @@ -1999,7 +2006,9 @@ bool do_int_spell_fix(const char *word) #endif _("Edit a replacement")) == -1); - do_replace_highlight(FALSE, word); + do_replace_highlight(FALSE, exp_word); + + free(exp_word); if (!canceled && strcmp(word, answer) != 0) { current_x--; -- 2.39.5