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-d3aeb78583b8master
parent
75155dff51
commit
d00e6dfacd
12
ChangeLog
12
ChangeLog
|
@ -30,6 +30,18 @@ CVS code -
|
|||
text there, then grabs the next keystroke and, if the unjustify
|
||||
key, gets rid of the justified text and calls do_uncut_text.
|
||||
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:
|
||||
- Traditional Spanish strings updates.
|
||||
|
||||
|
|
30
nano.c
30
nano.c
|
@ -1074,8 +1074,8 @@ void wrap_reset(void)
|
|||
int do_int_spell_fix(char *word)
|
||||
{
|
||||
char *prevanswer = NULL, *save_search = NULL, *save_replace = NULL;
|
||||
filestruct *begin, *begin_top;
|
||||
int i = 0, beginx, beginx_top;
|
||||
filestruct *begin;
|
||||
int i = 0, j = 0, beginx, beginx_top;
|
||||
|
||||
/* save where we are */
|
||||
begin = current;
|
||||
|
@ -1092,25 +1092,32 @@ int do_int_spell_fix(char *word)
|
|||
last_replace = mallocstrcpy(last_replace, word);
|
||||
|
||||
/* start from the top of file */
|
||||
begin_top = current = fileage;
|
||||
beginx_top = current_x = -1;
|
||||
current = fileage;
|
||||
current_x = beginx_top = -1;
|
||||
|
||||
search_last_line = FALSE;
|
||||
|
||||
edit_update(fileage, TOP);
|
||||
|
||||
/* 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 */
|
||||
current = begin_top;
|
||||
current = fileage;
|
||||
current_x = beginx_top;
|
||||
|
||||
search_last_line = FALSE;
|
||||
|
||||
/* allow replace word to be corrected */
|
||||
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, last_replace,
|
||||
_("Edit a replacement"));
|
||||
|
||||
do_replace_loop(prevanswer, begin_top, &beginx_top, TRUE, &i);
|
||||
j = i;
|
||||
do_replace_loop(prevanswer, fileage, &beginx_top, TRUE, &j);
|
||||
}
|
||||
|
||||
/* restore the search/replace strings */
|
||||
|
@ -1171,6 +1178,7 @@ int do_int_speller(char *tempfile_name)
|
|||
}
|
||||
close(tempfile_fd);
|
||||
|
||||
|
||||
/* send spell's standard out to the pipe */
|
||||
|
||||
if (dup2(in_fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
|
||||
|
|
2
nano.h
2
nano.h
|
@ -245,7 +245,7 @@ know what you're doing */
|
|||
#define GOTO_LIST_LEN 3
|
||||
#define WRITEFILE_LIST_LEN 1
|
||||
#define HELP_LIST_LEN 3
|
||||
#define SPELL_LIST_LEN 3
|
||||
#define SPELL_LIST_LEN 2
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
#define TOGGLE_LEN 9
|
||||
|
|
74
po/nano.pot
74
po/nano.pot
|
@ -6,7 +6,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"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"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -55,7 +55,7 @@ msgstr ""
|
|||
msgid "File to insert [from ./] "
|
||||
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"
|
||||
msgstr ""
|
||||
|
||||
|
@ -642,101 +642,101 @@ msgstr ""
|
|||
msgid "After, data = \"%s\"\n"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1111
|
||||
#: nano.c:1109
|
||||
msgid "Edit a replacement"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1322
|
||||
#: nano.c:1330
|
||||
#, c-format
|
||||
msgid "Could not create a temporary filename: %s"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1338
|
||||
#: nano.c:1346
|
||||
msgid "Finished checking spelling"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1340
|
||||
#: nano.c:1348
|
||||
msgid "Spell checking failed"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1360
|
||||
#: nano.c:1368
|
||||
msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1523
|
||||
#: nano.c:1531
|
||||
msgid "Cannot resize top win"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1525
|
||||
#: nano.c:1533
|
||||
msgid "Cannot move top win"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1527
|
||||
#: nano.c:1535
|
||||
msgid "Cannot resize edit win"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1529
|
||||
#: nano.c:1537
|
||||
msgid "Cannot move edit win"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1531
|
||||
#: nano.c:1539
|
||||
msgid "Cannot resize bottom win"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1533
|
||||
#: nano.c:1541
|
||||
msgid "Cannot move bottom win"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1815
|
||||
#: nano.c:1823
|
||||
msgid "Can now UnJustify!"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1913
|
||||
#: nano.c:1921
|
||||
#, c-format
|
||||
msgid "%s enable/disable"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1925
|
||||
#: nano.c:1933
|
||||
msgid "enabled"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:1926
|
||||
#: nano.c:1934
|
||||
msgid "disabled"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:2156
|
||||
#: nano.c:2164
|
||||
msgid "Main: set up windows\n"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:2169
|
||||
#: nano.c:2177
|
||||
msgid "Main: bottom win\n"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:2175
|
||||
#: nano.c:2183
|
||||
msgid "Main: open file\n"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:2212
|
||||
#: nano.c:2220
|
||||
#, c-format
|
||||
msgid "I got Alt-O-%c! (%d)\n"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:2234
|
||||
#: nano.c:2242
|
||||
#, c-format
|
||||
msgid "I got Alt-[-1-%c! (%d)\n"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:2267
|
||||
#: nano.c:2275
|
||||
#, c-format
|
||||
msgid "I got Alt-[-2-%c! (%d)\n"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:2315
|
||||
#: nano.c:2323
|
||||
#, c-format
|
||||
msgid "I got Alt-[-%c! (%d)\n"
|
||||
msgstr ""
|
||||
|
||||
#: nano.c:2341
|
||||
#: nano.c:2349
|
||||
#, c-format
|
||||
msgid "I got Alt-%c! (%d)\n"
|
||||
msgstr ""
|
||||
|
@ -765,7 +765,7 @@ msgstr ""
|
|||
msgid " (to replace)"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:136 search.c:318
|
||||
#: search.c:136 search.c:321
|
||||
msgid "Search Cancelled"
|
||||
msgstr ""
|
||||
|
||||
|
@ -778,50 +778,50 @@ msgstr ""
|
|||
msgid "Search Wrapped"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:340
|
||||
#: search.c:343
|
||||
#, c-format
|
||||
msgid "Replaced %d occurences"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:342
|
||||
#: search.c:345
|
||||
msgid "Replaced 1 occurence"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:479 search.c:575 search.c:591
|
||||
#: search.c:504 search.c:608 search.c:624
|
||||
msgid "Replace Cancelled"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:525
|
||||
#: search.c:554
|
||||
msgid "Replace this instance?"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:533
|
||||
#: search.c:566
|
||||
msgid "Replace failed: unknown subexpression!"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:616
|
||||
#: search.c:649
|
||||
#, c-format
|
||||
msgid "Replace with [%s]"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:620 search.c:624
|
||||
#: search.c:653 search.c:657
|
||||
msgid "Replace with"
|
||||
msgstr ""
|
||||
|
||||
#. Ask for it
|
||||
#: search.c:659
|
||||
#: search.c:692
|
||||
msgid "Enter line number"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:661
|
||||
#: search.c:694
|
||||
msgid "Aborted"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:681
|
||||
#: search.c:714
|
||||
msgid "Come on, be reasonable"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:686
|
||||
#: search.c:719
|
||||
#, c-format
|
||||
msgid "Only %d lines available, skipping to last line"
|
||||
msgstr ""
|
||||
|
|
1
proto.h
1
proto.h
|
@ -132,6 +132,7 @@ void blank_edit(void);
|
|||
void search_init_globals(void);
|
||||
void replace_abort(void);
|
||||
void add_to_cutbuffer(filestruct * inptr);
|
||||
void do_replace_highlight(int highlight_flag, char *word);
|
||||
#ifdef NANO_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
|
|
47
search.c
47
search.c
|
@ -202,11 +202,11 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
|
|||
{
|
||||
filestruct *fileptr;
|
||||
char *searchstr, *found = NULL, *tmp;
|
||||
int past_editbot = 0, current_x_find = current_x;
|
||||
int past_editbot = 0, current_x_find;
|
||||
|
||||
fileptr = current;
|
||||
|
||||
current_x_find++;
|
||||
current_x_find = current_x + 1;
|
||||
|
||||
/* Are we searching the last line? (i.e. the line where search started) */
|
||||
if ((fileptr == begin) && (current_x_find < beginx))
|
||||
|
@ -251,18 +251,21 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
|
|||
}
|
||||
|
||||
/* We found an instance */
|
||||
current = fileptr;
|
||||
current_x = 0;
|
||||
current_x_find = 0;
|
||||
for (tmp = fileptr->data; tmp != found; tmp++)
|
||||
current_x++;
|
||||
current_x_find++;
|
||||
|
||||
/* Ensure we haven't wrap around again! */
|
||||
if ((search_last_line) && (current_x >= beginx)) {
|
||||
if ((search_last_line) && (current_x_find >= beginx)) {
|
||||
if (!quiet)
|
||||
not_found_msg(needle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set globals now that we are sure we found something */
|
||||
current = fileptr;
|
||||
current_x = current_x_find;
|
||||
|
||||
if (past_editbot)
|
||||
edit_update(fileptr, CENTER);
|
||||
else
|
||||
|
@ -465,6 +468,28 @@ char *replace_line(void)
|
|||
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, ¤t->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 wholewords, int *i)
|
||||
{
|
||||
|
@ -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 (!replaceall)
|
||||
if (!replaceall) {
|
||||
|
||||
curs_set(0);
|
||||
do_replace_highlight(TRUE, prevanswer);
|
||||
|
||||
*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 == 2)
|
||||
replaceall = 1;
|
||||
|
|
Loading…
Reference in New Issue