bindings: make ^Q start a backward search also in the file browser
This makes the four search keystrokes (^W/^Q/M-W/M-Q) available in all three areas of nano: editor, help viewer, and file browser.
Этот коммит содержится в:
родитель
7f2031006a
Коммит
7a31507167
@ -166,9 +166,9 @@ char *do_browser(char *path)
|
|||||||
say_there_is_no_help();
|
say_there_is_no_help();
|
||||||
#endif
|
#endif
|
||||||
} else if (func == do_search_forward) {
|
} else if (func == do_search_forward) {
|
||||||
do_filesearch();
|
do_filesearch(FORWARD);
|
||||||
} else if (func == do_research) {
|
} else if (func == do_search_backward) {
|
||||||
do_fileresearch(FORWARD);
|
do_filesearch(BACKWARD);
|
||||||
} else if (func == do_findprevious) {
|
} else if (func == do_findprevious) {
|
||||||
do_fileresearch(BACKWARD);
|
do_fileresearch(BACKWARD);
|
||||||
} else if (func == do_findnext) {
|
} else if (func == do_findnext) {
|
||||||
@ -657,10 +657,11 @@ void browser_select_dirname(const char *needle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare the prompt and ask the user what to search for. Return -2
|
/* Prepare the prompt and ask the user what to search for. If forwards is
|
||||||
|
* TRUE, search forward in the list; otherwise, search backward. Return -2
|
||||||
* for a blank answer, -1 for Cancel, 0 when we have a string, and a
|
* for a blank answer, -1 for Cancel, 0 when we have a string, and a
|
||||||
* positive value when some function was run. */
|
* positive value when some function was run. */
|
||||||
int filesearch_init(void)
|
int filesearch_init(bool forwards)
|
||||||
{
|
{
|
||||||
char *thedefault;
|
char *thedefault;
|
||||||
int response;
|
int response;
|
||||||
@ -679,7 +680,8 @@ int filesearch_init(void)
|
|||||||
|
|
||||||
/* Now ask what to search for. */
|
/* Now ask what to search for. */
|
||||||
response = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
|
response = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
|
||||||
browser_refresh, "%s%s", _("Search"), thedefault);
|
browser_refresh, "%s%s%s", _("Search"),
|
||||||
|
!forwards ? _(" [Backwards]") : "", thedefault);
|
||||||
free(thedefault);
|
free(thedefault);
|
||||||
|
|
||||||
/* If only Enter was pressed but we have a previous string, it's okay. */
|
/* If only Enter was pressed but we have a previous string, it's okay. */
|
||||||
@ -752,11 +754,12 @@ void findfile(const char *needle, bool forwards)
|
|||||||
selected = looking_at;
|
selected = looking_at;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for a filename. */
|
/* Search for a filename. If forwards is TRUE, search forward in the list;
|
||||||
void do_filesearch(void)
|
* otherwise, search backward.*/
|
||||||
|
void do_filesearch(bool forwards)
|
||||||
{
|
{
|
||||||
/* If the user cancelled or jumped to first or last file, don't search. */
|
/* If the user cancelled or jumped to first or last file, don't search. */
|
||||||
if (filesearch_init() != 0)
|
if (filesearch_init(forwards) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If answer is now "", copy last_search into answer. */
|
/* If answer is now "", copy last_search into answer. */
|
||||||
@ -771,7 +774,7 @@ void do_filesearch(void)
|
|||||||
update_history(&search_history, answer);
|
update_history(&search_history, answer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
findfile(answer, TRUE);
|
findfile(answer, forwards);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search again without prompting for the last given search string,
|
/* Search again without prompting for the last given search string,
|
||||||
|
18
src/global.c
18
src/global.c
@ -503,6 +503,7 @@ void shortcut_init(void)
|
|||||||
{
|
{
|
||||||
const char *readfile_tag = N_("Read File");
|
const char *readfile_tag = N_("Read File");
|
||||||
const char *whereis_tag = N_("Where Is");
|
const char *whereis_tag = N_("Where Is");
|
||||||
|
const char *wherewas_tag = N_("Where Was");
|
||||||
const char *replace_tag = N_("Replace");
|
const char *replace_tag = N_("Replace");
|
||||||
const char *gotoline_tag = N_("Go To Line");
|
const char *gotoline_tag = N_("Go To Line");
|
||||||
const char *prevline_tag = N_("Prev Line");
|
const char *prevline_tag = N_("Prev Line");
|
||||||
@ -533,7 +534,8 @@ void shortcut_init(void)
|
|||||||
const char *wherewas_gist =
|
const char *wherewas_gist =
|
||||||
N_("Search backward for a string or a regular expression");
|
N_("Search backward for a string or a regular expression");
|
||||||
#ifdef ENABLE_BROWSER
|
#ifdef ENABLE_BROWSER
|
||||||
const char *browserwhereis_gist = N_("Search for a string");
|
const char *browserwhereis_gist = N_("Search forward for a string");
|
||||||
|
const char *browserwherewas_gist = N_("Search backward for a string");
|
||||||
const char *browserrefresh_gist = N_("Refresh the file list");
|
const char *browserrefresh_gist = N_("Refresh the file list");
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
const char *browserlefthand_gist = N_("Go to lefthand column");
|
const char *browserlefthand_gist = N_("Go to lefthand column");
|
||||||
@ -738,12 +740,6 @@ void shortcut_init(void)
|
|||||||
replace_tag, WITHORSANS(replace_gist), TOGETHER, NOVIEW);
|
replace_tag, WITHORSANS(replace_gist), TOGETHER, NOVIEW);
|
||||||
|
|
||||||
#ifdef ENABLE_BROWSER
|
#ifdef ENABLE_BROWSER
|
||||||
add_to_funcs(do_search_forward, MBROWSER,
|
|
||||||
whereis_tag, WITHORSANS(browserwhereis_gist), TOGETHER, VIEW);
|
|
||||||
|
|
||||||
add_to_funcs(do_research, MBROWSER,
|
|
||||||
whereisnext_tag, WITHORSANS(whereisnext_gist), BLANKAFTER, VIEW);
|
|
||||||
|
|
||||||
add_to_funcs(goto_dir_void, MBROWSER,
|
add_to_funcs(goto_dir_void, MBROWSER,
|
||||||
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
|
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
|
||||||
|
|
||||||
@ -841,7 +837,13 @@ void shortcut_init(void)
|
|||||||
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
|
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
add_to_funcs(do_search_backward, MMAIN|MHELP|MBROWSER,
|
#ifdef ENABLE_BROWSER
|
||||||
|
add_to_funcs(do_search_forward, MBROWSER,
|
||||||
|
whereis_tag, WITHORSANS(browserwhereis_gist), TOGETHER, VIEW);
|
||||||
|
add_to_funcs(do_search_backward, MBROWSER,
|
||||||
|
wherewas_tag, WITHORSANS(browserwherewas_gist), TOGETHER, VIEW);
|
||||||
|
#endif
|
||||||
|
add_to_funcs(do_search_backward, MMAIN|MHELP,
|
||||||
/* TRANSLATORS: This starts a backward search. */
|
/* TRANSLATORS: This starts a backward search. */
|
||||||
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
|
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
|
||||||
add_to_funcs(do_findprevious, MMAIN|MHELP|MBROWSER,
|
add_to_funcs(do_findprevious, MMAIN|MHELP|MBROWSER,
|
||||||
|
@ -190,7 +190,7 @@ void read_the_list(const char *path, DIR *dir);
|
|||||||
functionptrtype parse_browser_input(int *kbinput);
|
functionptrtype parse_browser_input(int *kbinput);
|
||||||
void browser_refresh(void);
|
void browser_refresh(void);
|
||||||
void browser_select_dirname(const char *needle);
|
void browser_select_dirname(const char *needle);
|
||||||
void do_filesearch(void);
|
void do_filesearch(bool forwards);
|
||||||
void do_fileresearch(bool forwards);
|
void do_fileresearch(bool forwards);
|
||||||
void to_first_file(void);
|
void to_first_file(void);
|
||||||
void to_last_file(void);
|
void to_last_file(void);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user