more minor cosmetic fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1834 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
0fb841a78a
commit
ebd0d7c859
|
@ -1,8 +1,17 @@
|
||||||
CVS code -
|
CVS code -
|
||||||
|
- General:
|
||||||
|
- More minor comment cleanups. (DLR)
|
||||||
|
- Convert more ints used as boolean values to use TRUE and
|
||||||
|
FALSE. (David Benbennick and DLR)
|
||||||
|
- Change more instances of ints that can never be negative to
|
||||||
|
size_t's. (DLR)
|
||||||
- global.c:
|
- global.c:
|
||||||
shortcut_init()
|
shortcut_init()
|
||||||
- Fix erroneous #ifdef so that nano compiles with
|
- Fix erroneous #ifdef so that nano compiles with
|
||||||
--disable-justify again. (DLR; found by Mike Frysinger)
|
--disable-justify again. (DLR; found by Mike Frysinger)
|
||||||
|
- proto.h:
|
||||||
|
- Change the last variable in the prototype for get_mouseinput()
|
||||||
|
to match the one used in the actual function. (DLR)
|
||||||
- rcfile.c:
|
- rcfile.c:
|
||||||
parse_rcfile()
|
parse_rcfile()
|
||||||
- Have whitespace display default to off instead of on. (Mike
|
- Have whitespace display default to off instead of on. (Mike
|
||||||
|
|
|
@ -439,10 +439,7 @@ int do_insertfile(int loading_file)
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(DISABLE_BROWSER) || !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
|
start_again:
|
||||||
start_again: /* Goto here when the user cancels the file browser. */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
|
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
|
||||||
currshortcut = insertfile_list;
|
currshortcut = insertfile_list;
|
||||||
#endif
|
#endif
|
||||||
|
@ -599,7 +596,7 @@ int do_insertfile(int loading_file)
|
||||||
titlebar(NULL);
|
titlebar(NULL);
|
||||||
|
|
||||||
/* And re-init the shortcut list */
|
/* And re-init the shortcut list */
|
||||||
shortcut_init(0);
|
shortcut_init(FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1019,7 +1016,7 @@ int close_open_file(void)
|
||||||
unlink_opennode(tmp);
|
unlink_opennode(tmp);
|
||||||
delete_opennode(tmp);
|
delete_opennode(tmp);
|
||||||
|
|
||||||
shortcut_init(0);
|
shortcut_init(FALSE);
|
||||||
display_main_list();
|
display_main_list();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,9 +172,9 @@ int curses_ended = FALSE; /* Indicates to statusbar() to simply
|
||||||
* ended curses mode. */
|
* ended curses mode. */
|
||||||
|
|
||||||
|
|
||||||
int length_of_list(const shortcut *s)
|
size_t length_of_list(const shortcut *s)
|
||||||
{
|
{
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
for (; s != NULL; s = s->next)
|
for (; s != NULL; s = s->next)
|
||||||
i++;
|
i++;
|
||||||
|
|
63
src/nano.c
63
src/nano.c
|
@ -413,7 +413,7 @@ void help_init(void)
|
||||||
/* Now add our shortcut info */
|
/* Now add our shortcut info */
|
||||||
for (s = currshortcut; s != NULL; s = s->next) {
|
for (s = currshortcut; s != NULL; s = s->next) {
|
||||||
/* true if the character in s->metaval is shown in first column */
|
/* true if the character in s->metaval is shown in first column */
|
||||||
int meta_shortcut = 0;
|
int meta_shortcut = FALSE;
|
||||||
|
|
||||||
if (s->ctrlval != NANO_NO_KEY) {
|
if (s->ctrlval != NANO_NO_KEY) {
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
@ -430,7 +430,7 @@ void help_init(void)
|
||||||
}
|
}
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
else if (s->metaval != NANO_NO_KEY) {
|
else if (s->metaval != NANO_NO_KEY) {
|
||||||
meta_shortcut = 1;
|
meta_shortcut = TRUE;
|
||||||
if (s->metaval == NANO_ALT_SPACE)
|
if (s->metaval == NANO_ALT_SPACE)
|
||||||
ptr += snprintf(ptr, 8, "M-%.5s", _("Space"));
|
ptr += snprintf(ptr, 8, "M-%.5s", _("Space"));
|
||||||
else
|
else
|
||||||
|
@ -880,8 +880,7 @@ void do_mouse(void)
|
||||||
{
|
{
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
|
|
||||||
if (get_mouseinput(&mouse_x, &mouse_y, 1) == 0) {
|
if (get_mouseinput(&mouse_x, &mouse_y, TRUE) == FALSE) {
|
||||||
|
|
||||||
/* Click in the edit window to move the cursor, but only when
|
/* Click in the edit window to move the cursor, but only when
|
||||||
we're not in a subfunction. */
|
we're not in a subfunction. */
|
||||||
if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) {
|
if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) {
|
||||||
|
@ -906,7 +905,7 @@ void do_mouse(void)
|
||||||
xcur = actual_x(current->data, get_page_start(xplustabs()) +
|
xcur = actual_x(current->data, get_page_start(xplustabs()) +
|
||||||
mouse_x);
|
mouse_x);
|
||||||
|
|
||||||
/* Selecting where the cursor is toggles the mark. As does
|
/* Selecting where the cursor is toggles the mark, as does
|
||||||
selecting beyond the line length with the cursor at the
|
selecting beyond the line length with the cursor at the
|
||||||
end of the line. */
|
end of the line. */
|
||||||
if (sameline && xcur == current_x) {
|
if (sameline && xcur == current_x) {
|
||||||
|
@ -1810,7 +1809,7 @@ const char *do_alt_speller(char *tempfile_name)
|
||||||
/* Only reload the temp file if it isn't a marked selection. */
|
/* Only reload the temp file if it isn't a marked selection. */
|
||||||
#endif
|
#endif
|
||||||
free_filestruct(fileage);
|
free_filestruct(fileage);
|
||||||
global_init(1);
|
global_init(TRUE);
|
||||||
open_file(tempfile_name, 0, 1);
|
open_file(tempfile_name, 0, 1);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
}
|
}
|
||||||
|
@ -2412,9 +2411,10 @@ int do_justify(int full_justify)
|
||||||
filestruct *mark_beginbuf_save = mark_beginbuf;
|
filestruct *mark_beginbuf_save = mark_beginbuf;
|
||||||
int mark_beginx_save = mark_beginx;
|
int mark_beginx_save = mark_beginx;
|
||||||
#endif
|
#endif
|
||||||
|
int kbinput;
|
||||||
|
int meta_key;
|
||||||
|
|
||||||
size_t indent_len; /* Generic indentation length. */
|
size_t indent_len; /* Generic indentation length. */
|
||||||
size_t i; /* Generic loop variable. */
|
|
||||||
|
|
||||||
/* If we're justifying the entire file, start at the beginning. */
|
/* If we're justifying the entire file, start at the beginning. */
|
||||||
if (full_justify)
|
if (full_justify)
|
||||||
|
@ -2645,28 +2645,29 @@ int do_justify(int full_justify)
|
||||||
|
|
||||||
statusbar(_("Can now UnJustify!"));
|
statusbar(_("Can now UnJustify!"));
|
||||||
/* Display the shortcut list with UnJustify. */
|
/* Display the shortcut list with UnJustify. */
|
||||||
shortcut_init(1);
|
shortcut_init(TRUE);
|
||||||
display_main_list();
|
display_main_list();
|
||||||
reset_cursor();
|
reset_cursor();
|
||||||
|
|
||||||
/* 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. */
|
||||||
{
|
kbinput = get_kbinput(edit, &meta_key);
|
||||||
int meta_key;
|
|
||||||
i = get_kbinput(edit, &meta_key);
|
|
||||||
#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 == KEY_MOUSE) {
|
|
||||||
do_mouse();
|
|
||||||
i = get_kbinput(edit, &meta_key);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i != NANO_UNJUSTIFY_KEY && i != NANO_UNJUSTIFY_FKEY) {
|
#ifndef DISABLE_MOUSE
|
||||||
ungetch(i);
|
/* 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 (kbinput == KEY_MOUSE) {
|
||||||
|
do_mouse();
|
||||||
|
kbinput = get_kbinput(edit, &meta_key);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (meta_key || (kbinput != NANO_UNJUSTIFY_KEY &&
|
||||||
|
kbinput != NANO_UNJUSTIFY_FKEY)) {
|
||||||
|
ungetch(kbinput);
|
||||||
|
if (meta_key)
|
||||||
|
ungetch(NANO_CONTROL_3);
|
||||||
placewewant = 0;
|
placewewant = 0;
|
||||||
} else {
|
} else {
|
||||||
/* Else restore the justify we just did (ungrateful user!). */
|
/* Else restore the justify we just did (ungrateful user!). */
|
||||||
|
@ -2704,11 +2705,12 @@ int do_justify(int full_justify)
|
||||||
titlebar(NULL);
|
titlebar(NULL);
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
cutbuffer = cutbuffer_save;
|
cutbuffer = cutbuffer_save;
|
||||||
/* Note that now cutbottom is invalid, but that's okay. */
|
/* Note that now cutbottom is invalid, but that's okay. */
|
||||||
blank_statusbar();
|
blank_statusbar();
|
||||||
/* Display the shortcut list with UnCut. */
|
/* Display the shortcut list with UnCut. */
|
||||||
shortcut_init(0);
|
shortcut_init(FALSE);
|
||||||
display_main_list();
|
display_main_list();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3501,8 +3503,8 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set up the global variables and the shortcuts. */
|
/* Set up the global variables and the shortcuts. */
|
||||||
global_init(0);
|
global_init(FALSE);
|
||||||
shortcut_init(0);
|
shortcut_init(FALSE);
|
||||||
|
|
||||||
/* Set up the signal handlers. */
|
/* Set up the signal handlers. */
|
||||||
signal_init();
|
signal_init();
|
||||||
|
@ -3642,14 +3644,11 @@ int main(int argc, char *argv[])
|
||||||
cutbuffer_reset();
|
cutbuffer_reset();
|
||||||
|
|
||||||
/* Don't even think about changing this string */
|
/* Don't even think about changing this string */
|
||||||
if (kbinput == NANO_CONTROL_Q)
|
if (kbinput == NANO_XON_KEY)
|
||||||
statusbar(_("XON ignored, mumble mumble."));
|
statusbar(_("XON ignored, mumble mumble."));
|
||||||
if (kbinput == NANO_CONTROL_S)
|
if (kbinput == NANO_XOFF_KEY)
|
||||||
statusbar(_("XOFF ignored, mumble mumble."));
|
statusbar(_("XOFF ignored, mumble mumble."));
|
||||||
|
if (kbinput == NANO_XON_KEY || kbinput == NANO_XOFF_KEY)
|
||||||
/* If we're in raw mode or using Alt-Alt-x, we have to catch
|
|
||||||
Control-S and Control-Q */
|
|
||||||
if (kbinput == NANO_CONTROL_Q || kbinput == NANO_CONTROL_S)
|
|
||||||
keyhandled = TRUE;
|
keyhandled = TRUE;
|
||||||
|
|
||||||
/* Catch ^Z by hand when triggered also */
|
/* Catch ^Z by hand when triggered also */
|
||||||
|
|
|
@ -362,6 +362,8 @@ typedef struct historyheadtype {
|
||||||
#define NANO_HISTORY_KEY -3
|
#define NANO_HISTORY_KEY -3
|
||||||
|
|
||||||
/* Normal keys. */
|
/* Normal keys. */
|
||||||
|
#define NANO_XON_KEY NANO_CONTROL_Q
|
||||||
|
#define NANO_XOFF_KEY NANO_CONTROL_S
|
||||||
#define NANO_INSERTFILE_KEY NANO_CONTROL_R
|
#define NANO_INSERTFILE_KEY NANO_CONTROL_R
|
||||||
#define NANO_INSERTFILE_FKEY KEY_F(5)
|
#define NANO_INSERTFILE_FKEY KEY_F(5)
|
||||||
#define NANO_EXIT_KEY NANO_CONTROL_X
|
#define NANO_EXIT_KEY NANO_CONTROL_X
|
||||||
|
@ -457,8 +459,8 @@ typedef struct historyheadtype {
|
||||||
|
|
||||||
#define MAIN_VISIBLE 12
|
#define MAIN_VISIBLE 12
|
||||||
|
|
||||||
#define VIEW 1
|
#define VIEW TRUE
|
||||||
#define NOVIEW 0
|
#define NOVIEW FALSE
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
JUSTIFY, BEGIN, END
|
JUSTIFY, BEGIN, END
|
||||||
|
|
|
@ -218,7 +218,7 @@ char *do_browse_from(const char *inpath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public functions in global.c */
|
/* Public functions in global.c */
|
||||||
int length_of_list(const shortcut *s);
|
size_t length_of_list(const shortcut *s);
|
||||||
void sc_init_one(shortcut **shortcutage, int key, const char *desc,
|
void sc_init_one(shortcut **shortcutage, int key, const char *desc,
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
const char *help,
|
const char *help,
|
||||||
|
@ -503,7 +503,7 @@ int get_untranslated_kbinput(int kbinput, size_t position, int
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
int get_mouseinput(int *mouse_x, int *mouse_y, int shortcut);
|
int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts);
|
||||||
#endif
|
#endif
|
||||||
size_t xplustabs(void);
|
size_t xplustabs(void);
|
||||||
size_t actual_x(const char *str, size_t xplus);
|
size_t actual_x(const char *str, size_t xplus);
|
||||||
|
|
26
src/winio.c
26
src/winio.c
|
@ -1239,12 +1239,12 @@ int get_untranslated_kbinput(int kbinput, size_t position, int
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
/* Check for a mouse event, and if one's taken place, save the
|
/* Check for a mouse event, and if one's taken place, save the
|
||||||
* coordinates where it took place in mouse_x and mouse_y. After that,
|
* coordinates where it took place in mouse_x and mouse_y. After that,
|
||||||
* if allow_shortcuts is zero, return 0. Otherwise, if the mouse event
|
* assuming allow_shortcuts is FALSE, if the shortcut list on the
|
||||||
* took place on the shortcut list on the bottom two lines of the screen
|
* bottom two lines of the screen is visible and the mouse event took
|
||||||
* (assuming that the shortcut list is visible), figure out which
|
* place on it, figure out which shortcut was clicked and ungetch() the
|
||||||
* shortcut was clicked and ungetch() the equivalent keystroke(s).
|
* equivalent keystroke(s). Return FALSE if no keystrokes were
|
||||||
* Return 0 if no keystrokes were ungetch()ed, or 1 if at least one was.
|
* ungetch()ed, or TRUE if at least one was. Assume that KEY_MOUSE has
|
||||||
* Assume that KEY_MOUSE has already been read in. */
|
* already been read in. */
|
||||||
int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||||
{
|
{
|
||||||
MEVENT mevent;
|
MEVENT mevent;
|
||||||
|
@ -1254,7 +1254,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||||
|
|
||||||
/* First, get the actual mouse event. */
|
/* First, get the actual mouse event. */
|
||||||
if (getmouse(&mevent) == ERR)
|
if (getmouse(&mevent) == ERR)
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
/* Save the screen coordinates where the mouse event took place. */
|
/* Save the screen coordinates where the mouse event took place. */
|
||||||
*mouse_x = mevent.x;
|
*mouse_x = mevent.x;
|
||||||
|
@ -1262,7 +1262,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||||
|
|
||||||
/* If we're not allowing shortcuts' we're done now. */
|
/* If we're not allowing shortcuts' we're done now. */
|
||||||
if (!allow_shortcuts)
|
if (!allow_shortcuts)
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
/* Otherwise, if the current shortcut list is being displayed on the
|
/* Otherwise, if the current shortcut list is being displayed on the
|
||||||
* last two lines of the screen and the mouse event took place
|
* last two lines of the screen and the mouse event took place
|
||||||
|
@ -1270,7 +1270,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||||
* ungetch() the equivalent keystroke(s) for it. */
|
* ungetch() the equivalent keystroke(s) for it. */
|
||||||
if (!ISSET(NO_HELP) && wenclose(bottomwin, *mouse_y, *mouse_x)) {
|
if (!ISSET(NO_HELP) && wenclose(bottomwin, *mouse_y, *mouse_x)) {
|
||||||
int i, j;
|
int i, j;
|
||||||
int currslen;
|
size_t currslen;
|
||||||
/* The number of shortcuts in the current shortcut list. */
|
/* The number of shortcuts in the current shortcut list. */
|
||||||
const shortcut *s = currshortcut;
|
const shortcut *s = currshortcut;
|
||||||
/* The actual shortcut we clicked on, starting at the first
|
/* The actual shortcut we clicked on, starting at the first
|
||||||
|
@ -1318,9 +1318,9 @@ int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||||
ungetch(NANO_CONTROL_3);
|
ungetch(NANO_CONTROL_3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2888,7 +2888,7 @@ int do_yesno(int all, const char *msg)
|
||||||
/* Look ma! We get to duplicate lots of code from
|
/* Look ma! We get to duplicate lots of code from
|
||||||
* do_mouse()!! */
|
* do_mouse()!! */
|
||||||
else if (kbinput == KEY_MOUSE) {
|
else if (kbinput == KEY_MOUSE) {
|
||||||
kbinput = get_mouseinput(&mouse_x, &mouse_y, 0);
|
kbinput = get_mouseinput(&mouse_x, &mouse_y, FALSE);
|
||||||
|
|
||||||
if (mouse_x != -1 && mouse_y != -1 && !ISSET(NO_HELP) &&
|
if (mouse_x != -1 && mouse_y != -1 && !ISSET(NO_HELP) &&
|
||||||
wenclose(bottomwin, mouse_y, mouse_x) && mouse_x <
|
wenclose(bottomwin, mouse_y, mouse_x) && mouse_x <
|
||||||
|
@ -3005,7 +3005,7 @@ int do_cursorpos(int constant)
|
||||||
|
|
||||||
int do_cursorpos_void(void)
|
int do_cursorpos_void(void)
|
||||||
{
|
{
|
||||||
return do_cursorpos(0);
|
return do_cursorpos(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the next line of help_text, starting at ptr. */
|
/* Calculate the next line of help_text, starting at ptr. */
|
||||||
|
|
Loading…
Reference in New Issue