Now delete these case-sensitive, regular-expressive and backwards

file-searching capabilities again and all provisions for them.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5048 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-07-01 16:24:01 +00:00
parent 4947ad83cb
commit b095725429
3 changed files with 26 additions and 101 deletions

View File

@ -8,9 +8,11 @@
* src/prompt.c (do_prompt, get_prompt_string): Don't pass the * src/prompt.c (do_prompt, get_prompt_string): Don't pass the
menu, just set it earlier. menu, just set it earlier.
* src/prompt.c (get_prompt_string): Group the arguments better. * src/prompt.c (get_prompt_string): Group the arguments better.
* src/global.c (shortcut_init), src/browser(do_filesearch): Show * src/global.c (shortcut_init), src/browser.c (do_filesearch):
that it is possible to have case-sensitive, regular-expressive, Show that it is possible to have backwards, regular-expressive
and backwards searching in the file browser. and case-sensitive searching in the file browser.
* src/browser.c (filesearch_init, do_filesearch): Now delete
these abilities again and all provisions for them.
2014-06-30 Mark Majeres <mark@engine12.com> 2014-06-30 Mark Majeres <mark@engine12.com>
* src/cut.c, src/global.c, src/nano.c: Rename 'cut_till_end' to * src/cut.c, src/global.c, src/nano.c: Rename 'cut_till_end' to

View File

@ -736,7 +736,6 @@ int filesearch_init(void)
{ {
int i = 0; int i = 0;
char *buf; char *buf;
const sc *s;
static char *backupstring = NULL; static char *backupstring = NULL;
/* The search string we'll be using. */ /* The search string we'll be using. */
@ -772,19 +771,7 @@ int filesearch_init(void)
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
&search_history, &search_history,
#endif #endif
browser_refresh, "%s%s%s%s%s", _("Search"), browser_refresh, "%s%s", _("Search"), buf);
#ifndef NANO_TINY
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") :
#endif
"",
#ifdef HAVE_REGEX_H
ISSET(USE_REGEXP) ? _(" [Regexp]") :
#endif
"",
#ifndef NANO_TINY
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") :
#endif
"", buf);
/* Release buf now that we don't need it anymore. */ /* Release buf now that we don't need it anymore. */
free(buf); free(buf);
@ -797,36 +784,6 @@ int filesearch_init(void)
*answer == '\0')) { *answer == '\0')) {
statusbar(_("Cancelled")); statusbar(_("Cancelled"));
return -1; return -1;
} else {
s = get_shortcut(&i);
if (i == -2 || i == 0) {
#ifdef HAVE_REGEX_H
/* Use last_search if answer is an empty string, or
* answer if it isn't. */
if (ISSET(USE_REGEXP) && !regexp_init((i == -2) ?
last_search : answer))
return -1;
#endif
} else
#ifndef NANO_TINY
if (s && s->scfunc == case_sens_void) {
TOGGLE(CASE_SENSITIVE);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (s && s->scfunc == backwards_void) {
TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else
#endif
#ifdef HAVE_REGEX_H
if (s && s->scfunc == regexp_void) {
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else
#endif
return -1;
} }
return 0; return 0;
@ -845,11 +802,6 @@ bool findnextfile(bool no_sameline, size_t begin, const char *needle)
/* The filename we display, minus the path. */ /* The filename we display, minus the path. */
const char *rev_start = filetail, *found = NULL; const char *rev_start = filetail, *found = NULL;
#ifndef NANO_TINY
if (ISSET(BACKWARDS_SEARCH))
rev_start += strlen(rev_start);
#endif
/* Look for needle in the current filename we're searching. */ /* Look for needle in the current filename we're searching. */
while (TRUE) { while (TRUE) {
found = strstrwrapper(filetail, needle, rev_start); found = strstrwrapper(filetail, needle, rev_start);
@ -866,27 +818,14 @@ bool findnextfile(bool no_sameline, size_t begin, const char *needle)
return FALSE; return FALSE;
} }
/* Move to the previous or next filename in the list. If we've /* Move to the next filename in the list. If we've reached the
* reached the start or end of the list, wrap around. */ * end of the list, wrap around. */
#ifndef NANO_TINY if (currselected < filelist_len - 1)
if (ISSET(BACKWARDS_SEARCH)) { currselected++;
if (currselected > 0) else {
currselected--; currselected = 0;
else { statusbar(_("Search Wrapped"));
currselected = filelist_len - 1;
statusbar(_("Search Wrapped"));
}
} else {
#endif
if (currselected < filelist_len - 1)
currselected++;
else {
currselected = 0;
statusbar(_("Search Wrapped"));
}
#ifndef NANO_TINY
} }
#endif
/* We've reached the original starting file. */ /* We've reached the original starting file. */
if (currselected == begin) if (currselected == begin)
@ -895,10 +834,6 @@ bool findnextfile(bool no_sameline, size_t begin, const char *needle)
filetail = tail(filelist[currselected]); filetail = tail(filelist[currselected]);
rev_start = filetail; rev_start = filetail;
#ifndef NANO_TINY
if (ISSET(BACKWARDS_SEARCH))
rev_start += strlen(rev_start);
#endif
} }
/* We've definitely found something. */ /* We've definitely found something. */
@ -915,34 +850,28 @@ void findnextfile_wrap_reset(void)
} }
/* Abort the current filename search. Clean up by setting the current /* Abort the current filename search. Clean up by setting the current
* shortcut list to the browser shortcut list, displaying it, and * shortcut list to the browser shortcut list, and displaying it. */
* decompiling the compiled regular expression we used in the last
* search, if any. */
void filesearch_abort(void) void filesearch_abort(void)
{ {
currmenu = MBROWSER; currmenu = MBROWSER;
bottombars(MBROWSER); bottombars(MBROWSER);
#ifdef HAVE_REGEX_H
regexp_cleanup();
#endif
} }
/* Search for a filename. */ /* Search for a filename. */
void do_filesearch(void) void do_filesearch(void)
{ {
size_t begin = selected; size_t begin = selected;
int i;
bool didfind; bool didfind;
do i = filesearch_init(); UNSET(CASE_SENSITIVE);
while (i == 1); UNSET(USE_REGEXP);
UNSET(BACKWARDS_SEARCH);
if (i == -1) /* Cancel, blank search string, or regcomp() if (filesearch_init() != 0) {
* failed. */ /* Cancelled or a blank search string. */
filesearch_abort(); filesearch_abort();
if (i != 0)
return; return;
}
/* If answer is now "", copy last_search into answer. */ /* If answer is now "", copy last_search into answer. */
if (*answer == '\0') if (*answer == '\0')
@ -983,12 +912,6 @@ void do_fileresearch(void)
search_init_globals(); search_init_globals();
if (last_search[0] != '\0') { if (last_search[0] != '\0') {
#ifdef HAVE_REGEX_H
/* Since answer is "", use last_search! */
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return;
#endif
findnextfile_wrap_reset(); findnextfile_wrap_reset();
didfind = findnextfile(FALSE, begin, answer); didfind = findnextfile(FALSE, begin, answer);

View File

@ -733,17 +733,17 @@ void shortcut_init(void)
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE|MWHEREISFILE, add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
N_("Case Sens"), IFSCHELP(nano_case_msg), FALSE, VIEW); N_("Case Sens"), IFSCHELP(nano_case_msg), FALSE, VIEW);
#endif #endif
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
add_to_funcs(regexp_void, MWHEREIS|MREPLACE|MWHEREISFILE, add_to_funcs(regexp_void, MWHEREIS|MREPLACE,
N_("Regexp"), IFSCHELP(nano_regexp_msg), FALSE, VIEW); N_("Regexp"), IFSCHELP(nano_regexp_msg), FALSE, VIEW);
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
add_to_funcs(backwards_void, MWHEREIS|MREPLACE|MWHEREISFILE, add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
N_("Backwards"), IFSCHELP(nano_reverse_msg), FALSE, VIEW); N_("Backwards"), IFSCHELP(nano_reverse_msg), FALSE, VIEW);
#endif #endif
@ -1117,10 +1117,10 @@ void shortcut_init(void)
add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", do_cancel, 0); add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", do_cancel, 0);
#ifndef NANO_TINY #ifndef NANO_TINY
add_to_sclist(MWHEREIS|MREPLACE|MWHEREISFILE, "M-B", backwards_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "M-B", backwards_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MWHEREISFILE, "M-C", case_sens_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "M-C", case_sens_void, 0);
#endif #endif
add_to_sclist(MWHEREIS|MREPLACE|MWHEREISFILE, "M-R", regexp_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "M-R", regexp_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "^R", flip_replace_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "^R", flip_replace_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", do_first_line, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", do_first_line, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", do_last_line, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", do_last_line, 0);