#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
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
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
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
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
switch (kbinput) {
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case KEY_MOUSE:
if (getmouse(&mevent) == ERR)
return retval;
/* 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? */
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
*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
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");
#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);
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
keypad(bottomwin, TRUE);
}
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
void mouse_init(void)
{
if (ISSET(USE_MOUSE)) {
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
#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
}
#endif /* NANO_SMALL */
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
void do_mouse(void)
{
MEVENT mevent;
/* 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)
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;
{"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
case 'l':
SET(NOFOLLOW_SYMLINKS);
break;
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case 'm':
SET(USE_MOUSE);
break;
#endif
window_init();
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
mouse_init();
#endif
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
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) {
/* 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;
#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
#include "nano.h"
+#ifndef DISABLE_WRAPJUSTIFY
extern int wrap_at;
+#endif
extern int editwinrows;
extern int current_x, current_y, totlines;
extern int placewewant;
#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;
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
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
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);
#ifndef NANO_SMALL
{"historylog", HISTORYLOG},
#endif
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
#ifdef ENABLE_MULTIBUFFER
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
tabbed = 0;
switch (kbinput) {
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case KEY_MOUSE:
do_mouse();
break;
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) &&
const char *ptr = help_text;
switch (kbinput) {
-#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
+#ifndef DISABLE_MOUSE
case KEY_MOUSE:
do_mouse();
break;