tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER

Also, allow Ctrl+Left/Right with --enable-tiny --enable-browser.
master
Benno Schulenberg 2017-05-08 19:08:23 +02:00
parent a33a4f00e5
commit dc3610fc8e
8 changed files with 41 additions and 39 deletions

View File

@ -64,8 +64,15 @@ dnl Checks for options.
AC_ARG_ENABLE(browser, AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser])) AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
if test "x$enable_browser" = xno; then if test "x$enable_tiny" = xyes; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.]) if test "x$enable_browser" != xyes; then
enable_browser=no
fi
fi
if test "x$disable_browser" != xyes; then
if test "x$enable_browser" != xno; then
AC_DEFINE(ENABLE_BROWSER, 1, [Define this to enable the built-in file browser.])
fi
fi fi
AC_ARG_ENABLE(color, AC_ARG_ENABLE(color,
@ -249,9 +256,6 @@ AC_ARG_ENABLE(tiny,
AS_HELP_STRING([--enable-tiny], [Disable features for the sake of size])) AS_HELP_STRING([--enable-tiny], [Disable features for the sake of size]))
if test "x$enable_tiny" = xyes; then if test "x$enable_tiny" = xyes; then
AC_DEFINE(NANO_TINY, 1, [Define this to make the nano executable as small as possible.]) AC_DEFINE(NANO_TINY, 1, [Define this to make the nano executable as small as possible.])
if test "x$enable_browser" != xyes; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
fi
if test "x$enable_color" != xyes; then if test "x$enable_color" != xyes; then
AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.]) AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
color_support=no color_support=no

View File

@ -27,7 +27,7 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
static char **filelist = NULL; static char **filelist = NULL;
/* The list of files to display in the file browser. */ /* The list of files to display in the file browser. */
@ -183,14 +183,12 @@ char *do_browser(char *path)
} else if (func == do_right) { } else if (func == do_right) {
if (selected < filelist_len - 1) if (selected < filelist_len - 1)
selected++; selected++;
#ifndef NANO_TINY
} else if (func == do_prev_word_void) { } else if (func == do_prev_word_void) {
selected -= (selected % width); selected -= (selected % width);
} else if (func == do_next_word_void) { } else if (func == do_next_word_void) {
selected += width - 1 - (selected % width); selected += width - 1 - (selected % width);
if (selected >= filelist_len) if (selected >= filelist_len)
selected = filelist_len - 1; selected = filelist_len - 1;
#endif
} else if (func == do_up_void) { } else if (func == do_up_void) {
if (selected >= width) if (selected >= width)
selected -= width; selected -= width;
@ -812,4 +810,4 @@ char *strip_last_component(const char *path)
return copy; return copy;
} }
#endif /* !DISABLE_BROWSER */ #endif /* ENABLE_BROWSER */

View File

@ -1106,7 +1106,7 @@ void do_insertfile(void)
} else { } else {
ssize_t was_current_lineno = openfile->current->lineno; ssize_t was_current_lineno = openfile->current->lineno;
size_t was_current_x = openfile->current_x; size_t was_current_x = openfile->current_x;
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER) || defined(ENABLE_MULTIBUFFER) #if !defined(NANO_TINY) || defined(ENABLE_BROWSER) || defined(ENABLE_MULTIBUFFER)
functionptrtype func = func_from_key(&i); functionptrtype func = func_from_key(&i);
#endif #endif
given = mallocstrcpy(given, answer); given = mallocstrcpy(given, answer);
@ -1127,7 +1127,7 @@ void do_insertfile(void)
continue; continue;
} }
#endif #endif
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
if (func == to_files_void) { if (func == to_files_void) {
char *chosen = do_browse_from(answer); char *chosen = do_browse_from(answer);
@ -2173,7 +2173,7 @@ int do_writeout(bool exiting)
given = mallocstrcpy(given, answer); given = mallocstrcpy(given, answer);
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
if (func == to_files_void) { if (func == to_files_void) {
char *chosen = do_browse_from(answer); char *chosen = do_browse_from(answer);
@ -2184,7 +2184,7 @@ int do_writeout(bool exiting)
free(answer); free(answer);
answer = chosen; answer = chosen;
} else } else
#endif /* !DISABLE_BROWSER */ #endif
#ifndef NANO_TINY #ifndef NANO_TINY
if (func == dos_format_void) { if (func == dos_format_void) {
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE : openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE :
@ -2385,7 +2385,7 @@ char *real_dir_from_tilde(const char *buf)
return retval; return retval;
} }
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER) #if !defined(DISABLE_TABCOMP) || defined(ENABLE_BROWSER)
/* Our sort routine for file listings. Sort alphabetically and /* Our sort routine for file listings. Sort alphabetically and
* case-insensitively, and sort directories before filenames. */ * case-insensitively, and sort directories before filenames. */
int diralphasort(const void *va, const void *vb) int diralphasort(const void *va, const void *vb)

View File

@ -272,7 +272,7 @@ void flip_replace(void)
void gototext_void(void) void gototext_void(void)
{ {
} }
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
void to_files_void(void) void to_files_void(void)
{ {
} }
@ -513,7 +513,7 @@ 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");
#ifndef DISABLE_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");
#ifndef NANO_TINY #ifndef NANO_TINY
@ -623,7 +623,7 @@ void shortcut_init(void)
const char *nano_next_history_msg = const char *nano_next_history_msg =
N_("Recall the next search/replace string"); N_("Recall the next search/replace string");
#endif #endif
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
const char *nano_tofiles_msg = N_("Go to file browser"); const char *nano_tofiles_msg = N_("Go to file browser");
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
@ -638,7 +638,7 @@ void shortcut_init(void)
#endif #endif
#endif #endif
const char *nano_discard_buffer_msg = N_("Close buffer without saving it"); const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
const char *nano_exitbrowser_msg = N_("Exit from the file browser"); const char *nano_exitbrowser_msg = N_("Exit from the file browser");
const char *nano_firstfile_msg = N_("Go to the first file in the list"); const char *nano_firstfile_msg = N_("Go to the first file in the list");
const char *nano_lastfile_msg = N_("Go to the last file in the list"); const char *nano_lastfile_msg = N_("Go to the last file in the list");
@ -676,7 +676,7 @@ void shortcut_init(void)
/* Remember the entry for Exit, to be able to replace it with Close. */ /* Remember the entry for Exit, to be able to replace it with Close. */
exitfunc = tailfunc; exitfunc = tailfunc;
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
add_to_funcs(do_exit, MBROWSER, add_to_funcs(do_exit, MBROWSER,
exit_tag, IFSCHELP(nano_exitbrowser_msg), TOGETHER, VIEW); exit_tag, IFSCHELP(nano_exitbrowser_msg), TOGETHER, VIEW);
#endif #endif
@ -713,7 +713,7 @@ void shortcut_init(void)
add_to_funcs(do_replace, MMAIN, add_to_funcs(do_replace, MMAIN,
replace_tag, IFSCHELP(nano_replace_msg), TOGETHER, NOVIEW); replace_tag, IFSCHELP(nano_replace_msg), TOGETHER, NOVIEW);
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
add_to_funcs(do_search, MBROWSER, add_to_funcs(do_search, MBROWSER,
whereis_tag, IFSCHELP(nano_browser_whereis_msg), TOGETHER, VIEW); whereis_tag, IFSCHELP(nano_browser_whereis_msg), TOGETHER, VIEW);
@ -824,7 +824,7 @@ void shortcut_init(void)
N_("Back"), IFSCHELP(nano_back_msg), TOGETHER, VIEW); N_("Back"), IFSCHELP(nano_back_msg), TOGETHER, VIEW);
add_to_funcs(do_right, MMAIN, add_to_funcs(do_right, MMAIN,
N_("Forward"), IFSCHELP(nano_forward_msg), TOGETHER, VIEW); N_("Forward"), IFSCHELP(nano_forward_msg), TOGETHER, VIEW);
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
add_to_funcs(do_left, MBROWSER, add_to_funcs(do_left, MBROWSER,
N_("Back"), IFSCHELP(nano_backfile_msg), TOGETHER, VIEW); N_("Back"), IFSCHELP(nano_backfile_msg), TOGETHER, VIEW);
add_to_funcs(do_right, MBROWSER, add_to_funcs(do_right, MBROWSER,
@ -1009,7 +1009,7 @@ void shortcut_init(void)
N_("New Buffer"), IFSCHELP(nano_newbuffer_msg), TOGETHER, NOVIEW); N_("New Buffer"), IFSCHELP(nano_newbuffer_msg), TOGETHER, NOVIEW);
#endif #endif
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
if (!ISSET(RESTRICTED)) if (!ISSET(RESTRICTED))
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE, add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
N_("To Files"), IFSCHELP(nano_tofiles_msg), TOGETHER, VIEW); N_("To Files"), IFSCHELP(nano_tofiles_msg), TOGETHER, VIEW);
@ -1028,7 +1028,7 @@ void shortcut_init(void)
add_to_funcs(discard_buffer, MWRITEFILE, add_to_funcs(discard_buffer, MWRITEFILE,
N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW); N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW);
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
add_to_funcs(do_research, MBROWSER, add_to_funcs(do_research, MBROWSER,
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW); whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
add_to_funcs(total_refresh, MBROWSER, add_to_funcs(total_refresh, MBROWSER,
@ -1261,7 +1261,7 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Down", KEY_DOWN, get_history_newer_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Down", KEY_DOWN, get_history_newer_void, 0);
} }
#endif #endif
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0); add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0);
add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0); add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0); add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0);
@ -1295,7 +1295,7 @@ void shortcut_init(void)
if (!ISSET(RESTRICTED)) if (!ISSET(RESTRICTED))
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0); add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
#endif #endif
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
/* In restricted mode, don't allow entering the file browser. */ /* In restricted mode, don't allow entering the file browser. */
if (!ISSET(RESTRICTED)) if (!ISSET(RESTRICTED))
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0); add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
@ -1303,7 +1303,7 @@ void shortcut_init(void)
add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0); add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0);
/* Allow exiting from the file browser and the help viewer with /* Allow exiting from the file browser and the help viewer with
* the same key as they were entered. */ * the same key as they were entered. */
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
add_to_sclist(MBROWSER, "^T", 0, do_exit, 0); add_to_sclist(MBROWSER, "^T", 0, do_exit, 0);
#endif #endif
#ifdef ENABLE_HELP #ifdef ENABLE_HELP
@ -1608,7 +1608,7 @@ sc *strtosc(const char *input)
!strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */ !strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */
s->scfunc = flip_newbuffer; s->scfunc = flip_newbuffer;
#endif #endif
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
else if (!strcasecmp(input, "tofiles") || else if (!strcasecmp(input, "tofiles") ||
!strcasecmp(input, "browser")) !strcasecmp(input, "browser"))
s->scfunc = to_files_void; s->scfunc = to_files_void;
@ -1707,7 +1707,7 @@ int strtomenu(const char *input)
#endif #endif
else if (!strcasecmp(input, "linter")) else if (!strcasecmp(input, "linter"))
return MLINTER; return MLINTER;
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
else if (!strcasecmp(input, "browser")) else if (!strcasecmp(input, "browser"))
return MBROWSER; return MBROWSER;
else if (!strcasecmp(input, "whereisfile")) else if (!strcasecmp(input, "whereisfile"))

View File

@ -271,7 +271,7 @@ void do_help(void)
title = NULL; title = NULL;
inhelp = FALSE; inhelp = FALSE;
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR) if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh(); browser_refresh();
else else
@ -353,7 +353,7 @@ void help_init(void)
htx[1] = NULL; htx[1] = NULL;
htx[2] = NULL; htx[2] = NULL;
} }
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
else if (currmenu == MBROWSER) { else if (currmenu == MBROWSER) {
htx[0] = N_("File Browser Help Text\n\n " htx[0] = N_("File Browser Help Text\n\n "
"The file browser is used to visually browse the " "The file browser is used to visually browse the "
@ -391,7 +391,7 @@ void help_init(void)
htx[1] = NULL; htx[1] = NULL;
htx[2] = NULL; htx[2] = NULL;
} }
#endif /* !DISABLE_BROWSER */ #endif /* ENABLE_BROWSER */
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
else if (currmenu == MSPELL) { else if (currmenu == MSPELL) {
htx[0] = N_("Spell Check Help Text\n\n " htx[0] = N_("Spell Check Help Text\n\n "

View File

@ -848,7 +848,7 @@ void usage(void)
print_opt("-c", "--constantshow", N_("Constantly show cursor position")); print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete", print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem")); N_("Fix Backspace/Delete confusion problem"));
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
if (!ISSET(RESTRICTED)) if (!ISSET(RESTRICTED))
print_opt("-g", "--showcursor", N_("Show cursor in file browser")); print_opt("-g", "--showcursor", N_("Show cursor in file browser"));
#endif #endif
@ -916,7 +916,7 @@ void version(void)
#ifdef NANO_TINY #ifdef NANO_TINY
printf(" --enable-tiny"); printf(" --enable-tiny");
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
printf(" --enable-browser"); printf(" --enable-browser");
#endif #endif
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
@ -962,7 +962,7 @@ void version(void)
printf(" --enable-wrapping"); printf(" --enable-wrapping");
#endif #endif
#else /* !NANO_TINY */ #else /* !NANO_TINY */
#ifdef DISABLE_BROWSER #ifndef ENABLE_BROWSER
printf(" --disable-browser"); printf(" --disable-browser");
#endif #endif
#ifdef DISABLE_COLOR #ifdef DISABLE_COLOR
@ -1935,7 +1935,7 @@ int main(int argc, char **argv)
#endif #endif
{"constantshow", 0, NULL, 'c'}, {"constantshow", 0, NULL, 'c'},
{"rebinddelete", 0, NULL, 'd'}, {"rebinddelete", 0, NULL, 'd'},
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
{"showcursor", 0, NULL, 'g'}, {"showcursor", 0, NULL, 'g'},
#endif #endif
{"help", 0, NULL, 'h'}, {"help", 0, NULL, 'h'},

View File

@ -176,7 +176,7 @@ extern char *homedir;
typedef void (*functionptrtype)(void); typedef void (*functionptrtype)(void);
/* Most functions in browser.c. */ /* Most functions in browser.c. */
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
char *do_browse_from(const char *inpath); char *do_browse_from(const char *inpath);
void read_the_list(const char *path, DIR *dir); void read_the_list(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput); functionptrtype parse_browser_input(int *kbinput);
@ -304,7 +304,7 @@ void do_writeout_void(void);
void do_savefile(void); void do_savefile(void);
#endif #endif
char *real_dir_from_tilde(const char *buf); char *real_dir_from_tilde(const char *buf);
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER) #if !defined(DISABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb); int diralphasort(const void *va, const void *vb);
void free_chararray(char **array, size_t len); void free_chararray(char **array, size_t len);
#endif #endif
@ -690,7 +690,7 @@ void regexp_void(void);
void backwards_void(void); void backwards_void(void);
void flip_replace(void); void flip_replace(void);
void gototext_void(void); void gototext_void(void);
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
void to_files_void(void); void to_files_void(void);
void goto_dir_void(void); void goto_dir_void(void);
#endif #endif

View File

@ -1989,7 +1989,7 @@ void titlebar(const char *path)
/* Figure out the path, prefix and state strings. */ /* Figure out the path, prefix and state strings. */
if (inhelp) if (inhelp)
branding = ""; branding = "";
#ifndef DISABLE_BROWSER #ifdef ENABLE_BROWSER
else if (path != NULL) else if (path != NULL)
prefix = _("DIR:"); prefix = _("DIR:");
#endif #endif