Commit d00e6dfa authored by Chris Allegretta's avatar Chris Allegretta
Browse files

Rocco's changes to spell checking and my alterations

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@350 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 75155dff
Showing with 110 additions and 56 deletions
+110 -56
...@@ -30,6 +30,18 @@ CVS code - ...@@ -30,6 +30,18 @@ CVS code -
text there, then grabs the next keystroke and, if the unjustify text there, then grabs the next keystroke and, if the unjustify
key, gets rid of the justified text and calls do_uncut_text. key, gets rid of the justified text and calls do_uncut_text.
Added macro NANO_UNJUSTIFY_KEY. Added macro NANO_UNJUSTIFY_KEY.
do_int_spell*
- Various fixes (Rocco Corsi).
- Changed abort of program to aborting based on value of "edit a
replacement" question, and not caring about the replace loop
return value. That way the user can get out of the replace loop
and continue spell checking (very important to me anyway).
- search.c:
do_replace_hilight()
- New function, displays the currently selected word as hilighted
in the spell check. Called from do_replace_loop (Rocco Corsi).
- Added calls to curs_set(0) and (1) to diable the cursor when
hilighting, looks much better.
- es.po: - es.po:
- Traditional Spanish strings updates. - Traditional Spanish strings updates.
......
...@@ -1074,8 +1074,8 @@ void wrap_reset(void) ...@@ -1074,8 +1074,8 @@ void wrap_reset(void)
int do_int_spell_fix(char *word) int do_int_spell_fix(char *word)
{ {
char *prevanswer = NULL, *save_search = NULL, *save_replace = NULL; char *prevanswer = NULL, *save_search = NULL, *save_replace = NULL;
filestruct *begin, *begin_top; filestruct *begin;
int i = 0, beginx, beginx_top; int i = 0, j = 0, beginx, beginx_top;
/* save where we are */ /* save where we are */
begin = current; begin = current;
...@@ -1092,25 +1092,32 @@ int do_int_spell_fix(char *word) ...@@ -1092,25 +1092,32 @@ int do_int_spell_fix(char *word)
last_replace = mallocstrcpy(last_replace, word); last_replace = mallocstrcpy(last_replace, word);
/* start from the top of file */ /* start from the top of file */
begin_top = current = fileage; current = fileage;
beginx_top = current_x = -1; current_x = beginx_top = -1;
search_last_line = FALSE; search_last_line = FALSE;
edit_update(fileage, TOP);
/* make sure word is still mis-spelt (i.e. when multi-errors) */ /* make sure word is still mis-spelt (i.e. when multi-errors) */
if (findnextstr(TRUE, begin_top, beginx_top, prevanswer) != NULL) if (findnextstr(TRUE, fileage, beginx_top, prevanswer) != NULL)
{ {
do_replace_highlight(TRUE, prevanswer);
/* allow replace word to be corrected */
i = statusq(0, spell_list, SPELL_LIST_LEN, last_replace,
_("Edit a replacement"));
do_replace_highlight(FALSE, prevanswer);
/* start from the start of this line again */ /* start from the start of this line again */
current = begin_top; current = fileage;
current_x = beginx_top; current_x = beginx_top;
search_last_line = FALSE; search_last_line = FALSE;
/* allow replace word to be corrected */ j = i;
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, last_replace, do_replace_loop(prevanswer, fileage, &beginx_top, TRUE, &j);
_("Edit a replacement"));
do_replace_loop(prevanswer, begin_top, &beginx_top, TRUE, &i);
} }
/* restore the search/replace strings */ /* restore the search/replace strings */
...@@ -1171,6 +1178,7 @@ int do_int_speller(char *tempfile_name) ...@@ -1171,6 +1178,7 @@ int do_int_speller(char *tempfile_name)
} }
close(tempfile_fd); close(tempfile_fd);
/* send spell's standard out to the pipe */ /* send spell's standard out to the pipe */
if (dup2(in_fd[1], STDOUT_FILENO) != STDOUT_FILENO) { if (dup2(in_fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
......
...@@ -245,7 +245,7 @@ know what you're doing */ ...@@ -245,7 +245,7 @@ know what you're doing */
#define GOTO_LIST_LEN 3 #define GOTO_LIST_LEN 3
#define WRITEFILE_LIST_LEN 1 #define WRITEFILE_LIST_LEN 1
#define HELP_LIST_LEN 3 #define HELP_LIST_LEN 3
#define SPELL_LIST_LEN 3 #define SPELL_LIST_LEN 2
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
#define TOGGLE_LEN 9 #define TOGGLE_LEN 9
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-11-28 18:04-0500\n" "POT-Creation-Date: 2000-11-28 23:25-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -55,7 +55,7 @@ msgstr "" ...@@ -55,7 +55,7 @@ msgstr ""
msgid "File to insert [from ./] " msgid "File to insert [from ./] "
msgstr "" msgstr ""
#: files.c:280 files.c:305 files.c:513 nano.c:1373 #: files.c:280 files.c:305 files.c:513 nano.c:1381
msgid "Cancelled" msgid "Cancelled"
msgstr "" msgstr ""
...@@ -642,101 +642,101 @@ msgstr "" ...@@ -642,101 +642,101 @@ msgstr ""
msgid "After, data = \"%s\"\n" msgid "After, data = \"%s\"\n"
msgstr "" msgstr ""
#: nano.c:1111 #: nano.c:1109
msgid "Edit a replacement" msgid "Edit a replacement"
msgstr "" msgstr ""
#: nano.c:1322 #: nano.c:1330
#, c-format #, c-format
msgid "Could not create a temporary filename: %s" msgid "Could not create a temporary filename: %s"
msgstr "" msgstr ""
#: nano.c:1338 #: nano.c:1346
msgid "Finished checking spelling" msgid "Finished checking spelling"
msgstr "" msgstr ""
#: nano.c:1340 #: nano.c:1348
msgid "Spell checking failed" msgid "Spell checking failed"
msgstr "" msgstr ""
#: nano.c:1360 #: nano.c:1368
msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? " msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "
msgstr "" msgstr ""
#: nano.c:1523 #: nano.c:1531
msgid "Cannot resize top win" msgid "Cannot resize top win"
msgstr "" msgstr ""
#: nano.c:1525 #: nano.c:1533
msgid "Cannot move top win" msgid "Cannot move top win"
msgstr "" msgstr ""
#: nano.c:1527 #: nano.c:1535
msgid "Cannot resize edit win" msgid "Cannot resize edit win"
msgstr "" msgstr ""
#: nano.c:1529 #: nano.c:1537
msgid "Cannot move edit win" msgid "Cannot move edit win"
msgstr "" msgstr ""
#: nano.c:1531 #: nano.c:1539
msgid "Cannot resize bottom win" msgid "Cannot resize bottom win"
msgstr "" msgstr ""
#: nano.c:1533 #: nano.c:1541
msgid "Cannot move bottom win" msgid "Cannot move bottom win"
msgstr "" msgstr ""
#: nano.c:1815 #: nano.c:1823
msgid "Can now UnJustify!" msgid "Can now UnJustify!"
msgstr "" msgstr ""
#: nano.c:1913 #: nano.c:1921
#, c-format #, c-format
msgid "%s enable/disable" msgid "%s enable/disable"
msgstr "" msgstr ""
#: nano.c:1925 #: nano.c:1933
msgid "enabled" msgid "enabled"
msgstr "" msgstr ""
#: nano.c:1926 #: nano.c:1934
msgid "disabled" msgid "disabled"
msgstr "" msgstr ""
#: nano.c:2156 #: nano.c:2164
msgid "Main: set up windows\n" msgid "Main: set up windows\n"
msgstr "" msgstr ""
#: nano.c:2169 #: nano.c:2177
msgid "Main: bottom win\n" msgid "Main: bottom win\n"
msgstr "" msgstr ""
#: nano.c:2175 #: nano.c:2183
msgid "Main: open file\n" msgid "Main: open file\n"
msgstr "" msgstr ""
#: nano.c:2212 #: nano.c:2220
#, c-format #, c-format
msgid "I got Alt-O-%c! (%d)\n" msgid "I got Alt-O-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:2234 #: nano.c:2242
#, c-format #, c-format
msgid "I got Alt-[-1-%c! (%d)\n" msgid "I got Alt-[-1-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:2267 #: nano.c:2275
#, c-format #, c-format
msgid "I got Alt-[-2-%c! (%d)\n" msgid "I got Alt-[-2-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:2315 #: nano.c:2323
#, c-format #, c-format
msgid "I got Alt-[-%c! (%d)\n" msgid "I got Alt-[-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:2341 #: nano.c:2349
#, c-format #, c-format
msgid "I got Alt-%c! (%d)\n" msgid "I got Alt-%c! (%d)\n"
msgstr "" msgstr ""
...@@ -765,7 +765,7 @@ msgstr "" ...@@ -765,7 +765,7 @@ msgstr ""
msgid " (to replace)" msgid " (to replace)"
msgstr "" msgstr ""
#: search.c:136 search.c:318 #: search.c:136 search.c:321
msgid "Search Cancelled" msgid "Search Cancelled"
msgstr "" msgstr ""
...@@ -778,50 +778,50 @@ msgstr "" ...@@ -778,50 +778,50 @@ msgstr ""
msgid "Search Wrapped" msgid "Search Wrapped"
msgstr "" msgstr ""
#: search.c:340 #: search.c:343
#, c-format #, c-format
msgid "Replaced %d occurences" msgid "Replaced %d occurences"
msgstr "" msgstr ""
#: search.c:342 #: search.c:345
msgid "Replaced 1 occurence" msgid "Replaced 1 occurence"
msgstr "" msgstr ""
#: search.c:479 search.c:575 search.c:591 #: search.c:504 search.c:608 search.c:624
msgid "Replace Cancelled" msgid "Replace Cancelled"
msgstr "" msgstr ""
#: search.c:525 #: search.c:554
msgid "Replace this instance?" msgid "Replace this instance?"
msgstr "" msgstr ""
#: search.c:533 #: search.c:566
msgid "Replace failed: unknown subexpression!" msgid "Replace failed: unknown subexpression!"
msgstr "" msgstr ""
#: search.c:616 #: search.c:649
#, c-format #, c-format
msgid "Replace with [%s]" msgid "Replace with [%s]"
msgstr "" msgstr ""
#: search.c:620 search.c:624 #: search.c:653 search.c:657
msgid "Replace with" msgid "Replace with"
msgstr "" msgstr ""
#. Ask for it #. Ask for it
#: search.c:659 #: search.c:692
msgid "Enter line number" msgid "Enter line number"
msgstr "" msgstr ""
#: search.c:661 #: search.c:694
msgid "Aborted" msgid "Aborted"
msgstr "" msgstr ""
#: search.c:681 #: search.c:714
msgid "Come on, be reasonable" msgid "Come on, be reasonable"
msgstr "" msgstr ""
#: search.c:686 #: search.c:719
#, c-format #, c-format
msgid "Only %d lines available, skipping to last line" msgid "Only %d lines available, skipping to last line"
msgstr "" msgstr ""
......
...@@ -132,6 +132,7 @@ void blank_edit(void); ...@@ -132,6 +132,7 @@ void blank_edit(void);
void search_init_globals(void); void search_init_globals(void);
void replace_abort(void); void replace_abort(void);
void add_to_cutbuffer(filestruct * inptr); void add_to_cutbuffer(filestruct * inptr);
void do_replace_highlight(int highlight_flag, char *word);
#ifdef NANO_EXTRA #ifdef NANO_EXTRA
void do_credits(void); void do_credits(void);
#endif #endif
......
...@@ -202,11 +202,11 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx, ...@@ -202,11 +202,11 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
{ {
filestruct *fileptr; filestruct *fileptr;
char *searchstr, *found = NULL, *tmp; char *searchstr, *found = NULL, *tmp;
int past_editbot = 0, current_x_find = current_x; int past_editbot = 0, current_x_find;
fileptr = current; fileptr = current;
current_x_find++; current_x_find = current_x + 1;
/* Are we searching the last line? (i.e. the line where search started) */ /* Are we searching the last line? (i.e. the line where search started) */
if ((fileptr == begin) && (current_x_find < beginx)) if ((fileptr == begin) && (current_x_find < beginx))
...@@ -251,18 +251,21 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx, ...@@ -251,18 +251,21 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
} }
/* We found an instance */ /* We found an instance */
current = fileptr; current_x_find = 0;
current_x = 0;
for (tmp = fileptr->data; tmp != found; tmp++) for (tmp = fileptr->data; tmp != found; tmp++)
current_x++; current_x_find++;
/* Ensure we haven't wrap around again! */ /* Ensure we haven't wrap around again! */
if ((search_last_line) && (current_x >= beginx)) { if ((search_last_line) && (current_x_find >= beginx)) {
if (!quiet) if (!quiet)
not_found_msg(needle); not_found_msg(needle);
return NULL; return NULL;
} }
/* Set globals now that we are sure we found something */
current = fileptr;
current_x = current_x_find;
if (past_editbot) if (past_editbot)
edit_update(fileptr, CENTER); edit_update(fileptr, CENTER);
else else
...@@ -465,6 +468,28 @@ char *replace_line(void) ...@@ -465,6 +468,28 @@ char *replace_line(void)
return copy; return copy;
} }
/* highlight the current word being replaced or spell checked */
void do_replace_highlight(int highlight_flag, char *word)
{
char *highlight_word = NULL;
highlight_word = mallocstrcpy(highlight_word, &current->data[current_x]);
highlight_word[strlen(word)] = '\0';
reset_cursor();
if (highlight_flag)
wattron(edit, A_REVERSE);
waddstr(edit, highlight_word);
if (highlight_flag)
wattroff(edit, A_REVERSE);
free(highlight_word);
}
/* step through each replace word and prompt user before replacing word */
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx, int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
int wholewords, int *i) int wholewords, int *i)
{ {
...@@ -521,9 +546,17 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx, ...@@ -521,9 +546,17 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
} }
/* If we're here, we've found the search string */ /* If we're here, we've found the search string */
if (!replaceall) if (!replaceall) {
curs_set(0);
do_replace_highlight(TRUE, prevanswer);
*i = do_yesno(1, 1, _("Replace this instance?")); *i = do_yesno(1, 1, _("Replace this instance?"));
do_replace_highlight(FALSE, prevanswer);
curs_set(1);
}
if (*i > 0 || replaceall) { /* Yes, replace it!!!! */ if (*i > 0 || replaceall) { /* Yes, replace it!!!! */
if (*i == 2) if (*i == 2)
replaceall = 1; replaceall = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment