Wouter van Hemel's "Where Is Next" patch

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1530 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey 2003-08-23 21:11:06 +00:00
parent 222feaa953
commit e04970675f
5 changed files with 61 additions and 6 deletions

View File

@ -20,6 +20,12 @@ CVS code -
notably FreeBSD; if your Backspace key acts like Delete, this
option will fix that. (DLR)
- Remove unneeded breaks at the ends of default: clauses. (DLR)
- Add the ability to repeat the last search without prompting
via Meta-W, and move the line wrapping toggle to Meta-L. New
function do_research(). (Wouter van Hemel)
- Change the message for the line wrapping toggle from "Auto
wrap" to "Auto line wrap", to more clearly associate it with
Meta-L. (DLR)
- files.c:
do_browser():
- Some of the Pico compatibility options in the file browser

View File

@ -260,7 +260,7 @@ void toggle_init(void)
toggle_syntax_msg = _("Color syntax highlighting");
#endif
#ifndef DISABLE_WRAPPING
toggle_wrap_msg = _("Auto wrap");
toggle_wrap_msg = _("Auto line wrap");
#endif
#ifdef ENABLE_MULTIBUFFER
toggle_load_msg = _("Multiple file buffers");
@ -321,10 +321,11 @@ void shortcut_init(int unjustify)
const char *nano_help_msg = "", *nano_writeout_msg = "", *nano_exit_msg =
"", *nano_goto_msg = "", *nano_justify_msg =
"", *nano_replace_msg = "", *nano_insert_msg =
"", *nano_whereis_msg = "", *nano_prevpage_msg =
"", *nano_nextpage_msg = "", *nano_cut_msg =
"", *nano_uncut_msg = "", *nano_cursorpos_msg =
"", *nano_spell_msg = "", *nano_up_msg = "", *nano_down_msg =
"", *nano_whereis_msg = "", *nano_whereis_next_msg =
"", *nano_prevpage_msg = "", *nano_nextpage_msg =
"", *nano_cut_msg = "", *nano_uncut_msg =
"", *nano_cursorpos_msg = "", *nano_spell_msg =
"", *nano_up_msg = "", *nano_down_msg =
"", *nano_forward_msg = "", *nano_back_msg = "", *nano_home_msg =
"", *nano_end_msg = "", *nano_firstline_msg =
"", *nano_lastline_msg = "", *nano_refresh_msg =
@ -359,6 +360,7 @@ void shortcut_init(int unjustify)
nano_replace_msg = _("Replace text within the editor");
nano_insert_msg = _("Insert another file into the current one");
nano_whereis_msg = _("Search for text within the editor");
nano_whereis_next_msg = _("Repeat last search");
nano_prevpage_msg = _("Move to the previous screen");
nano_nextpage_msg = _("Move to the next screen");
nano_cut_msg = _("Cut the current line and store it in the cutbuffer");
@ -564,6 +566,11 @@ void shortcut_init(int unjustify)
IFHELP(nano_bracket_msg, NANO_BRACKET_KEY),
0, 0, VIEW, do_find_bracket);
#endif
sc_init_one(&main_list, -9, _("Where Is Next"),
IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY), 0, 0,
NOVIEW, do_research);
#ifdef ENABLE_MULTIBUFFER
sc_init_one(&main_list, -9, _("Previous File"),
IFHELP(nano_openprev_msg, NANO_OPENPREV_KEY),

3
nano.h
View File

@ -340,6 +340,7 @@ know what you're doing */
#define NANO_HELP_FKEY KEY_F(1)
#define NANO_WHEREIS_KEY NANO_CONTROL_W
#define NANO_WHEREIS_FKEY KEY_F(6)
#define NANO_WHEREIS_NEXT_KEY NANO_ALT_W
#define NANO_REPLACE_KEY NANO_CONTROL_4
#define NANO_REPLACE_FKEY KEY_F(14)
#define NANO_ALT_REPLACE_KEY NANO_ALT_R
@ -398,7 +399,7 @@ know what you're doing */
#define TOGGLE_MOUSE_KEY NANO_ALT_M
#define TOGGLE_CUTTOEND_KEY NANO_ALT_K
#define TOGGLE_REGEXP_KEY NANO_ALT_R
#define TOGGLE_WRAP_KEY NANO_ALT_W
#define TOGGLE_WRAP_KEY NANO_ALT_L
#define TOGGLE_BACKWARDS_KEY NANO_ALT_B
#define TOGGLE_CASE_KEY NANO_ALT_C
#define TOGGLE_LOAD_KEY NANO_ALT_F

View File

@ -358,6 +358,7 @@ filestruct *findnextstr(int quiet, int bracket_mode,
const filestruct *begin, int beginx,
const char *needle);
int do_search(void);
int do_research(void);
void replace_abort(void);
#ifdef HAVE_REGEX_H
int replace_regexp(char *string, int create_flag);

View File

@ -430,6 +430,46 @@ int do_search(void)
return 1;
}
/* Search for the next string without prompting. */
int do_research(void)
{
filestruct *fileptr = current, *didfind;
int fileptr_x = current_x;
#ifdef HAVE_REGEX_H
const char *regex_error = _("Invalid regex \"%s\"");
#endif /* HAVE_REGEX_H */
wrap_reset();
search_init_globals();
if (last_search[0] != '\0') {
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
if (regexp_init(last_search) == 0) {
statusbar(regex_error, last_search);
reset_cursor();
return -3;
}
#endif
search_last_line = 0;
didfind = findnextstr(FALSE, FALSE, current, current_x, last_search);
if (fileptr == current && fileptr_x == current_x && didfind != NULL)
statusbar(_("This is the only occurrence"));
else if (current->lineno <= edittop->lineno
|| current->lineno >= editbot->lineno)
edit_update(current, CENTER);
} else
statusbar(_("No current search pattern"));
search_abort();
return 1;
}
void replace_abort(void)
{
/* Identical to search_abort, so we'll call it here. If it