Commit c7eecd74 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

new feature: a bindable function that starts always a backward search

parent a7fa1744
Showing with 34 additions and 5 deletions
+34 -5
...@@ -1087,8 +1087,11 @@ Inserts a file into the current buffer (at the current cursor position), ...@@ -1087,8 +1087,11 @@ Inserts a file into the current buffer (at the current cursor position),
or into a new buffer when option @code{multibuffer} is set. or into a new buffer when option @code{multibuffer} is set.
@item whereis @item whereis
Searches for text in the current buffer --- or for filenames matching Starts a forward search for text in the current buffer --- or for filenames
a string in the current list in the file browser matching a string in the current list in the file browser.
@item wherewas
Starts a backward search for text in the current buffer.
@item searchagain @item searchagain
Repeats the last search command without prompting. Repeats the last search command without prompting.
......
...@@ -443,8 +443,11 @@ Inserts a file into the current buffer (at the current cursor position), ...@@ -443,8 +443,11 @@ Inserts a file into the current buffer (at the current cursor position),
or into a new buffer when option \fBmultibuffer\fR is set. or into a new buffer when option \fBmultibuffer\fR is set.
.TP .TP
.B whereis .B whereis
Searches for text in the current buffer -- or for filenames matching Starts a forward search for text in the current buffer -- or for filenames
a string in the current list in the file browser. matching a string in the current list in the file browser.
.TP
.B wherewas
Starts a backward search for text in the current buffer.
.TP .TP
.B searchagain .B searchagain
Repeats the last search command without prompting. Repeats the last search command without prompting.
......
...@@ -534,6 +534,8 @@ void shortcut_init(void) ...@@ -534,6 +534,8 @@ void shortcut_init(void)
N_("Insert another file into the current one"); N_("Insert another file into the current one");
const char *nano_whereis_msg = const char *nano_whereis_msg =
N_("Search for a string or a regular expression"); N_("Search for a string or a regular expression");
const char *nano_wherewas_msg =
N_("Search backward for a string or expression");
#ifdef ENABLE_BROWSER #ifdef ENABLE_BROWSER
const char *nano_browser_whereis_msg = N_("Search for a string"); const char *nano_browser_whereis_msg = N_("Search for a string");
const char *nano_browser_refresh_msg = N_("Refresh the file list"); const char *nano_browser_refresh_msg = N_("Refresh the file list");
...@@ -974,6 +976,9 @@ void shortcut_init(void) ...@@ -974,6 +976,9 @@ void shortcut_init(void)
N_("Comment Lines"), IFSCHELP(nano_comment_msg), BLANKAFTER, NOVIEW); N_("Comment Lines"), IFSCHELP(nano_comment_msg), BLANKAFTER, NOVIEW);
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
add_to_funcs(do_search_backward, MMAIN,
N_("Where Was"), IFSCHELP(N_(nano_wherewas_msg)), BLANKAFTER, VIEW);
add_to_funcs(do_savefile, MMAIN, add_to_funcs(do_savefile, MMAIN,
N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW); N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
#endif #endif
...@@ -1462,7 +1467,9 @@ sc *strtosc(const char *input) ...@@ -1462,7 +1467,9 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "insert")) else if (!strcasecmp(input, "insert"))
s->scfunc = do_insertfile_void; s->scfunc = do_insertfile_void;
else if (!strcasecmp(input, "whereis")) else if (!strcasecmp(input, "whereis"))
s->scfunc = do_search; s->scfunc = do_search_forward;
else if (!strcasecmp(input, "wherewas"))
s->scfunc = do_search_backward;
else if (!strcasecmp(input, "searchagain") || else if (!strcasecmp(input, "searchagain") ||
!strcasecmp(input, "research")) /* Deprecated. Remove in 2018. */ !strcasecmp(input, "research")) /* Deprecated. Remove in 2018. */
s->scfunc = do_research; s->scfunc = do_research;
......
...@@ -502,6 +502,8 @@ void search_replace_abort(void); ...@@ -502,6 +502,8 @@ void search_replace_abort(void);
int findnextstr(const char *needle, bool whole_word_only, bool have_region, int findnextstr(const char *needle, bool whole_word_only, bool have_region,
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x); size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x);
void do_search(void); void do_search(void);
void do_search_forward(void);
void do_search_backward(void);
#ifndef NANO_TINY #ifndef NANO_TINY
void do_findprevious(void); void do_findprevious(void);
void do_findnext(void); void do_findnext(void);
......
...@@ -374,6 +374,20 @@ void do_search(void) ...@@ -374,6 +374,20 @@ void do_search(void)
go_looking(); go_looking();
} }
/* Search forward for a string. */
void do_search_forward(void)
{
UNSET(BACKWARDS_SEARCH);
do_search();
}
/* Search backwards for a string. */
void do_search_backward(void)
{
SET(BACKWARDS_SEARCH);
do_search();
}
#ifndef NANO_TINY #ifndef NANO_TINY
/* Search in the backward direction for the next occurrence. */ /* Search in the backward direction for the next occurrence. */
void do_findprevious(void) void do_findprevious(void)
......
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