mirror of git://git.sv.gnu.org/nano.git
miscellaneous bug fixes, part 2
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1331 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
334a94049f
commit
9b13ff31bb
78
ChangeLog
78
ChangeLog
|
@ -9,9 +9,72 @@ CVS code -
|
|||
- Minor cosmetic tweaks to the ngettext() macro, and fix to
|
||||
properly detect systems lacking ngettext() and correctly
|
||||
compile on them; the previous fix didn't work. (DLR)
|
||||
- Fix problems with some code sections' not being #ifdef'ed out
|
||||
when they should be, or being #ifdef'ed out improperly. (David
|
||||
Benbennick and DLR)
|
||||
- Change FOLLOW_SYMLINKS to NOFOLLOW_SYMLINKS, and rework the
|
||||
associated logic accordingly, throughout the code. (David
|
||||
Benbennick)
|
||||
- Rework #ifdefs to not include mouse_init() at all if
|
||||
DISABLE_MOUSE is defined or NCURSES_MOUSE_VERSION isn't. (DLR)
|
||||
- For consistency, change many references of (!x) to (x == NULL)
|
||||
and (x) to (x != NULL). (DLR)
|
||||
- Define KEY_IC properly (and KEY_DC more portably) when slang
|
||||
support is enabled, and remove the hack to work around the
|
||||
former's not being defined. (David Benbennick and DLR)
|
||||
- configure.ac:
|
||||
- Added tr to ALL_LINGUAS (Jordi).
|
||||
- Fix now inaccurate description of --enable-tiny's effects; it
|
||||
no longer disables NLS support. (DLR)
|
||||
- Fix typo. (David Benbennick)
|
||||
- Check for strcasecmp() and strncasecmp(), since they are
|
||||
apparently only standard under BSD. (DLR)
|
||||
- cut.c:
|
||||
do_cut_text()
|
||||
- Fix a memory corruption problem caused by accessing edittop
|
||||
after it was freed but before it was reset to a sane value
|
||||
from current. (David Benbennick)
|
||||
do_uncut_text()
|
||||
- If uncutting more than one line of unmarked text at editbot,
|
||||
don't center the screen, since Pico doesn't. (DLR)
|
||||
- files.c:
|
||||
read_line()
|
||||
- Miscellaneous cleanups. (David Benbennick)
|
||||
read_file()
|
||||
- Miscellaneous cleanups. (David Benbennick)
|
||||
- Fix len's being off by one when reading in Mac-format files,
|
||||
exposed by one of David Benbennick's cleanups. (DLR)
|
||||
- If NO_CONVERT isn't set when we first enter, and it gets set
|
||||
while reading in the file, unset it again afterwards. (DLR)
|
||||
add_open_file()
|
||||
- Fix minor logic error when determining when to resave fileage
|
||||
and filebot. (DLR)
|
||||
write_file()
|
||||
- Change lineswritten from a long to an int, to match
|
||||
filestruct->lineno. (DLR; mismatch found by David Benbennick)
|
||||
input_tab()
|
||||
- Variable name change: matchBuf -> matchbuf. (DLR)
|
||||
diralphasort()
|
||||
- Remove the HAVE_STRCASECMP #ifdef block; see the changes to
|
||||
configure.ac and nano.h for why. (DLR)
|
||||
- move.c:
|
||||
do_page_down()
|
||||
- If there's a page or less of text, do an edit_update() if the
|
||||
mark is on; otherwise, the highlight won't be displayed. (DLR)
|
||||
- nano.c:
|
||||
do_prev_word()
|
||||
- Make the assert match that in do_next_word(). (DLR)
|
||||
do_enter()
|
||||
- If smooth scrolling is on, and Enter is pressed on the
|
||||
magicline, don't center the screen. (DLR)
|
||||
do_justify()
|
||||
- Fix memory corruption problem triggered when edittop and
|
||||
current->next pointed to the same value and current->next was
|
||||
destroyed during justification. (DLR)
|
||||
- Center the screen when justification moves the cursor entirely
|
||||
off the bottom of the screen, instead of when it moves the
|
||||
cursor near the bottom of the screen, to more closely match
|
||||
Pico's behavior. (DLR)
|
||||
version()
|
||||
- Remove obsolete reference to --enable-undo. (David Benbennick)
|
||||
do_int_speller()
|
||||
|
@ -23,7 +86,22 @@ CVS code -
|
|||
- Programs now return char *, NULL for successful completion,
|
||||
otherwise the error string to display. This allows us to give
|
||||
more useful feedback to the user when spell checking fails.
|
||||
ABCD()
|
||||
- Renamed abcd(). (DLR)
|
||||
- nano.h:
|
||||
- Make sure NO_RCFILE and COLOR_SYNTAX aren't set to the same
|
||||
value. (DLR; discovered by Ken Tyler)
|
||||
- If strcasecmp() and/or strncasecmp() aren't available, use
|
||||
strcmp() and/or strncmp instead. (DLR)
|
||||
- utils.c:
|
||||
is_cntrl_char()
|
||||
- Rework to fix a problem with displaying certain high-bit
|
||||
characters. (David Benbennick; reported by Andrzej Marecki)
|
||||
- winio.c:
|
||||
edit_refresh()
|
||||
- Miscellaneous cleanups that fix a bug where the screen
|
||||
isn't updated after uncutting chunks of upwardly marked cut
|
||||
text that are over a page in length. (David Benbennick)
|
||||
do_credits()
|
||||
- Add David Benbennick to credits. (DLR)
|
||||
- nanorc.sample:
|
||||
|
|
4
color.c
4
color.c
|
@ -78,13 +78,13 @@ void do_colorinit(void)
|
|||
defok = use_default_colors() != ERR;
|
||||
#endif
|
||||
|
||||
for (tmpcolor = colorstrings; tmpcolor != NULL;
|
||||
for (tmpcolor = colorstrings; tmpcolor != NULL;
|
||||
tmpcolor = tmpcolor->next) {
|
||||
short background = tmpcolor->bg;
|
||||
|
||||
if (background == -1)
|
||||
#ifdef HAVE_USE_DEFAULT_COLORS
|
||||
if (!defok)
|
||||
if (defok == 0)
|
||||
#endif
|
||||
background = COLOR_BLACK;
|
||||
|
||||
|
|
|
@ -37,8 +37,7 @@ AC_ARG_ENABLE(extra,
|
|||
fi])
|
||||
|
||||
AC_ARG_ENABLE(tiny,
|
||||
[ --enable-tiny Disable features for the sake of size
|
||||
(currently disables detailed help and i18n)],
|
||||
[ --enable-tiny Disable features for the sake of size],
|
||||
[if test x$enableval = xyes; then
|
||||
AC_DEFINE(NANO_SMALL, 1, [Define this to make the nano executable as small as possible.]) tiny_support=yes
|
||||
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.])
|
||||
|
@ -223,7 +222,7 @@ AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
|||
esac], [AC_MSG_RESULT(no)])
|
||||
|
||||
dnl Checks for functions
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf strcasecmp strncasecmp)
|
||||
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
|
||||
then
|
||||
AM_PATH_GLIB(1.2.4,,
|
||||
|
@ -284,7 +283,7 @@ if test x$slang_support != xyes; then
|
|||
AC_CHECK_LIB([$CURSES_LIB_NAME], wresize, AC_DEFINE(HAVE_WRESIZE, 1, [Define this if you have the wresize function in your ncurses-type library.]))
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], resizeterm, AC_DEFINE(HAVE_RESIZETERM, 1, [Define this if you have the resizeterm function in your ncurses-type library.]))
|
||||
|
||||
# Taken from aumix (can't tell form the variable name?)
|
||||
# Taken from aumix (can't tell from the variable name?)
|
||||
AC_CACHE_CHECK([for private member _use_keypad in WINDOW],
|
||||
aumix_cv_struct_window_usekeypad,
|
||||
[AC_TRY_COMPILE([#ifdef HAVE_NCURSES_H
|
||||
|
|
33
cut.c
33
cut.c
|
@ -29,7 +29,8 @@
|
|||
#include "nano.h"
|
||||
|
||||
static int marked_cut; /* Is the cutbuffer from a mark? */
|
||||
static filestruct *cutbottom = NULL; /* Pointer to end of cutbuffer */
|
||||
static filestruct *cutbottom = NULL;
|
||||
/* Pointer to end of cutbuffer */
|
||||
|
||||
filestruct *get_cutbottom(void)
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ filestruct *get_cutbottom(void)
|
|||
void add_to_cutbuffer(filestruct *inptr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("add_to_cutbuffer called with inptr->data = %s\n"),
|
||||
fprintf(stderr, _("add_to_cutbuffer() called with inptr->data = %s\n"),
|
||||
inptr->data);
|
||||
#endif
|
||||
|
||||
|
@ -57,6 +58,7 @@ void add_to_cutbuffer(filestruct *inptr)
|
|||
|
||||
#ifndef NANO_SMALL
|
||||
/* Cut a marked segment instead of a whole line.
|
||||
*
|
||||
* The first cut character is top->data[top_x]. Unless top == bot, the
|
||||
* last cut line has length bot_x. That is, if bot_x > 0 then we cut to
|
||||
* bot->data[bot_x - 1].
|
||||
|
@ -121,8 +123,8 @@ void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
|
|||
} else {
|
||||
totsize -= bot_x + 1;
|
||||
|
||||
/* Here, the remainder line might get longer, so we realloc
|
||||
it first. */
|
||||
/* Here, the remainder line might get longer, so we
|
||||
realloc() it first. */
|
||||
top->data = (char *)nrealloc(top->data,
|
||||
sizeof(char) * newsize);
|
||||
memmove(top->data + top_x, bot->data + bot_x,
|
||||
|
@ -248,12 +250,11 @@ int do_cut_text(void)
|
|||
UNSET(MARK_ISSET);
|
||||
|
||||
marked_cut = 1;
|
||||
set_modified();
|
||||
if (dontupdate) {
|
||||
fix_editbot();
|
||||
if (dontupdate)
|
||||
edit_refresh();
|
||||
} else
|
||||
else
|
||||
edit_update(current, CENTER);
|
||||
set_modified();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -291,8 +292,7 @@ int do_cut_text(void)
|
|||
int do_uncut_text(void)
|
||||
{
|
||||
filestruct *tmp = current, *fileptr = current;
|
||||
filestruct *newbuf = NULL;
|
||||
filestruct *newend = NULL;
|
||||
filestruct *newbuf = NULL, *newend = NULL;
|
||||
#ifndef NANO_SMALL
|
||||
char *tmpstr, *tmpstr2;
|
||||
filestruct *hold = current;
|
||||
|
@ -305,7 +305,7 @@ int do_uncut_text(void)
|
|||
return 0; /* AIEEEEEEEEEEEE */
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (!marked_cut || cutbuffer->next != NULL)
|
||||
if (marked_cut == 0 || cutbuffer->next != NULL)
|
||||
#endif
|
||||
{
|
||||
newbuf = copy_filestruct(cutbuffer);
|
||||
|
@ -316,7 +316,7 @@ int do_uncut_text(void)
|
|||
|
||||
/* Hook newbuf into fileptr */
|
||||
#ifndef NANO_SMALL
|
||||
if (marked_cut) {
|
||||
if (marked_cut != 0) {
|
||||
int recenter_me = 0;
|
||||
/* Should we eventually use edit_update(CENTER)? */
|
||||
|
||||
|
@ -329,7 +329,7 @@ int do_uncut_text(void)
|
|||
memmove(current->data + current_x + buf_len,
|
||||
current->data + current_x, cur_len - current_x + 1);
|
||||
strncpy(current->data + current_x, cutbuffer->data, buf_len);
|
||||
/* Use strncpy to not copy the terminal '\0'. */
|
||||
/* Use strncpy() to not copy the terminal '\0'. */
|
||||
|
||||
current_x += buf_len;
|
||||
totsize += buf_len;
|
||||
|
@ -398,8 +398,7 @@ int do_uncut_text(void)
|
|||
|
||||
if (marked_cut == 2) {
|
||||
tmp = make_new_node(current);
|
||||
tmp->data = charalloc(strlen(¤t->data[current_x]) + 1);
|
||||
strcpy(tmp->data, ¤t->data[current_x]);
|
||||
tmp->data = mallocstrcpy(NULL, current->data + current_x);
|
||||
splice_node(current, tmp, current->next);
|
||||
null_at(¤t->data, current_x);
|
||||
current = current->next;
|
||||
|
@ -449,7 +448,9 @@ int do_uncut_text(void)
|
|||
|
||||
i = editbot->lineno;
|
||||
renumber(newbuf);
|
||||
if (i < newend->lineno)
|
||||
/* Center the screen if we've moved beyond the line numbers of both
|
||||
the old and new editbots */
|
||||
if (i < newend->lineno && editbot->lineno < newend->lineno)
|
||||
edit_update(fileptr, CENTER);
|
||||
else
|
||||
edit_refresh();
|
||||
|
|
27
global.c
27
global.c
|
@ -111,20 +111,22 @@ shortcut *writefile_list = NULL;
|
|||
shortcut *insertfile_list = NULL;
|
||||
shortcut *help_list = NULL;
|
||||
shortcut *spell_list = NULL;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
shortcut *extcmd_list = NULL;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
shortcut *browser_list = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
const colortype *colorstrings = NULL;
|
||||
syntaxtype *syntaxes = NULL;
|
||||
char *syntaxstr = NULL;
|
||||
const colortype *colorstrings = NULL;
|
||||
syntaxtype *syntaxes = NULL;
|
||||
char *syntaxstr = NULL;
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined(DISABLE_HELP)
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
||||
const shortcut *currshortcut; /* Current shortcut list we're using */
|
||||
#endif
|
||||
|
||||
|
@ -207,9 +209,12 @@ void toggle_init_one(int val, const char *desc, int flag)
|
|||
void toggle_init(void)
|
||||
{
|
||||
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
|
||||
*toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg,
|
||||
*toggle_cuttoend_msg, *toggle_noconvert_msg, *toggle_dos_msg,
|
||||
*toggle_mac_msg, *toggle_backup_msg, *toggle_smooth_msg;
|
||||
*toggle_nohelp_msg, *toggle_picomode_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)
|
||||
char *toggle_mouse_msg;
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPPING
|
||||
char *toggle_wrap_msg;
|
||||
#endif
|
||||
|
@ -232,7 +237,9 @@ void toggle_init(void)
|
|||
toggle_suspend_msg = _("Suspend");
|
||||
toggle_nohelp_msg = _("Help mode");
|
||||
toggle_picomode_msg = _("Pico mode");
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
toggle_mouse_msg = _("Mouse support");
|
||||
#endif
|
||||
toggle_cuttoend_msg = _("Cut to end");
|
||||
toggle_noconvert_msg = _("No conversion from DOS/Mac format");
|
||||
toggle_dos_msg = _("Writing file in DOS format");
|
||||
|
@ -257,7 +264,9 @@ 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)
|
||||
toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE);
|
||||
#endif
|
||||
toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
toggle_init_one(TOGGLE_LOAD_KEY, toggle_load_msg, MULTIBUFFER);
|
||||
|
@ -401,7 +410,7 @@ void shortcut_init(int unjustify)
|
|||
do_help);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (open_files != NULL && (open_files->prev || open_files->next))
|
||||
if (open_files != NULL && (open_files->prev != NULL || open_files->next != NULL))
|
||||
sc_init_one(&main_list, NANO_EXIT_KEY, _("Close"),
|
||||
IFHELP(nano_exit_msg, 0), NANO_EXIT_FKEY, 0, VIEW,
|
||||
do_exit);
|
||||
|
@ -775,7 +784,7 @@ void shortcut_init(int unjustify)
|
|||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
||||
currshortcut = main_list;
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
|
|
13
move.c
13
move.c
|
@ -104,10 +104,16 @@ int do_page_down(void)
|
|||
return 0;
|
||||
|
||||
/* AHEM, if we only have a screen or less of text, DON'T do an
|
||||
edit_update, just move the cursor to editbot! */
|
||||
edit_update(), just move the cursor to editbot! */
|
||||
if (edittop == fileage && editbot == filebot && totlines < editwinrows) {
|
||||
current = editbot;
|
||||
reset_cursor();
|
||||
#ifndef NANO_SMALL
|
||||
/* ...unless marking is on, in which case we need it to update
|
||||
the highlight. */
|
||||
if (ISSET(MARK_ISSET))
|
||||
edit_update(current, NONE);
|
||||
#endif
|
||||
} else if (editbot != filebot || edittop == fileage) {
|
||||
current_y = 0;
|
||||
current = editbot;
|
||||
|
@ -153,7 +159,8 @@ int do_up(void)
|
|||
|
||||
/* Return value 1 means we moved down, 0 means we were already at the
|
||||
* bottom. */
|
||||
int do_down(void) {
|
||||
int do_down(void)
|
||||
{
|
||||
wrap_reset();
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
check_statblank();
|
||||
|
@ -211,7 +218,7 @@ int do_right(void)
|
|||
|
||||
if (current->data[current_x] != '\0')
|
||||
current_x++;
|
||||
else if (current->next) {
|
||||
else if (current->next != NULL) {
|
||||
do_down();
|
||||
current_x = 0;
|
||||
}
|
||||
|
|
175
nano.c
175
nano.c
|
@ -111,15 +111,15 @@ void die(const char *msg, ...)
|
|||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* then save all of the other modified loaded files, if any */
|
||||
if (open_files) {
|
||||
if (open_files != NULL) {
|
||||
openfilestruct *tmp;
|
||||
|
||||
tmp = open_files;
|
||||
|
||||
while (open_files->prev)
|
||||
while (open_files->prev != NULL)
|
||||
open_files = open_files->prev;
|
||||
|
||||
while (open_files->next) {
|
||||
while (open_files->next != NULL) {
|
||||
|
||||
/* if we already saved the file above (i. e. if it was the
|
||||
currently loaded file), don't save it again */
|
||||
|
@ -228,17 +228,16 @@ void window_init(void)
|
|||
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
|
||||
|
||||
#ifdef PDCURSES
|
||||
/* Oops, I guess we need this again.
|
||||
Moved here so the keypad still works after a Meta-X, for example */
|
||||
/* Oops, I guess we need this again. Moved here so the keypad still
|
||||
works after a Meta-X, for example */
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
void mouse_init(void)
|
||||
{
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
if (ISSET(USE_MOUSE)) {
|
||||
keypad_on(edit, 1);
|
||||
keypad_on(bottomwin, 1);
|
||||
|
@ -247,9 +246,8 @@ void mouse_init(void)
|
|||
mouseinterval(50);
|
||||
} else
|
||||
mousemask(0, NULL);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
/* This function allocates help_text, and stores the help string in it.
|
||||
|
@ -651,11 +649,9 @@ 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"));
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
print1opt("-m", "--mouse", _("Enable mouse"));
|
||||
#endif
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
print1opt(_("-o [dir]"), _("--operatingdir=[dir]"), _("Set operating directory"));
|
||||
#endif
|
||||
|
@ -706,7 +702,7 @@ void version(void)
|
|||
#ifdef DISABLE_JUSTIFY
|
||||
printf(" --disable-justify");
|
||||
#endif
|
||||
#ifdef DISABLE_MOUSE
|
||||
#if defined(DISABLE_MOUSE) || !defined(NCURSES_MOUSE_VERSION)
|
||||
printf(" --disable-mouse");
|
||||
#endif
|
||||
#ifndef ENABLE_NLS
|
||||
|
@ -769,7 +765,8 @@ static int pid; /* This is the PID of the newly forked process
|
|||
|
||||
RETSIGTYPE cancel_fork(int signal)
|
||||
{
|
||||
if (kill(pid, SIGKILL)==-1) nperror("kill");
|
||||
if (kill(pid, SIGKILL) == -1)
|
||||
nperror("kill");
|
||||
}
|
||||
|
||||
int open_pipe(const char *command)
|
||||
|
@ -780,7 +777,7 @@ int open_pipe(const char *command)
|
|||
/* original and temporary handlers for SIGINT */
|
||||
#ifdef _POSIX_VDISABLE
|
||||
struct termios term, newterm;
|
||||
#endif /* _POSIX_VDISABLE */
|
||||
#endif /* _POSIX_VDISABLE */
|
||||
int cancel_sigs = 0;
|
||||
/* cancel_sigs == 1 means that sigaction() failed without changing
|
||||
* the signal handlers. cancel_sigs == 2 means the signal handler
|
||||
|
@ -836,11 +833,11 @@ int open_pipe(const char *command)
|
|||
/* See if the platform supports disabling individual control
|
||||
* characters. */
|
||||
#ifdef _POSIX_VDISABLE
|
||||
if (!cancel_sigs && tcgetattr(0, &term) == -1) {
|
||||
if (cancel_sigs == 0 && tcgetattr(0, &term) == -1) {
|
||||
cancel_sigs = 2;
|
||||
nperror("tcgetattr");
|
||||
}
|
||||
if (!cancel_sigs) {
|
||||
if (cancel_sigs == 0) {
|
||||
newterm = term;
|
||||
/* Grab oldterm's VINTR key :-) */
|
||||
newterm.c_cc[VINTR] = oldterm.c_cc[VINTR];
|
||||
|
@ -852,7 +849,7 @@ int open_pipe(const char *command)
|
|||
#endif /* _POSIX_VDISABLE */
|
||||
|
||||
f = fdopen(fd[0], "rb");
|
||||
if (!f)
|
||||
if (f == NULL)
|
||||
nperror("fdopen");
|
||||
|
||||
read_file(f, "stdin", 0);
|
||||
|
@ -865,7 +862,7 @@ int open_pipe(const char *command)
|
|||
nperror("wait");
|
||||
|
||||
#ifdef _POSIX_VDISABLE
|
||||
if (!cancel_sigs && tcsetattr(0, TCSANOW, &term) == -1)
|
||||
if (cancel_sigs == 0 && tcsetattr(0, TCSANOW, &term) == -1)
|
||||
nperror("tcsetattr");
|
||||
#endif /* _POSIX_VDISABLE */
|
||||
|
||||
|
@ -876,8 +873,7 @@ int open_pipe(const char *command)
|
|||
}
|
||||
#endif /* NANO_SMALL */
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
void do_mouse(void)
|
||||
{
|
||||
MEVENT mevent;
|
||||
|
@ -968,7 +964,6 @@ void do_mouse(void)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The user typed a printable character; add it to the edit buffer. */
|
||||
void do_char(char ch)
|
||||
|
@ -1225,7 +1220,12 @@ int do_enter(void)
|
|||
* where we think the cursor is.
|
||||
*/
|
||||
if (current_y == editwinrows - 1) {
|
||||
edit_update(current, CENTER);
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(SMOOTHSCROLL))
|
||||
edit_update(current, NONE);
|
||||
else
|
||||
#endif
|
||||
edit_update(current, CENTER);
|
||||
reset_cursor();
|
||||
} else {
|
||||
current_y++;
|
||||
|
@ -1300,7 +1300,7 @@ int do_prev_word(void)
|
|||
{
|
||||
filestruct *old = current;
|
||||
|
||||
assert(current != NULL);
|
||||
assert(current != NULL && current->data != NULL);
|
||||
|
||||
/* Skip letters in this word first. */
|
||||
while (current_x >= 0 && isalnum((int)current->data[current_x]))
|
||||
|
@ -1529,9 +1529,9 @@ int do_wrap(filestruct *inptr)
|
|||
temp->prev = inptr;
|
||||
temp->next = inptr->next;
|
||||
temp->prev->next = temp;
|
||||
/* If !temp->next, then temp is the last line of the file, so we
|
||||
* must set filebot. */
|
||||
if (temp->next)
|
||||
/* If temp->next is NULL, then temp is the last line of the
|
||||
* file, so we must set filebot. */
|
||||
if (temp->next != NULL)
|
||||
temp->next->prev = temp;
|
||||
else
|
||||
filebot = temp;
|
||||
|
@ -1623,7 +1623,7 @@ int do_int_spell_fix(const char *word)
|
|||
|
||||
while (1) {
|
||||
/* make sure word is still mis-spelt (i.e. when multi-errors) */
|
||||
if (findnextstr(TRUE, FALSE, fileage, beginx_top, word) != NULL) {
|
||||
if (findnextstr(TRUE, FALSE, fileage, beginx_top, word)) {
|
||||
|
||||
/* find whole words only */
|
||||
if (!is_whole_word(current_x, current->data, word))
|
||||
|
@ -1678,8 +1678,8 @@ int do_int_spell_fix(const char *word)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* Integrated spell checking using 'spell' program.
|
||||
Return value: NULL for normal termination, otherwise the error string */
|
||||
/* Integrated spell checking using 'spell' program. Return value: NULL
|
||||
* for normal termination, otherwise the error string. */
|
||||
char *do_int_speller(char *tempfile_name)
|
||||
{
|
||||
char *read_buff, *read_buff_ptr, *read_buff_word;
|
||||
|
@ -1834,17 +1834,17 @@ char *do_int_speller(char *tempfile_name)
|
|||
|
||||
}
|
||||
|
||||
*read_buff_ptr = (char) NULL;
|
||||
*read_buff_ptr = (char)NULL;
|
||||
close(uniq_fd[0]);
|
||||
|
||||
/* Process the spelling errors */
|
||||
|
||||
read_buff_word = read_buff_ptr = read_buff;
|
||||
|
||||
while (*read_buff_ptr) {
|
||||
while (*read_buff_ptr != '\0') {
|
||||
|
||||
if ((*read_buff_ptr == '\n') || (*read_buff_ptr == '\r')) {
|
||||
*read_buff_ptr = (char) NULL;
|
||||
*read_buff_ptr = (char)NULL;
|
||||
if (read_buff_word != read_buff_ptr) {
|
||||
if (!do_int_spell_fix(read_buff_word)) {
|
||||
read_buff_word = read_buff_ptr;
|
||||
|
@ -1883,8 +1883,8 @@ char *do_int_speller(char *tempfile_name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* External spell checking.
|
||||
Return value: NULL for normal termination, otherwise the error string */
|
||||
/* External spell checking. Return value: NULL for normal termination,
|
||||
* otherwise the error string. */
|
||||
char *do_alt_speller(char *tempfile_name)
|
||||
{
|
||||
int alt_spell_status, lineno_cur = current->lineno;
|
||||
|
@ -1979,7 +1979,7 @@ int do_spell(void)
|
|||
{
|
||||
#ifdef DISABLE_SPELLER
|
||||
nano_disabled_msg();
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
#else
|
||||
char *temp, *spell_msg = _("Generic error");
|
||||
|
||||
|
@ -2001,7 +2001,7 @@ int do_spell(void)
|
|||
add_open_file(1);
|
||||
#endif
|
||||
|
||||
if (alt_speller)
|
||||
if (alt_speller != NULL)
|
||||
spell_msg = do_alt_speller(temp);
|
||||
else
|
||||
spell_msg = do_int_speller(temp);
|
||||
|
@ -2052,6 +2052,8 @@ size_t indent_length(const char *line)
|
|||
* not be whitespace. */
|
||||
int justify_format(int changes_allowed, filestruct *line, size_t skip)
|
||||
{
|
||||
const char *punct = ".?!";
|
||||
const char *brackets = "'\")}]>";
|
||||
char *back, *front;
|
||||
|
||||
/* These four asserts are assumptions about the input data. */
|
||||
|
@ -2072,9 +2074,7 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
|
|||
*front = ' ';
|
||||
}
|
||||
/* these tests are safe since line->data + skip is not a space */
|
||||
if (*front == ' ' && *(front-1) == ' ') {
|
||||
const char *brackets = _("'\")}]>");
|
||||
const char *punct = _(".?!");
|
||||
if (*front == ' ' && *(front - 1) == ' ') {
|
||||
const char *bob = front - 2;
|
||||
|
||||
remove_space = 1;
|
||||
|
@ -2105,16 +2105,16 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
|
|||
|
||||
/* Remove spaces from the end of the line, except maintain 1 after a
|
||||
* sentence punctuation. */
|
||||
while (line->data < back && *(back-1) == ' ')
|
||||
while (line->data < back && *(back - 1) == ' ')
|
||||
back--;
|
||||
if (line->data < back && *back == ' ' &&
|
||||
(*(back-1) == '.' || *(back-1) == '!' || *(back-1) == '?'))
|
||||
strchr(punct, *(back - 1)) != NULL)
|
||||
back++;
|
||||
if (!changes_allowed && back != front)
|
||||
return 1;
|
||||
|
||||
/* This assert merely documents a fact about the loop above. */
|
||||
assert(changes_allowed || back == front);
|
||||
assert(changes_allowed != 0 || back == front);
|
||||
|
||||
/* Now back is the new end of line->data. */
|
||||
if (back != front) {
|
||||
|
@ -2364,7 +2364,7 @@ int do_justify(void)
|
|||
/* This line is part of a paragraph. So we must search back to
|
||||
* the first line of this paragraph. First we check items 1) and
|
||||
* 3) above. */
|
||||
while (current->prev && quotes_match(current->data,
|
||||
while (current->prev != NULL && quotes_match(current->data,
|
||||
quote_len, IFREG(current->prev->data, &qreg))) {
|
||||
size_t temp_id_len =
|
||||
indent_length(current->prev->data + quote_len);
|
||||
|
@ -2392,7 +2392,7 @@ int do_justify(void)
|
|||
/* There is no next paragraph, so nothing to justify. */
|
||||
if (current->next == NULL) {
|
||||
placewewant = 0;
|
||||
if (current_y > editwinrows - 4)
|
||||
if (current_y > editwinrows - 1)
|
||||
edit_update(current, CENTER);
|
||||
else
|
||||
edit_refresh();
|
||||
|
@ -2412,7 +2412,7 @@ int do_justify(void)
|
|||
par_len = 1;
|
||||
indent_len = indent_length(line->data + quote_len);
|
||||
|
||||
while (line->next && quotes_match(current->data, quote_len,
|
||||
while (line->next != NULL && quotes_match(current->data, quote_len,
|
||||
IFREG(line->next->data, &qreg))) {
|
||||
size_t temp_id_len = indent_length(line->next->data + quote_len);
|
||||
|
||||
|
@ -2453,8 +2453,7 @@ int do_justify(void)
|
|||
* made. If there are, we do backup_lines(), which copies the
|
||||
* original paragraph to the cutbuffer for unjustification, and
|
||||
* then calls justify_format() on the remaining lines. */
|
||||
if (first_mod_line == NULL &&
|
||||
justify_format(0, current, indent_len))
|
||||
if (first_mod_line == NULL && justify_format(0, current, indent_len))
|
||||
first_mod_line = backup_lines(current, par_len, quote_len);
|
||||
|
||||
line_len = strlen(current->data);
|
||||
|
@ -2557,6 +2556,11 @@ int do_justify(void)
|
|||
#endif
|
||||
if (indent_len + break_pos == next_line_len) {
|
||||
line = current->next;
|
||||
|
||||
/* Don't destroy edittop! */
|
||||
if (line == edittop)
|
||||
edittop = current;
|
||||
|
||||
unlink_node(line);
|
||||
delete_node(line);
|
||||
totlines--;
|
||||
|
@ -2588,7 +2592,7 @@ int do_justify(void)
|
|||
renumber(first_mod_line);
|
||||
}
|
||||
|
||||
if (current_y > editwinrows - 4)
|
||||
if (current_y > editwinrows - 1)
|
||||
edit_update(current, CENTER);
|
||||
else
|
||||
edit_refresh();
|
||||
|
@ -2602,15 +2606,13 @@ int do_justify(void)
|
|||
/* Now get a keystroke and see if it's unjustify; if not, unget the
|
||||
* keystroke and return. */
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
/* 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)
|
||||
do_mouse();
|
||||
else
|
||||
ungetch(i);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if ((i = wgetch(edit)) != NANO_UNJUSTIFY_KEY) {
|
||||
|
@ -2803,8 +2805,8 @@ RETSIGTYPE do_suspend(int signal)
|
|||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
|
||||
/* We used to re-enable the default SIG_DFL and raise SIGTSTP, but
|
||||
then we could be (and were) interrupted in the middle of the call.
|
||||
So we do it the mutt way instead */
|
||||
then we could be (and were) interrupted in the middle of the call.
|
||||
So we do it the mutt way instead */
|
||||
kill(0, SIGSTOP);
|
||||
}
|
||||
|
||||
|
@ -2833,7 +2835,7 @@ void handle_sigwinch(int s)
|
|||
int result = 0;
|
||||
struct winsize win;
|
||||
|
||||
if (!tty)
|
||||
if (tty == NULL)
|
||||
return;
|
||||
fd = open(tty, O_RDWR);
|
||||
if (fd == -1)
|
||||
|
@ -2933,9 +2935,11 @@ void do_toggle(const toggle *which)
|
|||
case TOGGLE_SUSPEND_KEY:
|
||||
signal_init();
|
||||
break;
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
case TOGGLE_MOUSE_KEY:
|
||||
mouse_init();
|
||||
break;
|
||||
#endif
|
||||
case TOGGLE_NOHELP_KEY:
|
||||
wclear(bottomwin);
|
||||
wrefresh(bottomwin);
|
||||
|
@ -2950,9 +2954,11 @@ void do_toggle(const toggle *which)
|
|||
case TOGGLE_MAC_KEY:
|
||||
UNSET(DOS_FILE);
|
||||
break;
|
||||
#ifdef ENABLE_COLOR
|
||||
case TOGGLE_SYNTAX_KEY:
|
||||
edit_refresh();
|
||||
break;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We are assuming here that shortcut_init() above didn't free and
|
||||
|
@ -2968,21 +2974,21 @@ void do_toggle(const toggle *which)
|
|||
/* This function returns the correct keystroke, given the A,B,C or D
|
||||
input key. This is a common sequence of many terms which send
|
||||
Esc-O-[A-D] or Esc-[-[A-D]. */
|
||||
int ABCD(int input)
|
||||
int abcd(int input)
|
||||
{
|
||||
switch (input) {
|
||||
case 'A':
|
||||
case 'a':
|
||||
return (KEY_UP);
|
||||
return KEY_UP;
|
||||
case 'B':
|
||||
case 'b':
|
||||
return (KEY_DOWN);
|
||||
return KEY_DOWN;
|
||||
case 'C':
|
||||
case 'c':
|
||||
return (KEY_RIGHT);
|
||||
return KEY_RIGHT;
|
||||
case 'D':
|
||||
case 'd':
|
||||
return (KEY_LEFT);
|
||||
return KEY_LEFT;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -3007,7 +3013,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
int option_index = 0;
|
||||
struct option long_options[] = {
|
||||
const struct option long_options[] = {
|
||||
{"help", 0, 0, 'h'},
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
{"multibuffer", 0, 0, 'F'},
|
||||
|
@ -3029,7 +3035,9 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
{"const", 0, 0, 'c'},
|
||||
{"nofollow", 0, 0, 'l'},
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
{"mouse", 0, 0, 'm'},
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
{"operatingdir", 1, 0, 'o'},
|
||||
#endif
|
||||
|
@ -3060,16 +3068,11 @@ int main(int argc, char *argv[])
|
|||
};
|
||||
#endif
|
||||
|
||||
/* Flag inits... */
|
||||
SET(FOLLOW_SYMLINKS);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef ENABLE_NLS
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
{
|
||||
|
@ -3151,13 +3154,10 @@ int main(int argc, char *argv[])
|
|||
SET(NO_CONVERT);
|
||||
break;
|
||||
#endif
|
||||
case 'Q':
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
case 'Q':
|
||||
quotestr = optarg;
|
||||
break;
|
||||
#else
|
||||
usage();
|
||||
exit(1);
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
case 'R':
|
||||
|
@ -3208,11 +3208,13 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
#endif
|
||||
case 'l':
|
||||
UNSET(FOLLOW_SYMLINKS);
|
||||
SET(NOFOLLOW_SYMLINKS);
|
||||
break;
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
case 'm':
|
||||
SET(USE_MOUSE);
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
case 'o':
|
||||
operating_dir = mallocstrcpy(operating_dir, optarg);
|
||||
|
@ -3249,14 +3251,11 @@ int main(int argc, char *argv[])
|
|||
case 'v':
|
||||
SET(VIEW_MODE);
|
||||
break;
|
||||
case 'w':
|
||||
#ifdef DISABLE_WRAPPING
|
||||
usage();
|
||||
exit(0);
|
||||
#else
|
||||
case 'w':
|
||||
SET(NO_WRAP);
|
||||
break;
|
||||
#endif /* DISABLE_WRAPPING */
|
||||
#endif
|
||||
case 'x':
|
||||
SET(NO_HELP);
|
||||
break;
|
||||
|
@ -3281,8 +3280,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* See if we were invoked with the name "pico" */
|
||||
argv0 = strrchr(argv[0], '/');
|
||||
if ((argv0 && strstr(argv0, "pico"))
|
||||
|| (!argv0 && strstr(argv[0], "pico")))
|
||||
if ((argv0 != NULL && strstr(argv0, "pico") != NULL)
|
||||
|| (argv0 == NULL && strstr(argv[0], "pico") != NULL))
|
||||
SET(PICO_MODE);
|
||||
|
||||
/* See if there's a non-option in argv (first non-option is the
|
||||
|
@ -3326,7 +3325,9 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
window_init();
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
mouse_init();
|
||||
#endif
|
||||
|
||||
if (!ISSET(ALT_KEYPAD)) {
|
||||
keypad(edit, TRUE);
|
||||
|
@ -3374,7 +3375,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
while (1) {
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined(DISABLE_HELP)
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
||||
currshortcut = main_list;
|
||||
#endif
|
||||
|
||||
|
@ -3394,7 +3395,7 @@ int main(int argc, char *argv[])
|
|||
kbinput = wgetch(edit);
|
||||
if ((kbinput <= 'D' && kbinput >= 'A') ||
|
||||
(kbinput <= 'd' && kbinput >= 'a'))
|
||||
kbinput = ABCD(kbinput);
|
||||
kbinput = abcd(kbinput);
|
||||
else if (kbinput <= 'z' && kbinput >= 'j')
|
||||
print_numlock_warning();
|
||||
else if (kbinput <= 'S' && kbinput >= 'P')
|
||||
|
@ -3513,7 +3514,7 @@ int main(int argc, char *argv[])
|
|||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
kbinput = ABCD(kbinput);
|
||||
kbinput = abcd(kbinput);
|
||||
break;
|
||||
case 'H':
|
||||
kbinput = KEY_HOME;
|
||||
|
@ -3590,7 +3591,7 @@ int main(int argc, char *argv[])
|
|||
/* Look through the main shortcut list to see if we've hit a
|
||||
shortcut key */
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
|
||||
#if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
||||
for (s = currshortcut; s != NULL && !keyhandled; s = s->next) {
|
||||
#else
|
||||
for (s = main_list; s != NULL && !keyhandled; s = s->next) {
|
||||
|
@ -3628,12 +3629,8 @@ int main(int argc, char *argv[])
|
|||
keyhandled = 1;
|
||||
}
|
||||
|
||||
#ifndef USE_SLANG
|
||||
/* Hack, make insert key do something useful, like insert file */
|
||||
if (kbinput == KEY_IC) {
|
||||
#else
|
||||
if (0) {
|
||||
#endif
|
||||
do_insertkey:
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
|
@ -3654,12 +3651,10 @@ int main(int argc, char *argv[])
|
|||
/* Last gasp, stuff that's not in the main lists */
|
||||
if (!keyhandled)
|
||||
switch (kbinput) {
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
case KEY_MOUSE:
|
||||
do_mouse();
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
case 0: /* Erg */
|
||||
|
|
17
nano.h
17
nano.h
|
@ -39,7 +39,8 @@
|
|||
|
||||
#ifdef USE_SLANG /* Slang support enabled */
|
||||
#include <slcurses.h>
|
||||
#define KEY_DC 0x113
|
||||
#define KEY_IC SL_KEY_IC
|
||||
#define KEY_DC SL_KEY_DELETE
|
||||
#elif defined(HAVE_NCURSES_H)
|
||||
#include <ncurses.h>
|
||||
#else /* Uh oh */
|
||||
|
@ -71,6 +72,15 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_STRCASECMP) || !defined(HAVE_STRNCASECMP)
|
||||
# ifndef HAVE_STRCASECMP
|
||||
# define strcasecmp strcmp
|
||||
# endif
|
||||
# ifndef HAVE_STRNCASECMP
|
||||
# define strncasecmp strncmp
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* HP-UX 10 & 11 do not seem to support KEY_HOME and KEY_END */
|
||||
#ifndef KEY_HOME
|
||||
#define KEY_HOME -1
|
||||
|
@ -80,7 +90,6 @@
|
|||
#define KEY_END -1
|
||||
#endif /* KEY_END */
|
||||
|
||||
|
||||
#define VERMSG "GNU nano " VERSION
|
||||
|
||||
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
|
||||
|
@ -191,7 +200,7 @@ typedef struct syntaxtype {
|
|||
#define CONSTUPDATE (1<<4)
|
||||
#define NO_HELP (1<<5)
|
||||
#define PICO_MODE (1<<6)
|
||||
#define FOLLOW_SYMLINKS (1<<7)
|
||||
#define NOFOLLOW_SYMLINKS (1<<7)
|
||||
#define SUSPEND (1<<8)
|
||||
#define NO_WRAP (1<<9)
|
||||
#define AUTOINDENT (1<<10)
|
||||
|
@ -213,7 +222,7 @@ typedef struct syntaxtype {
|
|||
#define NO_CONVERT (1<<26)
|
||||
#define BACKUP_FILE (1<<27)
|
||||
#define NO_RCFILE (1<<28)
|
||||
#define COLOR_SYNTAX (1<<28)
|
||||
#define COLOR_SYNTAX (1<<29)
|
||||
|
||||
/* Control key sequences, changing these would be very very bad */
|
||||
|
||||
|
|
11
proto.h
11
proto.h
|
@ -33,7 +33,9 @@ extern int wrap_at;
|
|||
extern int editwinrows;
|
||||
extern int current_x, current_y, totlines;
|
||||
extern int placewewant;
|
||||
#ifndef NANO_SMALL
|
||||
extern int mark_beginx;
|
||||
#endif
|
||||
extern long totsize;
|
||||
extern int temp_opt;
|
||||
extern int wrap_at, flags, tabsize;
|
||||
|
@ -64,7 +66,10 @@ extern char *alt_speller;
|
|||
|
||||
extern struct stat fileinfo;
|
||||
extern filestruct *current, *fileage, *edittop, *editbot, *filebot;
|
||||
extern filestruct *cutbuffer, *mark_beginbuf;
|
||||
extern filestruct *cutbuffer;
|
||||
#ifndef NANO_SMALL
|
||||
extern filestruct *mark_beginbuf;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
extern openfilestruct *open_files;
|
||||
|
@ -215,7 +220,9 @@ 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)
|
||||
void mouse_init(void);
|
||||
#endif
|
||||
#ifndef DISABLE_HELP
|
||||
void help_init(void);
|
||||
#endif
|
||||
|
@ -300,7 +307,7 @@ void print_numlock_warning(void);
|
|||
#ifndef NANO_SMALL
|
||||
void do_toggle(const toggle *which);
|
||||
#endif
|
||||
int ABCD(int input);
|
||||
int abcd(int input);
|
||||
|
||||
/* Public functions in rcfile.c */
|
||||
#ifdef ENABLE_NANORC
|
||||
|
|
12
rcfile.c
12
rcfile.c
|
@ -50,7 +50,7 @@ const static rcoption rcopts[] = {
|
|||
{"fill", 0},
|
||||
#endif
|
||||
{"keypad", ALT_KEYPAD},
|
||||
#ifndef DISABLE_MOUSE
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
{"mouse", USE_MOUSE},
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
|
@ -59,7 +59,7 @@ const static rcoption rcopts[] = {
|
|||
#ifndef NANO_SMALL
|
||||
{"noconvert", NO_CONVERT},
|
||||
#endif
|
||||
{"nofollow", FOLLOW_SYMLINKS},
|
||||
{"nofollow", NOFOLLOW_SYMLINKS},
|
||||
{"nohelp", NO_HELP},
|
||||
#ifndef DISABLE_WRAPPING
|
||||
{"nowrap", NO_WRAP},
|
||||
|
@ -68,7 +68,7 @@ const static rcoption rcopts[] = {
|
|||
{"operatingdir", 0},
|
||||
#endif
|
||||
{"pico", PICO_MODE},
|
||||
#ifndef NANO_SMALL
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
{"quotestr", 0},
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
|
@ -403,7 +403,7 @@ void parse_colors(char *ptr)
|
|||
else {
|
||||
if (ptr == NULL || strncasecmp(ptr, "end=", 4)) {
|
||||
rcfile_error(_
|
||||
("\n\t\"start=\" requires a corresponding \"end=\""));
|
||||
("\"start=\" requires a corresponding \"end=\""));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ void parse_rcfile(FILE *rcstream)
|
|||
/* Else skip to the next space */
|
||||
keyword = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
if (!ptr)
|
||||
if (ptr == NULL)
|
||||
continue;
|
||||
|
||||
/* Else try to parse the keyword */
|
||||
|
@ -485,7 +485,7 @@ void parse_rcfile(FILE *rcstream)
|
|||
fprintf(stderr, _("parse_rcfile: Parsing option %s\n"),
|
||||
rcopts[i].name);
|
||||
#endif
|
||||
if (set == 1 || rcopts[i].flag == FOLLOW_SYMLINKS) {
|
||||
if (set == 1) {
|
||||
if (!strcasecmp(rcopts[i].name, "tabsize")
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
|| !strcasecmp(rcopts[i].name, "operatingdir")
|
||||
|
|
35
search.c
35
search.c
|
@ -30,6 +30,9 @@
|
|||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
static int past_editbuff;
|
||||
/* findnextstr() is now searching lines not displayed */
|
||||
|
||||
/* Regular expression helper functions */
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
|
@ -101,7 +104,7 @@ int search_init(int replacing)
|
|||
search_init_globals();
|
||||
|
||||
/* Clear the backupstring if we've changed from Pico mode to regular
|
||||
mode */
|
||||
mode */
|
||||
if (ISSET(CLEAR_BACKUPSTRING)) {
|
||||
free(backupstring);
|
||||
backupstring = NULL;
|
||||
|
@ -117,14 +120,16 @@ int search_init(int replacing)
|
|||
last_search. */
|
||||
|
||||
if (ISSET(PICO_MODE)) {
|
||||
if (backupstring == NULL || !strcmp(backupstring, last_search))
|
||||
backupstring = mallocstrcpy(backupstring, "");
|
||||
if (backupstring == NULL || !strcmp(backupstring, last_search)) {
|
||||
backupstring = charalloc(1);
|
||||
backupstring[0] = '\0';
|
||||
}
|
||||
}
|
||||
else if (backupstring == NULL)
|
||||
backupstring = mallocstrcpy(backupstring, last_search);
|
||||
|
||||
/* If using Pico messages, we do things the old fashioned way... */
|
||||
if (ISSET(PICO_MODE) && last_search[0]) {
|
||||
if (ISSET(PICO_MODE) && last_search[0] != '\0') {
|
||||
buf = charalloc(COLS / 3 + 7);
|
||||
/* We use COLS / 3 here because we need to see more on the line */
|
||||
sprintf(buf, " [%.*s%s]", COLS / 3, last_search,
|
||||
|
@ -227,9 +232,6 @@ int is_whole_word(int curr_pos, const char *datastr, const char *searchword)
|
|||
(sln == strlen(datastr) || !isalpha((int) datastr[sln]));
|
||||
}
|
||||
|
||||
static int past_editbuff;
|
||||
/* findnextstr() is now searching lines not displayed */
|
||||
|
||||
filestruct *findnextstr(int quiet, int bracket_mode,
|
||||
const filestruct *begin, int beginx,
|
||||
const char *needle)
|
||||
|
@ -326,7 +328,7 @@ filestruct *findnextstr(int quiet, int bracket_mode,
|
|||
if (fileptr == edittop->prev)
|
||||
past_editbuff = 1;
|
||||
|
||||
/* SOF reached ?, wrap around once */
|
||||
/* SOF reached?, wrap around once */
|
||||
/* ? */ if (fileptr == NULL) {
|
||||
if (bracket_mode)
|
||||
return NULL;
|
||||
|
@ -416,8 +418,7 @@ int do_search(void)
|
|||
search_last_line = 0;
|
||||
didfind = findnextstr(FALSE, FALSE, current, current_x, answer);
|
||||
|
||||
if ((fileptr == current) && (fileptr_x == current_x) &&
|
||||
didfind != NULL)
|
||||
if ((fileptr == current) && (fileptr_x == current_x) && didfind != NULL)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
|
||||
search_abort();
|
||||
|
@ -451,7 +452,7 @@ int replace_regexp(char *string, int create_flag)
|
|||
* replacement using \1, \2, \3, etc. */
|
||||
|
||||
c = last_replace;
|
||||
while (*c) {
|
||||
while (*c != '\0') {
|
||||
if (*c != '\\') {
|
||||
if (create_flag)
|
||||
*string++ = *c;
|
||||
|
@ -532,7 +533,7 @@ char *replace_line(void)
|
|||
strcat(copy, last_replace);
|
||||
#ifdef HAVE_REGEX_H
|
||||
else
|
||||
(void) replace_regexp(copy + current_x, 1);
|
||||
replace_regexp(copy + current_x, 1);
|
||||
#endif
|
||||
|
||||
/* The tail of the original line */
|
||||
|
@ -593,7 +594,7 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
|||
FALSE, begin, *beginx, prevanswer);
|
||||
|
||||
/* No more matches. Done! */
|
||||
if (!fileptr)
|
||||
if (fileptr == NULL)
|
||||
break;
|
||||
|
||||
/* Make sure only whole words are found */
|
||||
|
@ -616,7 +617,7 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
|||
replaceall = 1;
|
||||
|
||||
copy = replace_line();
|
||||
if (!copy) {
|
||||
if (copy == NULL) {
|
||||
statusbar(_("Replace failed: unknown subexpression!"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
|
@ -773,7 +774,7 @@ int do_gotoline(int line, int save_pos)
|
|||
|
||||
current_x = 0;
|
||||
|
||||
/* if save_pos is non-zero, don't change the cursor position when
|
||||
/* if save_pos is nonzero, don't change the cursor position when
|
||||
updating the edit window */
|
||||
if (save_pos)
|
||||
edit_update(current, NONE);
|
||||
|
@ -820,7 +821,7 @@ int do_find_bracket(void)
|
|||
|
||||
ch_under_cursor = current->data[current_x];
|
||||
|
||||
if ((!(pos = strchr(brackets, ch_under_cursor))) || (!((offset = pos - brackets) < 8))) {
|
||||
if (((pos = strchr(brackets, ch_under_cursor)) == NULL) || (((offset = pos - brackets) < 8) == 0)) {
|
||||
statusbar(_("Not a bracket"));
|
||||
return 1;
|
||||
}
|
||||
|
@ -850,7 +851,7 @@ int do_find_bracket(void)
|
|||
|
||||
while (1) {
|
||||
search_last_line = 0;
|
||||
if (findnextstr(1, 1, current, current_x, regexp_pat)) {
|
||||
if (findnextstr(1, 1, current, current_x, regexp_pat) != NULL) {
|
||||
have_past_editbuff |= past_editbuff;
|
||||
if (current->data[current_x] == ch_under_cursor) /* found identical bracket */
|
||||
count++;
|
||||
|
|
42
utils.c
42
utils.c
|
@ -32,10 +32,8 @@
|
|||
|
||||
int is_cntrl_char(int c)
|
||||
{
|
||||
if (iscntrl(c) || ((c & 127) != 127 && iscntrl(c & 127)))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
return (-128 <= c && c < -96) || (0 <= c && c < 32) ||
|
||||
(127 <= c && c < 160);
|
||||
}
|
||||
|
||||
int num_of_digits(int n)
|
||||
|
@ -120,20 +118,20 @@ const char *revstristr(const char *haystack, const char *needle,
|
|||
#endif /* !NANO_SMALL */
|
||||
|
||||
/* This is now mutt's version (called mutt_stristr) because it doesn't
|
||||
use memory allocation to do a simple search (yuck). */
|
||||
* use memory allocation to do a simple search (yuck). */
|
||||
const char *stristr(const char *haystack, const char *needle)
|
||||
{
|
||||
const char *p, *q;
|
||||
|
||||
if (!haystack)
|
||||
if (haystack == NULL)
|
||||
return NULL;
|
||||
if (!needle)
|
||||
return (haystack);
|
||||
if (needle == NULL)
|
||||
return haystack;
|
||||
|
||||
while (*(p = haystack)) {
|
||||
for (q = needle; *p && *q && tolower(*p) == tolower(*q); p++, q++)
|
||||
while (*(p = haystack) != '\0') {
|
||||
for (q = needle; *p != 0 && *q != 0 && tolower(*p) == tolower(*q); p++, q++)
|
||||
;
|
||||
if (!*q)
|
||||
if (*q == 0)
|
||||
return haystack;
|
||||
haystack++;
|
||||
}
|
||||
|
@ -191,7 +189,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
|||
* screen. Note that nperror causes the window to flicker once. */
|
||||
void nperror(const char *s)
|
||||
{
|
||||
/* leave ncurses mode, go to the terminal */
|
||||
/* leave ncurses mode, go to the terminal */
|
||||
if (endwin() != ERR) {
|
||||
perror(s); /* print the error */
|
||||
total_refresh(); /* return to ncurses and repaint */
|
||||
|
@ -205,14 +203,14 @@ void *nmalloc(size_t howmuch)
|
|||
|
||||
/* Panic save? */
|
||||
|
||||
if (!(r = malloc(howmuch)))
|
||||
if ((r = malloc(howmuch)) == NULL)
|
||||
die(_("nano: malloc: out of memory!"));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* We're going to need this too - Hopefully this will minimize
|
||||
the transition cost of moving to the appropriate function. */
|
||||
/* We're going to need this too - Hopefully this will minimize the
|
||||
* transition cost of moving to the appropriate function. */
|
||||
char *charalloc(size_t howmuch)
|
||||
{
|
||||
char *r = (char *)malloc(howmuch * sizeof(char));
|
||||
|
@ -227,7 +225,7 @@ void *nrealloc(void *ptr, size_t howmuch)
|
|||
{
|
||||
void *r;
|
||||
|
||||
if (!(r = realloc(ptr, howmuch)))
|
||||
if ((r = realloc(ptr, howmuch)) == NULL)
|
||||
die(_("nano: realloc: out of memory!"));
|
||||
|
||||
return r;
|
||||
|
@ -240,10 +238,10 @@ char *mallocstrcpy(char *dest, const char *src)
|
|||
if (src == dest)
|
||||
return dest;
|
||||
|
||||
if (dest)
|
||||
if (dest != NULL)
|
||||
free(dest);
|
||||
|
||||
if (!src)
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
dest = charalloc(strlen(src) + 1);
|
||||
|
@ -292,7 +290,7 @@ int check_wildcard_match(const char *text, const char *pattern)
|
|||
retrypat = NULL;
|
||||
retrytext = NULL;
|
||||
|
||||
while (*text || *pattern) {
|
||||
while (*text != '\0' || *pattern != '\0') {
|
||||
ch = *pattern++;
|
||||
|
||||
switch (ch) {
|
||||
|
@ -346,12 +344,12 @@ int check_wildcard_match(const char *text, const char *pattern)
|
|||
|
||||
default:
|
||||
if (*text == ch) {
|
||||
if (*text)
|
||||
if (*text != '\0')
|
||||
text++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*text) {
|
||||
if (*text != '\0') {
|
||||
pattern = retrypat;
|
||||
text = ++retrytext;
|
||||
break;
|
||||
|
@ -360,7 +358,7 @@ int check_wildcard_match(const char *text, const char *pattern)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pattern)
|
||||
if (pattern == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
109
winio.c
109
winio.c
|
@ -210,7 +210,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||
else
|
||||
answer[0] = '\0';
|
||||
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
#if !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
|
||||
currshortcut = s;
|
||||
#endif
|
||||
|
||||
|
@ -261,12 +261,10 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||
case 545: /* Right alt again */
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
case KEY_MOUSE:
|
||||
do_mouse();
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case NANO_HOME_KEY:
|
||||
case KEY_HOME:
|
||||
|
@ -515,7 +513,7 @@ void bottombars(const shortcut *s)
|
|||
s = s->next;
|
||||
if (s == NULL)
|
||||
goto break_completely_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break_completely_out:
|
||||
|
@ -572,8 +570,8 @@ void reset_cursor(void)
|
|||
const filestruct *ptr = edittop;
|
||||
size_t x;
|
||||
|
||||
/* Yuck. This condition can be true after open_file when opening the
|
||||
* first file. */
|
||||
/* Yuck. This condition can be true after open_file() when opening
|
||||
* the first file. */
|
||||
if (edittop == NULL)
|
||||
return;
|
||||
|
||||
|
@ -640,8 +638,8 @@ void edit_add(const filestruct *fileptr, int yval, int start
|
|||
while (k < start + COLS) {
|
||||
/* Note the fifth parameter to regexec. It says not to
|
||||
* match the beginning-of-line character unless
|
||||
* k == 0. If regexec returns non-zero, there are
|
||||
* no more matches in the line. */
|
||||
* k == 0. If regexec returns nonzero, there are no
|
||||
* more matches in the line. */
|
||||
if (regexec(&start_regexp, &fileptr->data[k], 1,
|
||||
&startmatch, k == 0 ? 0 : REG_NOTBOL))
|
||||
break;
|
||||
|
@ -732,14 +730,12 @@ void edit_add(const filestruct *fileptr, int yval, int start
|
|||
* fileptr and after the start. Is there an end after
|
||||
* the start at all? We don't paint unterminated starts. */
|
||||
end_line = fileptr;
|
||||
while (end_line != NULL &&
|
||||
regexec(&end_regexp, end_line->data, 1,
|
||||
&endmatch, 0))
|
||||
while (end_line != NULL && regexec(&end_regexp, end_line->data,
|
||||
1, &endmatch, 0))
|
||||
end_line = end_line->next;
|
||||
|
||||
/* No end found, or it is too early. */
|
||||
if (end_line == NULL ||
|
||||
end_line->lineno < fileptr->lineno ||
|
||||
if (end_line == NULL || end_line->lineno < fileptr->lineno ||
|
||||
(end_line == fileptr && endmatch.rm_eo <= start))
|
||||
goto step_two;
|
||||
|
||||
|
@ -801,9 +797,8 @@ void edit_add(const filestruct *fileptr, int yval, int start
|
|||
/* There is no end on this line. But we haven't
|
||||
* yet looked for one on later lines. */
|
||||
end_line = fileptr->next;
|
||||
while (end_line != NULL &&
|
||||
regexec(&end_regexp, end_line->data, 1,
|
||||
&endmatch, 0))
|
||||
while (end_line != NULL && regexec(&end_regexp,
|
||||
end_line->data, 1, &endmatch, 0))
|
||||
end_line = end_line->next;
|
||||
if (end_line != NULL) {
|
||||
assert(0 <= x_start && x_start < COLS);
|
||||
|
@ -900,7 +895,7 @@ void update_line(filestruct *fileptr, int index)
|
|||
size_t pos;
|
||||
size_t page_start;
|
||||
|
||||
if (!fileptr)
|
||||
if (fileptr == NULL)
|
||||
return;
|
||||
|
||||
line = fileptr->lineno - edittop->lineno;
|
||||
|
@ -996,9 +991,6 @@ void center_cursor(void)
|
|||
/* Refresh the screen without changing the position of lines. */
|
||||
void edit_refresh(void)
|
||||
{
|
||||
static int noloop = 0;
|
||||
int nlines = 0, currentcheck = 0;
|
||||
|
||||
/* Neither of these conditions should occur, but they do. edittop is
|
||||
* NULL when you open an existing file on the command line, and
|
||||
* ENABLE_COLOR is defined. Yuck. */
|
||||
|
@ -1007,40 +999,35 @@ void edit_refresh(void)
|
|||
if (edittop == NULL)
|
||||
edittop = current;
|
||||
|
||||
/* Don't make the cursor jump around the screen whilst updating */
|
||||
leaveok(edit, TRUE);
|
||||
|
||||
editbot = edittop;
|
||||
while (nlines < editwinrows) {
|
||||
update_line(editbot, current_x);
|
||||
if (editbot == current)
|
||||
currentcheck = 1;
|
||||
|
||||
nlines++;
|
||||
|
||||
if (editbot->next == NULL)
|
||||
break;
|
||||
editbot = editbot->next;
|
||||
}
|
||||
|
||||
/* If noloop == 1, then we already did an edit_update without finishing
|
||||
this function. So we don't run edit_update again */
|
||||
if (!currentcheck && !noloop) {
|
||||
/* Then current has run off the screen... */
|
||||
if (current->lineno >= edittop->lineno + editwinrows)
|
||||
/* Note that edit_update() changes edittop so that
|
||||
* current->lineno = edittop->lineno + editwinrows / 2. Thus
|
||||
* when it then calls edit_refresh(), there is no danger of
|
||||
* getting an infinite loop. */
|
||||
edit_update(current, CENTER);
|
||||
noloop = 1;
|
||||
} else if (noloop)
|
||||
noloop = 0;
|
||||
else {
|
||||
int nlines = 0;
|
||||
|
||||
while (nlines < editwinrows) {
|
||||
mvwaddstr(edit, nlines, 0, hblank);
|
||||
nlines++;
|
||||
/* Don't make the cursor jump around the screen whilst updating */
|
||||
leaveok(edit, TRUE);
|
||||
|
||||
editbot = edittop;
|
||||
while (nlines < editwinrows) {
|
||||
update_line(editbot, current_x);
|
||||
nlines++;
|
||||
if (editbot->next == NULL)
|
||||
break;
|
||||
editbot = editbot->next;
|
||||
}
|
||||
while (nlines < editwinrows) {
|
||||
mvwaddstr(edit, nlines, 0, hblank);
|
||||
nlines++;
|
||||
}
|
||||
/* What the hell are we expecting to update the screen if this
|
||||
isn't here? Luck?? */
|
||||
wrefresh(edit);
|
||||
leaveok(edit, FALSE);
|
||||
}
|
||||
|
||||
/* What the hell are we expecting to update the screen if this isn't
|
||||
here? Luck?? */
|
||||
wrefresh(edit);
|
||||
leaveok(edit, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1137,8 +1124,8 @@ int statusq(int tabs, const shortcut *s, const char *def,
|
|||
|
||||
/*
|
||||
* Ask a simple yes/no question on the statusbar. Returns 1 for Y, 0
|
||||
* for N, 2 for All (if all is non-zero when passed in) and -1 for
|
||||
* abort (^C).
|
||||
* for N, 2 for All (if all is nonzero when passed in) and -1 for abort
|
||||
* (^C).
|
||||
*/
|
||||
int do_yesno(int all, int leavecursor, const char *msg, ...)
|
||||
{
|
||||
|
@ -1148,10 +1135,8 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
|
|||
const char *yesstr; /* String of yes characters accepted */
|
||||
const char *nostr; /* Same for no */
|
||||
const char *allstr; /* And all, surprise! */
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
MEVENT mevent;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Yes, no and all are strings of any length. Each string consists of
|
||||
|
@ -1204,8 +1189,7 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
|
|||
kbinput = wgetch(edit);
|
||||
|
||||
switch (kbinput) {
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
case KEY_MOUSE:
|
||||
|
||||
/* Look ma! We get to duplicate lots of code from do_mouse!! */
|
||||
|
@ -1232,7 +1216,6 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
|
|||
ungetch(yesnosquare[mevent.y][mevent.x / (COLS / 6)]);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case NANO_CONTROL_C:
|
||||
ok = -2;
|
||||
|
@ -1436,12 +1419,10 @@ int do_help(void)
|
|||
const char *ptr = help_text;
|
||||
|
||||
switch (kbinput) {
|
||||
#ifndef DISABLE_MOUSE
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
|
||||
case KEY_MOUSE:
|
||||
do_mouse();
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case 27:
|
||||
kbinput = wgetch(edit);
|
||||
|
@ -1562,7 +1543,7 @@ int do_help(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int keypad_on(WINDOW * win, int newval)
|
||||
int keypad_on(WINDOW *win, int newval)
|
||||
{
|
||||
/* This is taken right from aumix. Don't sue me. */
|
||||
#ifdef HAVE_USEKEYPAD
|
||||
|
|
Loading…
Reference in New Issue