mirror of git://git.sv.gnu.org/nano.git
miscellaneous #define cleanups
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1565 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
4dcd070cdf
commit
f5b256bb9f
|
@ -55,6 +55,11 @@ CVS code -
|
|||
#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
|
||||
|
|
10
src/files.c
10
src/files.c
|
@ -441,7 +441,7 @@ int do_insertfile(int loading_file)
|
|||
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 @@ int do_writeout(const char *path, int exiting, int append)
|
|||
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 @@ char *do_browser(const char *inpath)
|
|||
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 @@ char *do_browser(const char *inpath)
|
|||
|
||||
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 @@ char *do_browser(const char *inpath)
|
|||
|
||||
switch (kbinput) {
|
||||
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
#ifndef DISABLE_MOUSE
|
||||
case KEY_MOUSE:
|
||||
if (getmouse(&mevent) == ERR)
|
||||
return retval;
|
||||
|
|
13
src/global.c
13
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 @@ syntaxtype *syntaxes = NULL;
|
|||
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 @@ void toggle_init(void)
|
|||
*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 @@ void toggle_init(void)
|
|||
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 @@ void toggle_init(void)
|
|||
#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 @@ void shortcut_init(int unjustify)
|
|||
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
|
||||
|
|
24
src/nano.c
24
src/nano.c
|
@ -245,7 +245,7 @@ void window_init(void)
|
|||
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 @@ void usage(void)
|
|||
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 @@ void version(void)
|
|||
#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 @@ int open_pipe(const char *command)
|
|||
}
|
||||
#endif /* NANO_SMALL */
|
||||
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
#ifndef DISABLE_MOUSE
|
||||
void do_mouse(void)
|
||||
{
|
||||
MEVENT mevent;
|
||||
|
@ -2630,7 +2630,7 @@ int do_para_operation(int operation)
|
|||
/* 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 @@ void do_toggle(const toggle *which)
|
|||
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 @@ int main(int argc, char *argv[])
|
|||
{"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 @@ int main(int argc, char *argv[])
|
|||
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 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
window_init();
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
#ifndef DISABLE_MOUSE
|
||||
mouse_init();
|
||||
#endif
|
||||
|
||||
|
@ -3479,7 +3479,7 @@ int main(int argc, char *argv[])
|
|||
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 @@ int main(int argc, char *argv[])
|
|||
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 @@ int main(int argc, char *argv[])
|
|||
/* 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;
|
||||
|
|
|
@ -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
|
||||
|
|
11
src/proto.h
11
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 @@ extern int mark_beginx;
|
|||
#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 *spell_list;
|
|||
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 die_too_small(void);
|
|||
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 @@ RETSIGTYPE cancel_fork(int signal);
|
|||
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);
|
||||
|
|
|
@ -52,7 +52,7 @@ const static rcoption rcopts[] = {
|
|||
#ifndef NANO_SMALL
|
||||
{"historylog", HISTORYLOG},
|
||||
#endif
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
#ifndef DISABLE_MOUSE
|
||||
{"mouse", USE_MOUSE},
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
|
|
10
src/winio.c
10
src/winio.c
|
@ -582,7 +582,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||
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 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||
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 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
|
|||
|
||||
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 @@ int do_help(void)
|
|||
const char *ptr = help_text;
|
||||
|
||||
switch (kbinput) {
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
#ifndef DISABLE_MOUSE
|
||||
case KEY_MOUSE:
|
||||
do_mouse();
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue