1
1

Adding two new bindable functions that repeat the last search command

in a fixed direction without prompting.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5320 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
Benno Schulenberg 2015-07-26 09:23:24 +00:00
родитель 8ffc33cd89
Коммит 4990f74f83
6 изменённых файлов: 59 добавлений и 3 удалений

Просмотреть файл

@ -1,6 +1,10 @@
2015-07-26 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_replace_loop): When doing regex replacements, find
each zero-length match only once. This fixes Savannah bug #45626.
each zero-length match only once. This fixes Savannah bug #45626.
* src/global.c (shortcut_init, strtosc), src/search.c (do_findnext,
do_findprevious), doc/man/nanorc.5, doc/texinfo/nano.texi: Add two
new bindable functions, 'findnext' and 'findprevious', which repeat
the last search command in a fixed direction without prompting.
2015-07-25 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (shortcut_init, strtosc), src/files.c (savefile),

Просмотреть файл

@ -394,7 +394,13 @@ Searches for text in the current buffer -- or for filenames matching
a string in the current list in the file browser.
.TP
.B searchagain
Repeats the last search command.
Repeats the last search command without prompting.
.TP
.B findprevious
As \fBsearchagain\fR, but always in the backward direction.
.TP
.B findnext
As \fBsearchagain\fR, but always in the forward direction.
.TP
.B replace
Interactively replaces text within the current buffer.

Просмотреть файл

@ -964,7 +964,13 @@ Searches for text in the current buffer --- or for filenames matching
a string in the current list in the file browser
@item searchagain
Repeats the last search command.
Repeats the last search command without prompting.
@item findprevious
As @code{searchagain}, but always in the backward direction.
@item findnext
As @code{searchagain}, but always in the forward direction.
@item replace
Interactively replaces text within the current buffer.

Просмотреть файл

@ -602,6 +602,8 @@ void shortcut_init(void)
N_("Suspend the editor (if suspend is enabled)");
#ifndef NANO_TINY
const char *nano_savefile_msg = N_("Save file without prompting");
const char *nano_findprev_msg = N_("Search next occurrence backward");
const char *nano_findnext_msg = N_("Search next occurrence forward");
const char *nano_case_msg =
N_("Toggle the case sensitivity of the search");
const char *nano_reverse_msg =
@ -915,6 +917,11 @@ void shortcut_init(void)
#ifndef NANO_TINY
add_to_funcs(do_savefile, MMAIN,
N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
add_to_funcs(do_findprevious, MMAIN,
N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN,
N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
#endif
#ifndef DISABLE_HISTORIES
@ -1317,6 +1324,10 @@ sc *strtosc(char *input)
else if (!strcasecmp(input, "searchagain") ||
!strcasecmp(input, "research"))
s->scfunc = do_research;
else if (!strcasecmp(input, "findprevious"))
s->scfunc = do_findprevious;
else if (!strcasecmp(input, "findnext"))
s->scfunc = do_findnext;
#endif
else if (!strcasecmp(input, "replace"))
s->scfunc = do_replace;

Просмотреть файл

@ -591,6 +591,10 @@ bool findnextstr(
const char *needle, size_t *needle_len);
void findnextstr_wrap_reset(void);
void do_search(void);
#ifndef NANO_TINY
void do_findprevious(void);
void do_findnext(void);
#endif
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
void do_research(void);
#endif

Просмотреть файл

@ -474,6 +474,31 @@ void do_search(void)
search_replace_abort();
}
#ifndef NANO_TINY
/* Search in the backward direction for the next occurrence. */
void do_findprevious(void)
{
if ISSET(BACKWARDS_SEARCH)
do_research();
else {
SET(BACKWARDS_SEARCH);
do_research();
UNSET(BACKWARDS_SEARCH);
}
}
/* Search in the forward direction for the next occurrence. */
void do_findnext(void)
{
if ISSET(BACKWARDS_SEARCH) {
UNSET(BACKWARDS_SEARCH);
do_research();
SET(BACKWARDS_SEARCH);
} else
do_research();
}
#endif
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
/* Search for the last string without prompting. */
void do_research(void)