miscellaneous #define cleanups
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1565 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
diff --git a/ChangeLog b/ChangeLog
index a9e3255..f2c7fe9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -55,6 +55,11 @@
#ifdef instead of two.
- Convert memmove() function calls to charmove() macro calls, as
the former all work on char*'s. (DLR)
+ - Miscellaneous #define cleanups: only include the prototype for
+ and definition of wrap_at if wrapping and/or justification are
+ enabled, remove duplicate wrap_at prototype, and define
+ DISABLE_MOUSE if NCURSES_MOUSE_VERSION isn't defined in nano.h
+ instead of all over the code. (DLR)
- files.c:
read_file()
- After we've read in a file and possibly converted it from
diff --git a/src/files.c b/src/files.c
index b3ce36a..af19dc5 100644
--- a/src/files.c
+++ b/src/files.c
@@ -441,7 +441,7 @@
start_again: /* Goto here when the user cancels the file browser. */
#endif
-#if !defined(DISABLE_BROWSER) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = insertfile_list;
#endif
@@ -1710,7 +1710,7 @@
static int did_cred = 0;
#endif
-#if !defined(DISABLE_BROWSER) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = writefile_list;
#endif
@@ -2488,7 +2488,7 @@
int abort = 0, col = 0, selected = 0, editline = 0, width = 0;
int filecols = 0, lineno = 0;
char **filelist = (char **)NULL;
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
MEVENT mevent;
#endif
@@ -2527,7 +2527,7 @@
blank_statusbar_refresh();
-#if !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = browser_list;
#endif
@@ -2541,7 +2541,7 @@
switch (kbinput) {
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case KEY_MOUSE:
if (getmouse(&mevent) == ERR)
return retval;
diff --git a/src/global.c b/src/global.c
index 6389239..452a7b1 100644
--- a/src/global.c
+++ b/src/global.c
@@ -29,8 +29,11 @@
/* Global variables */
+#ifndef DISABLE_WRAPJUSTIFY
/* wrap_at might be set in rcfile.c or nano.c */
int wrap_at = -CHARS_FROM_EOL;/* Right justified fill value, allows resize */
+#endif
+
char *last_search = NULL; /* Last string we searched for */
char *last_replace = NULL; /* Last replacement string */
int search_last_line; /* Is this the last search line? */
@@ -129,7 +132,7 @@
char *syntaxstr = NULL;
#endif
-#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
const shortcut *currshortcut; /* Current shortcut list we're using */
#endif
@@ -225,7 +228,7 @@
*toggle_nohelp_msg, *toggle_cuttoend_msg,
*toggle_noconvert_msg, *toggle_dos_msg, *toggle_mac_msg,
*toggle_backup_msg, *toggle_smooth_msg;
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
char *toggle_mouse_msg;
#endif
#ifndef DISABLE_WRAPPING
@@ -247,7 +250,7 @@
toggle_autoindent_msg = _("Auto indent");
toggle_suspend_msg = _("Suspend");
toggle_nohelp_msg = _("Help mode");
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
toggle_mouse_msg = _("Mouse support");
#endif
toggle_cuttoend_msg = _("Cut to end");
@@ -273,7 +276,7 @@
#ifndef DISABLE_WRAPPING
toggle_init_one(TOGGLE_WRAP_KEY, toggle_wrap_msg, NO_WRAP);
#endif
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE);
#endif
toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
@@ -840,7 +843,7 @@
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
#endif
-#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = main_list;
#endif
#ifndef NANO_SMALL
diff --git a/src/nano.c b/src/nano.c
index e3b8cbd..74949f8 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -245,7 +245,7 @@
keypad(bottomwin, TRUE);
}
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
void mouse_init(void)
{
if (ISSET(USE_MOUSE)) {
@@ -664,7 +664,7 @@
print1opt("-k", "--cut", _("Let ^K cut from cursor to end of line"));
#endif
print1opt("-l", "--nofollow", _("Don't follow symbolic links, overwrite"));
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
print1opt("-m", "--mouse", _("Enable mouse"));
#endif
#ifndef DISABLE_OPERATINGDIR
@@ -720,7 +720,7 @@
#ifdef DISABLE_JUSTIFY
printf(" --disable-justify");
#endif
-#if defined(DISABLE_MOUSE) || !defined(NCURSES_MOUSE_VERSION)
+#ifdef DISABLE_MOUSE
printf(" --disable-mouse");
#endif
#ifdef DISABLE_OPERATINGDIR
@@ -887,7 +887,7 @@
}
#endif /* NANO_SMALL */
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
void do_mouse(void)
{
MEVENT mevent;
@@ -2630,7 +2630,7 @@
/* Now get a keystroke and see if it's unjustify; if not, unget the
* keystroke and return. */
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
/* If it was a mouse click, parse it with do_mouse() and it might
* become the unjustify key. Else give it back to the input stream. */
if ((i = wgetch(edit)) == KEY_MOUSE)
@@ -2985,7 +2985,7 @@
case TOGGLE_SUSPEND_KEY:
signal_init();
break;
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case TOGGLE_MOUSE_KEY:
mouse_init();
break;
@@ -3065,7 +3065,7 @@
{"const", 0, 0, 'c'},
{"rebinddelete", 0, 0, 'd'},
{"nofollow", 0, 0, 'l'},
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
{"mouse", 0, 0, 'm'},
#endif
#ifndef DISABLE_OPERATINGDIR
@@ -3218,7 +3218,7 @@
case 'l':
SET(NOFOLLOW_SYMLINKS);
break;
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case 'm':
SET(USE_MOUSE);
break;
@@ -3419,7 +3419,7 @@
#endif
window_init();
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
mouse_init();
#endif
@@ -3479,7 +3479,7 @@
if (ISSET(CONSTUPDATE))
do_cursorpos(1);
-#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = main_list;
#endif
@@ -3544,7 +3544,7 @@
shortcut key */
if (!keyhandled)
-#if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || !defined(DISABLE_MOUSE)
for (s = currshortcut; s != NULL && !keyhandled; s = s->next) {
#else
for (s = main_list; s != NULL && !keyhandled; s = s->next) {
@@ -3593,7 +3593,7 @@
/* Last gasp, stuff that's not in the main lists */
if (!keyhandled)
switch (kbinput) {
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case KEY_MOUSE:
do_mouse();
break;
diff --git a/src/nano.h b/src/nano.h
index 03203c1..d97794f 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -109,6 +109,10 @@
#define VERMSG "GNU nano " VERSION
+#ifndef NCURSES_MOUSE_VERSION
+#define DISABLE_MOUSE 1
+#endif
+
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
#define DISABLE_WRAPJUSTIFY 1
#endif
diff --git a/src/proto.h b/src/proto.h
index 649bd7d..43556c4 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -29,7 +29,9 @@
#include "nano.h"
+#ifndef DISABLE_WRAPJUSTIFY
extern int wrap_at;
+#endif
extern int editwinrows;
extern int current_x, current_y, totlines;
extern int placewewant;
@@ -38,7 +40,8 @@
#endif
extern long totsize;
extern int temp_opt;
-extern int wrap_at, flags, tabsize;
+extern int flags;
+extern int tabsize;
extern int search_last_line;
extern int search_offscreen;
extern int currslen;
@@ -101,7 +104,7 @@
extern shortcut *browser_list, *gotodir_list;
#endif
-#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
extern const shortcut *currshortcut;
#endif
@@ -236,7 +239,7 @@
void print_view_warning(void);
void global_init(int save_cutbuffer);
void window_init(void);
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
void mouse_init(void);
#endif
#ifndef DISABLE_HELP
@@ -265,10 +268,8 @@
int open_pipe(const char *command);
#endif
#ifndef DISABLE_MOUSE
-#ifdef NCURSES_MOUSE_VERSION
void do_mouse(void);
#endif
-#endif
void do_char(char ch);
int do_backspace(void);
int do_delete(void);
diff --git a/src/rcfile.c b/src/rcfile.c
index ab96f9d..73bfc3e 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -52,7 +52,7 @@
#ifndef NANO_SMALL
{"historylog", HISTORYLOG},
#endif
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
#ifdef ENABLE_MULTIBUFFER
diff --git a/src/winio.c b/src/winio.c
index 7f53556..b221a7e 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -582,7 +582,7 @@
else
answer[0] = '\0';
-#if !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
+#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = s;
#endif
@@ -620,7 +620,7 @@
tabbed = 0;
switch (kbinput) {
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case KEY_MOUSE:
do_mouse();
break;
@@ -1602,13 +1602,13 @@
do {
int kbinput = wgetch(edit);
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
MEVENT mevent;
#endif
if (kbinput == NANO_CONTROL_C)
ok = -1;
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
/* Look ma! We get to duplicate lots of code from do_mouse!! */
else if (kbinput == KEY_MOUSE && getmouse(&mevent) != ERR &&
wenclose(bottomwin, mevent.y, mevent.x) &&
@@ -1841,7 +1841,7 @@
const char *ptr = help_text;
switch (kbinput) {
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case KEY_MOUSE:
do_mouse();
break;