* src/prompt.c (do_prompt, get_prompt_string): Don't pass the
menu, just set it earlier.
* src/prompt.c (get_prompt_string): Group the arguments better.
- * src/global.c (shortcut_init), src/browser(do_filesearch): Show
- that it is possible to have case-sensitive, regular-expressive,
- and backwards searching in the file browser.
+ * src/global.c (shortcut_init), src/browser.c (do_filesearch):
+ Show that it is possible to have backwards, regular-expressive
+ 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>
* src/cut.c, src/global.c, src/nano.c: Rename 'cut_till_end' to
{
int i = 0;
char *buf;
- const sc *s;
static char *backupstring = NULL;
/* The search string we'll be using. */
#ifndef DISABLE_HISTORIES
&search_history,
#endif
- browser_refresh, "%s%s%s%s%s", _("Search"),
-#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);
+ browser_refresh, "%s%s", _("Search"), buf);
/* Release buf now that we don't need it anymore. */
free(buf);
*answer == '\0')) {
statusbar(_("Cancelled"));
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;
/* The filename we display, minus the path. */
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. */
while (TRUE) {
found = strstrwrapper(filetail, needle, rev_start);
return FALSE;
}
- /* Move to the previous or next filename in the list. If we've
- * reached the start or end of the list, wrap around. */
-#ifndef NANO_TINY
- if (ISSET(BACKWARDS_SEARCH)) {
- if (currselected > 0)
- currselected--;
- else {
- currselected = filelist_len - 1;
- statusbar(_("Search Wrapped"));
- }
- } else {
-#endif
- if (currselected < filelist_len - 1)
- currselected++;
- else {
- currselected = 0;
- statusbar(_("Search Wrapped"));
- }
-#ifndef NANO_TINY
+ /* Move to the next filename in the list. If we've reached the
+ * end of the list, wrap around. */
+ if (currselected < filelist_len - 1)
+ currselected++;
+ else {
+ currselected = 0;
+ statusbar(_("Search Wrapped"));
}
-#endif
/* We've reached the original starting file. */
if (currselected == begin)
filetail = tail(filelist[currselected]);
rev_start = filetail;
-#ifndef NANO_TINY
- if (ISSET(BACKWARDS_SEARCH))
- rev_start += strlen(rev_start);
-#endif
}
/* We've definitely found something. */
}
/* Abort the current filename search. Clean up by setting the current
- * shortcut list to the browser shortcut list, displaying it, and
- * decompiling the compiled regular expression we used in the last
- * search, if any. */
+ * shortcut list to the browser shortcut list, and displaying it. */
void filesearch_abort(void)
{
currmenu = MBROWSER;
bottombars(MBROWSER);
-#ifdef HAVE_REGEX_H
- regexp_cleanup();
-#endif
}
/* Search for a filename. */
void do_filesearch(void)
{
size_t begin = selected;
- int i;
bool didfind;
- do i = filesearch_init();
- while (i == 1);
+ UNSET(CASE_SENSITIVE);
+ UNSET(USE_REGEXP);
+ UNSET(BACKWARDS_SEARCH);
- if (i == -1) /* Cancel, blank search string, or regcomp()
- * failed. */
+ if (filesearch_init() != 0) {
+ /* Cancelled or a blank search string. */
filesearch_abort();
-
- if (i != 0)
return;
+ }
/* If answer is now "", copy last_search into answer. */
if (*answer == '\0')
search_init_globals();
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();
didfind = findnextfile(FALSE, begin, answer);
#endif
#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);
#endif
#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);
#endif
#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);
#endif
add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", do_cancel, 0);
#ifndef NANO_TINY
- add_to_sclist(MWHEREIS|MREPLACE|MWHEREISFILE, "M-B", backwards_void, 0);
- add_to_sclist(MWHEREIS|MREPLACE|MWHEREISFILE, "M-C", case_sens_void, 0);
+ add_to_sclist(MWHEREIS|MREPLACE, "M-B", backwards_void, 0);
+ add_to_sclist(MWHEREIS|MREPLACE, "M-C", case_sens_void, 0);
#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|MREPLACEWITH|MGOTOLINE, "^Y", do_first_line, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", do_last_line, 0);