Commit f5b256bb authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

miscellaneous #define cleanups

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1565 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 46 additions and 33 deletions
+46 -33
...@@ -55,6 +55,11 @@ CVS code - ...@@ -55,6 +55,11 @@ CVS code -
#ifdef instead of two. #ifdef instead of two.
- Convert memmove() function calls to charmove() macro calls, as - Convert memmove() function calls to charmove() macro calls, as
the former all work on char*'s. (DLR) 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: - files.c:
read_file() read_file()
- After we've read in a file and possibly converted it from - After we've read in a file and possibly converted it from
......
...@@ -441,7 +441,7 @@ int do_insertfile(int loading_file) ...@@ -441,7 +441,7 @@ int do_insertfile(int loading_file)
start_again: /* Goto here when the user cancels the file browser. */ start_again: /* Goto here when the user cancels the file browser. */
#endif #endif
#if !defined(DISABLE_BROWSER) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)) #if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = insertfile_list; currshortcut = insertfile_list;
#endif #endif
...@@ -1710,7 +1710,7 @@ int do_writeout(const char *path, int exiting, int append) ...@@ -1710,7 +1710,7 @@ int do_writeout(const char *path, int exiting, int append)
static int did_cred = 0; static int did_cred = 0;
#endif #endif
#if !defined(DISABLE_BROWSER) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)) #if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = writefile_list; currshortcut = writefile_list;
#endif #endif
...@@ -2488,7 +2488,7 @@ char *do_browser(const char *inpath) ...@@ -2488,7 +2488,7 @@ char *do_browser(const char *inpath)
int abort = 0, col = 0, selected = 0, editline = 0, width = 0; int abort = 0, col = 0, selected = 0, editline = 0, width = 0;
int filecols = 0, lineno = 0; int filecols = 0, lineno = 0;
char **filelist = (char **)NULL; char **filelist = (char **)NULL;
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
MEVENT mevent; MEVENT mevent;
#endif #endif
...@@ -2527,7 +2527,7 @@ char *do_browser(const char *inpath) ...@@ -2527,7 +2527,7 @@ char *do_browser(const char *inpath)
blank_statusbar_refresh(); blank_statusbar_refresh();
#if !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)) #if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = browser_list; currshortcut = browser_list;
#endif #endif
...@@ -2541,7 +2541,7 @@ char *do_browser(const char *inpath) ...@@ -2541,7 +2541,7 @@ char *do_browser(const char *inpath)
switch (kbinput) { switch (kbinput) {
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
case KEY_MOUSE: case KEY_MOUSE:
if (getmouse(&mevent) == ERR) if (getmouse(&mevent) == ERR)
return retval; return retval;
......
...@@ -29,8 +29,11 @@ ...@@ -29,8 +29,11 @@
/* Global variables */ /* Global variables */
#ifndef DISABLE_WRAPJUSTIFY
/* wrap_at might be set in rcfile.c or nano.c */ /* wrap_at might be set in rcfile.c or nano.c */
int wrap_at = -CHARS_FROM_EOL;/* Right justified fill value, allows resize */ int wrap_at = -CHARS_FROM_EOL;/* Right justified fill value, allows resize */
#endif
char *last_search = NULL; /* Last string we searched for */ char *last_search = NULL; /* Last string we searched for */
char *last_replace = NULL; /* Last replacement string */ char *last_replace = NULL; /* Last replacement string */
int search_last_line; /* Is this the last search line? */ int search_last_line; /* Is this the last search line? */
...@@ -129,7 +132,7 @@ syntaxtype *syntaxes = NULL; ...@@ -129,7 +132,7 @@ syntaxtype *syntaxes = NULL;
char *syntaxstr = NULL; char *syntaxstr = NULL;
#endif #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 */ const shortcut *currshortcut; /* Current shortcut list we're using */
#endif #endif
...@@ -225,7 +228,7 @@ void toggle_init(void) ...@@ -225,7 +228,7 @@ void toggle_init(void)
*toggle_nohelp_msg, *toggle_cuttoend_msg, *toggle_nohelp_msg, *toggle_cuttoend_msg,
*toggle_noconvert_msg, *toggle_dos_msg, *toggle_mac_msg, *toggle_noconvert_msg, *toggle_dos_msg, *toggle_mac_msg,
*toggle_backup_msg, *toggle_smooth_msg; *toggle_backup_msg, *toggle_smooth_msg;
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
char *toggle_mouse_msg; char *toggle_mouse_msg;
#endif #endif
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
...@@ -247,7 +250,7 @@ void toggle_init(void) ...@@ -247,7 +250,7 @@ void toggle_init(void)
toggle_autoindent_msg = _("Auto indent"); toggle_autoindent_msg = _("Auto indent");
toggle_suspend_msg = _("Suspend"); toggle_suspend_msg = _("Suspend");
toggle_nohelp_msg = _("Help mode"); toggle_nohelp_msg = _("Help mode");
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
toggle_mouse_msg = _("Mouse support"); toggle_mouse_msg = _("Mouse support");
#endif #endif
toggle_cuttoend_msg = _("Cut to end"); toggle_cuttoend_msg = _("Cut to end");
...@@ -273,7 +276,7 @@ void toggle_init(void) ...@@ -273,7 +276,7 @@ void toggle_init(void)
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
toggle_init_one(TOGGLE_WRAP_KEY, toggle_wrap_msg, NO_WRAP); toggle_init_one(TOGGLE_WRAP_KEY, toggle_wrap_msg, NO_WRAP);
#endif #endif
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE); toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE);
#endif #endif
toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END); toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
...@@ -840,7 +843,7 @@ void shortcut_init(int unjustify) ...@@ -840,7 +843,7 @@ void shortcut_init(int unjustify)
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0); IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
#endif #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; currshortcut = main_list;
#endif #endif
#ifndef NANO_SMALL #ifndef NANO_SMALL
......
...@@ -245,7 +245,7 @@ void window_init(void) ...@@ -245,7 +245,7 @@ void window_init(void)
keypad(bottomwin, TRUE); keypad(bottomwin, TRUE);
} }
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
void mouse_init(void) void mouse_init(void)
{ {
if (ISSET(USE_MOUSE)) { if (ISSET(USE_MOUSE)) {
...@@ -664,7 +664,7 @@ void usage(void) ...@@ -664,7 +664,7 @@ void usage(void)
print1opt("-k", "--cut", _("Let ^K cut from cursor to end of line")); print1opt("-k", "--cut", _("Let ^K cut from cursor to end of line"));
#endif #endif
print1opt("-l", "--nofollow", _("Don't follow symbolic links, overwrite")); 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")); print1opt("-m", "--mouse", _("Enable mouse"));
#endif #endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
...@@ -720,7 +720,7 @@ void version(void) ...@@ -720,7 +720,7 @@ void version(void)
#ifdef DISABLE_JUSTIFY #ifdef DISABLE_JUSTIFY
printf(" --disable-justify"); printf(" --disable-justify");
#endif #endif
#if defined(DISABLE_MOUSE) || !defined(NCURSES_MOUSE_VERSION) #ifdef DISABLE_MOUSE
printf(" --disable-mouse"); printf(" --disable-mouse");
#endif #endif
#ifdef DISABLE_OPERATINGDIR #ifdef DISABLE_OPERATINGDIR
...@@ -887,7 +887,7 @@ int open_pipe(const char *command) ...@@ -887,7 +887,7 @@ int open_pipe(const char *command)
} }
#endif /* NANO_SMALL */ #endif /* NANO_SMALL */
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
void do_mouse(void) void do_mouse(void)
{ {
MEVENT mevent; MEVENT mevent;
...@@ -2630,7 +2630,7 @@ int do_para_operation(int operation) ...@@ -2630,7 +2630,7 @@ int do_para_operation(int operation)
/* Now get a keystroke and see if it's unjustify; if not, unget the /* Now get a keystroke and see if it's unjustify; if not, unget the
* keystroke and return. */ * 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 /* 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. */ * become the unjustify key. Else give it back to the input stream. */
if ((i = wgetch(edit)) == KEY_MOUSE) if ((i = wgetch(edit)) == KEY_MOUSE)
...@@ -2985,7 +2985,7 @@ void do_toggle(const toggle *which) ...@@ -2985,7 +2985,7 @@ void do_toggle(const toggle *which)
case TOGGLE_SUSPEND_KEY: case TOGGLE_SUSPEND_KEY:
signal_init(); signal_init();
break; break;
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
case TOGGLE_MOUSE_KEY: case TOGGLE_MOUSE_KEY:
mouse_init(); mouse_init();
break; break;
...@@ -3065,7 +3065,7 @@ int main(int argc, char *argv[]) ...@@ -3065,7 +3065,7 @@ int main(int argc, char *argv[])
{"const", 0, 0, 'c'}, {"const", 0, 0, 'c'},
{"rebinddelete", 0, 0, 'd'}, {"rebinddelete", 0, 0, 'd'},
{"nofollow", 0, 0, 'l'}, {"nofollow", 0, 0, 'l'},
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
{"mouse", 0, 0, 'm'}, {"mouse", 0, 0, 'm'},
#endif #endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
...@@ -3218,7 +3218,7 @@ int main(int argc, char *argv[]) ...@@ -3218,7 +3218,7 @@ int main(int argc, char *argv[])
case 'l': case 'l':
SET(NOFOLLOW_SYMLINKS); SET(NOFOLLOW_SYMLINKS);
break; break;
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
case 'm': case 'm':
SET(USE_MOUSE); SET(USE_MOUSE);
break; break;
...@@ -3419,7 +3419,7 @@ int main(int argc, char *argv[]) ...@@ -3419,7 +3419,7 @@ int main(int argc, char *argv[])
#endif #endif
window_init(); window_init();
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
mouse_init(); mouse_init();
#endif #endif
...@@ -3479,7 +3479,7 @@ int main(int argc, char *argv[]) ...@@ -3479,7 +3479,7 @@ int main(int argc, char *argv[])
if (ISSET(CONSTUPDATE)) if (ISSET(CONSTUPDATE))
do_cursorpos(1); 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; currshortcut = main_list;
#endif #endif
...@@ -3544,7 +3544,7 @@ int main(int argc, char *argv[]) ...@@ -3544,7 +3544,7 @@ int main(int argc, char *argv[])
shortcut key */ shortcut key */
if (!keyhandled) 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) { for (s = currshortcut; s != NULL && !keyhandled; s = s->next) {
#else #else
for (s = main_list; s != NULL && !keyhandled; s = s->next) { for (s = main_list; s != NULL && !keyhandled; s = s->next) {
...@@ -3593,7 +3593,7 @@ int main(int argc, char *argv[]) ...@@ -3593,7 +3593,7 @@ int main(int argc, char *argv[])
/* Last gasp, stuff that's not in the main lists */ /* Last gasp, stuff that's not in the main lists */
if (!keyhandled) if (!keyhandled)
switch (kbinput) { switch (kbinput) {
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
case KEY_MOUSE: case KEY_MOUSE:
do_mouse(); do_mouse();
break; break;
......
...@@ -109,6 +109,10 @@ ...@@ -109,6 +109,10 @@
#define VERMSG "GNU nano " VERSION #define VERMSG "GNU nano " VERSION
#ifndef NCURSES_MOUSE_VERSION
#define DISABLE_MOUSE 1
#endif
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY) #if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
#define DISABLE_WRAPJUSTIFY 1 #define DISABLE_WRAPJUSTIFY 1
#endif #endif
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
#include "nano.h" #include "nano.h"
#ifndef DISABLE_WRAPJUSTIFY
extern int wrap_at; extern int wrap_at;
#endif
extern int editwinrows; extern int editwinrows;
extern int current_x, current_y, totlines; extern int current_x, current_y, totlines;
extern int placewewant; extern int placewewant;
...@@ -38,7 +40,8 @@ extern int mark_beginx; ...@@ -38,7 +40,8 @@ extern int mark_beginx;
#endif #endif
extern long totsize; extern long totsize;
extern int temp_opt; extern int temp_opt;
extern int wrap_at, flags, tabsize; extern int flags;
extern int tabsize;
extern int search_last_line; extern int search_last_line;
extern int search_offscreen; extern int search_offscreen;
extern int currslen; extern int currslen;
...@@ -101,7 +104,7 @@ extern shortcut *spell_list; ...@@ -101,7 +104,7 @@ extern shortcut *spell_list;
extern shortcut *browser_list, *gotodir_list; extern shortcut *browser_list, *gotodir_list;
#endif #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; extern const shortcut *currshortcut;
#endif #endif
...@@ -236,7 +239,7 @@ void die_too_small(void); ...@@ -236,7 +239,7 @@ void die_too_small(void);
void print_view_warning(void); void print_view_warning(void);
void global_init(int save_cutbuffer); void global_init(int save_cutbuffer);
void window_init(void); void window_init(void);
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
void mouse_init(void); void mouse_init(void);
#endif #endif
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
...@@ -265,10 +268,8 @@ RETSIGTYPE cancel_fork(int signal); ...@@ -265,10 +268,8 @@ RETSIGTYPE cancel_fork(int signal);
int open_pipe(const char *command); int open_pipe(const char *command);
#endif #endif
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
#ifdef NCURSES_MOUSE_VERSION
void do_mouse(void); void do_mouse(void);
#endif #endif
#endif
void do_char(char ch); void do_char(char ch);
int do_backspace(void); int do_backspace(void);
int do_delete(void); int do_delete(void);
......
...@@ -52,7 +52,7 @@ const static rcoption rcopts[] = { ...@@ -52,7 +52,7 @@ const static rcoption rcopts[] = {
#ifndef NANO_SMALL #ifndef NANO_SMALL
{"historylog", HISTORYLOG}, {"historylog", HISTORYLOG},
#endif #endif
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
{"mouse", USE_MOUSE}, {"mouse", USE_MOUSE},
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
......
...@@ -582,7 +582,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def, ...@@ -582,7 +582,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
else else
answer[0] = '\0'; answer[0] = '\0';
#if !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)) #if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = s; currshortcut = s;
#endif #endif
...@@ -620,7 +620,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def, ...@@ -620,7 +620,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
tabbed = 0; tabbed = 0;
switch (kbinput) { switch (kbinput) {
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
case KEY_MOUSE: case KEY_MOUSE:
do_mouse(); do_mouse();
break; break;
...@@ -1602,13 +1602,13 @@ int do_yesno(int all, int leavecursor, const char *msg, ...) ...@@ -1602,13 +1602,13 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
do { do {
int kbinput = wgetch(edit); int kbinput = wgetch(edit);
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
MEVENT mevent; MEVENT mevent;
#endif #endif
if (kbinput == NANO_CONTROL_C) if (kbinput == NANO_CONTROL_C)
ok = -1; 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!! */ /* Look ma! We get to duplicate lots of code from do_mouse!! */
else if (kbinput == KEY_MOUSE && getmouse(&mevent) != ERR && else if (kbinput == KEY_MOUSE && getmouse(&mevent) != ERR &&
wenclose(bottomwin, mevent.y, mevent.x) && wenclose(bottomwin, mevent.y, mevent.x) &&
...@@ -1841,7 +1841,7 @@ int do_help(void) ...@@ -1841,7 +1841,7 @@ int do_help(void)
const char *ptr = help_text; const char *ptr = help_text;
switch (kbinput) { switch (kbinput) {
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION) #ifndef DISABLE_MOUSE
case KEY_MOUSE: case KEY_MOUSE:
do_mouse(); do_mouse();
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment