tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE

Also, trim some comments and avoid an unused-variable warning.
master
Benno Schulenberg 2017-05-01 20:45:07 +02:00
parent 9c3a149b14
commit 5033cfd81a
10 changed files with 45 additions and 46 deletions

View File

@ -160,8 +160,15 @@ fi
AC_ARG_ENABLE(mouse,
AS_HELP_STRING([--disable-mouse], [Disable mouse support]))
if test "x$enable_mouse" = xno; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable mouse support.])
if test "x$enable_tiny" = xyes; then
if test "x$enable_mouse" != xyes; then
enable_mouse=no
fi
fi
if test "x$disable_mouse" != xyes; then
if test "x$enable_mouse" != xno; then
AC_DEFINE(ENABLE_MOUSE, 1, [Define this to enable mouse support.])
fi
fi
AC_ARG_ENABLE(multibuffer,
@ -265,9 +272,6 @@ if test "x$enable_tiny" = xyes; then
if test "x$enable_libmagic" != xyes; then
enable_libmagic=no
fi
if test "x$enable_mouse" != xyes; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable mouse support.])
fi
if test "x$enable_nanorc" != xyes; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
fi

View File

@ -122,7 +122,7 @@ char *do_browser(char *path)
kbinput = get_kbinput(edit);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
@ -151,7 +151,7 @@ char *do_browser(char *path)
continue;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
func = parse_browser_input(&kbinput);

View File

@ -1216,7 +1216,7 @@ void shortcut_init(void)
#ifdef ENABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
#endif
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
@ -1646,7 +1646,7 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "multibuffer"))
s->toggle = MULTIBUFFER;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
else if (!strcasecmp(input, "mouse"))
s->toggle = USE_MOUSE;
#endif

View File

@ -217,7 +217,7 @@ void do_help(void)
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_x, dummy_y;
get_mouseinput(&dummy_x, &dummy_y, TRUE);

View File

@ -41,7 +41,7 @@
#include <sys/ioctl.h>
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
static int oldinterval = -1;
/* Used to store the user's original mouse click interval. */
#endif
@ -723,23 +723,20 @@ void window_init(void)
#endif
}
#ifndef DISABLE_MOUSE
/* Disable mouse support. */
#ifdef ENABLE_MOUSE
void disable_mouse_support(void)
{
mousemask(0, NULL);
mouseinterval(oldinterval);
}
/* Enable mouse support. */
void enable_mouse_support(void)
{
mousemask(ALL_MOUSE_EVENTS, NULL);
oldinterval = mouseinterval(50);
}
/* Initialize mouse support. Enable it if the USE_MOUSE flag is set,
* and disable it otherwise. */
/* Switch mouse support on or off, as needed. */
void mouse_init(void)
{
if (ISSET(USE_MOUSE))
@ -747,7 +744,7 @@ void mouse_init(void)
else
disable_mouse_support();
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* Print one usage string to the screen. This cuts down on duplicate
* strings to translate, and leaves out the parts that shouldn't be
@ -863,7 +860,7 @@ void usage(void)
#ifdef ENABLE_LINENUMBERS
print_opt("-l", "--linenumbers", N_("Show line numbers in front of the text"));
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
#endif
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
@ -943,7 +940,7 @@ void version(void)
#ifdef ENABLE_LINENUMBERS
printf(" --enable-linenumbers");
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
printf(" --enable-mouse");
#endif
#ifndef DISABLE_NANORC
@ -992,7 +989,7 @@ void version(void)
#ifndef ENABLE_LINENUMBERS
printf(" --disable-linenumbers");
#endif
#ifdef DISABLE_MOUSE
#ifndef ENABLE_MOUSE
printf(" --disable-mouse");
#endif
#ifndef ENABLE_MULTIBUFFER
@ -1228,8 +1225,7 @@ RETSIGTYPE handle_hupterm(int signal)
/* Handler for SIGTSTP (suspend). */
RETSIGTYPE do_suspend(int signal)
{
#ifndef DISABLE_MOUSE
/* Turn mouse support off. */
#ifdef ENABLE_MOUSE
disable_mouse_support();
#endif
@ -1272,8 +1268,7 @@ void do_suspend_void(void)
/* Handler for SIGCONT (continue after suspend). */
RETSIGTYPE do_continue(int signal)
{
#ifndef DISABLE_MOUSE
/* Turn mouse support back on if it was on before. */
#ifdef ENABLE_MOUSE
if (ISSET(USE_MOUSE))
enable_mouse_support();
#endif
@ -1383,7 +1378,7 @@ void do_toggle(int flag)
TOGGLE(flag);
switch (flag) {
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
case USE_MOUSE:
mouse_init();
break;
@ -1589,7 +1584,7 @@ int do_input(bool allow_funcs)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
if (input == KEY_MOUSE) {
/* We received a mouse click. */
if (do_mouse() == 1)
@ -1744,7 +1739,7 @@ void xoff_complaint(void)
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the edit window or the shortcut list. */
int do_mouse(void)
{
@ -1757,13 +1752,13 @@ int do_mouse(void)
/* If the click was in the edit window, put the cursor in that spot. */
if (wmouse_trafo(edit, &mouse_row, &mouse_col, FALSE)) {
bool sameline = (mouse_row == openfile->current_y);
/* Whether the click was on the row where the cursor is. */
filestruct *current_save = openfile->current;
ssize_t row_count = mouse_row - openfile->current_y;
size_t leftedge;
#ifndef NANO_TINY
size_t current_x_save = openfile->current_x;
bool sameline = (mouse_row == openfile->current_y);
/* Whether the click was on the row where the cursor is. */
if (ISSET(SOFTWRAP))
leftedge = (xplustabs() / editwincols) * editwincols;
@ -1800,7 +1795,7 @@ int do_mouse(void)
/* No more handling is needed. */
return 2;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* The user typed output_len multibyte characters. Add them to the edit
* buffer, filtering out all ASCII control characters if allow_cntrls is
@ -1946,7 +1941,7 @@ int main(int argc, char **argv)
#ifdef ENABLE_LINENUMBERS
{"linenumbers", 0, NULL, 'l'},
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
{"mouse", 0, NULL, 'm'},
#endif
{"noread", 0, NULL, 'n'},
@ -2154,7 +2149,7 @@ int main(int argc, char **argv)
SET(CUT_TO_END);
break;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
case 'm':
SET(USE_MOUSE);
break;
@ -2489,7 +2484,7 @@ int main(int argc, char **argv)
/* Set up the signal handlers. */
signal_init();
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Initialize mouse support. */
mouse_init();
#endif

View File

@ -124,10 +124,10 @@
#include <signal.h>
#include <assert.h>
/* If we aren't using ncurses with mouse support, turn the mouse support
* off, as it's useless then. */
/* If we aren't using an ncurses with mouse support, exclude any
* mouse routines, as they are useless then. */
#ifndef NCURSES_MOUSE_VERSION
#define DISABLE_MOUSE 1
#undef ENABLE_MOUSE
#endif
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)

View File

@ -57,7 +57,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* If we got a mouse click and it was on a shortcut, read in the
* shortcut character. */
if (input == KEY_MOUSE) {
@ -164,7 +164,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return input;
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
int do_statusbar_mouse(void)
{
@ -739,7 +739,7 @@ int do_yesno_prompt(bool all, const char *msg)
if (func == do_cancel)
response = -1;
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the Yes/No/All shortcuts to select an answer. */
@ -761,7 +761,7 @@ int do_yesno_prompt(bool all, const char *msg)
response = -2;
}
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
else {
/* Look for the kbinput in the Yes, No (and All) strings. */
if (strchr(yesstr, kbinput) != NULL)

View File

@ -428,13 +428,13 @@ void enable_flow_control(void);
void terminal_init(void);
void unbound_key(int code);
int do_input(bool allow_funcs);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int do_mouse(void);
#endif
void do_output(char *output, size_t output_len, bool allow_cntrls);
/* Most functions in prompt.c. */
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int do_statusbar_mouse(void);
#endif
void do_statusbar_output(int *the_input, size_t input_len,
@ -631,7 +631,7 @@ int get_byte_kbinput(int kbinput);
int get_control_kbinput(int kbinput);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
#endif
const sc *get_shortcut(int *kbinput);

View File

@ -53,7 +53,7 @@ static const rcoption rcopts[] = {
{"historylog", HISTORYLOG},
#endif
{"morespace", MORE_SPACE},
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
#ifdef ENABLE_MULTIBUFFER

View File

@ -1553,7 +1553,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
return get_input(NULL, *count);
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle any mouse event that may have occurred. We currently handle
* releases/clicks of the first mouse button. If allow_shortcuts is
* TRUE, releasing/clicking on a visible shortcut will put back the
@ -1707,7 +1707,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
/* Ignore all other mouse events. */
return 2;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
/* Return the shortcut that corresponds to the values of kbinput (the
* key itself) and meta_key (whether the key is a meta sequence). The