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:
shortcut_init()
- Fix erroneous #ifdef so that nano compiles with
--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:
parse_rcfile()
- Have whitespace display default to off instead of on. (Mike
wrap_reset();
#endif
-#if !defined(DISABLE_BROWSER) || !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
- start_again: /* Goto here when the user cancels the file browser. */
-#endif
-
+ start_again:
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = insertfile_list;
#endif
titlebar(NULL);
/* And re-init the shortcut list */
- shortcut_init(0);
+ shortcut_init(FALSE);
}
#endif
unlink_opennode(tmp);
delete_opennode(tmp);
- shortcut_init(0);
+ shortcut_init(FALSE);
display_main_list();
return 0;
}
* 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)
i++;
/* Now add our shortcut info */
for (s = currshortcut; s != NULL; s = s->next) {
/* 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) {
#ifndef NANO_SMALL
}
#ifndef NANO_SMALL
else if (s->metaval != NANO_NO_KEY) {
- meta_shortcut = 1;
+ meta_shortcut = TRUE;
if (s->metaval == NANO_ALT_SPACE)
ptr += snprintf(ptr, 8, "M-%.5s", _("Space"));
else
{
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
we're not in a subfunction. */
if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) {
xcur = actual_x(current->data, get_page_start(xplustabs()) +
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
end of the line. */
if (sameline && xcur == current_x) {
/* Only reload the temp file if it isn't a marked selection. */
#endif
free_filestruct(fileage);
- global_init(1);
+ global_init(TRUE);
open_file(tempfile_name, 0, 1);
#ifndef NANO_SMALL
}
filestruct *mark_beginbuf_save = mark_beginbuf;
int mark_beginx_save = mark_beginx;
#endif
+ int kbinput;
+ int meta_key;
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 (full_justify)
statusbar(_("Can now UnJustify!"));
/* Display the shortcut list with UnJustify. */
- shortcut_init(1);
+ shortcut_init(TRUE);
display_main_list();
reset_cursor();
/* Now get a keystroke and see if it's unjustify; if not, unget the
* keystroke and return. */
- {
- int meta_key;
- i = get_kbinput(edit, &meta_key);
+ kbinput = 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 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 (i != NANO_UNJUSTIFY_KEY && i != NANO_UNJUSTIFY_FKEY) {
- ungetch(i);
+ if (meta_key || (kbinput != NANO_UNJUSTIFY_KEY &&
+ kbinput != NANO_UNJUSTIFY_FKEY)) {
+ ungetch(kbinput);
+ if (meta_key)
+ ungetch(NANO_CONTROL_3);
placewewant = 0;
} else {
/* Else restore the justify we just did (ungrateful user!). */
titlebar(NULL);
edit_refresh();
}
+
cutbuffer = cutbuffer_save;
/* Note that now cutbottom is invalid, but that's okay. */
blank_statusbar();
/* Display the shortcut list with UnCut. */
- shortcut_init(0);
+ shortcut_init(FALSE);
display_main_list();
return 0;
#endif
/* Set up the global variables and the shortcuts. */
- global_init(0);
- shortcut_init(0);
+ global_init(FALSE);
+ shortcut_init(FALSE);
/* Set up the signal handlers. */
signal_init();
cutbuffer_reset();
/* Don't even think about changing this string */
- if (kbinput == NANO_CONTROL_Q)
+ if (kbinput == NANO_XON_KEY)
statusbar(_("XON ignored, mumble mumble."));
- if (kbinput == NANO_CONTROL_S)
+ if (kbinput == NANO_XOFF_KEY)
statusbar(_("XOFF ignored, mumble mumble."));
-
- /* 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)
+ if (kbinput == NANO_XON_KEY || kbinput == NANO_XOFF_KEY)
keyhandled = TRUE;
/* Catch ^Z by hand when triggered also */
#define NANO_HISTORY_KEY -3
/* 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_FKEY KEY_F(5)
#define NANO_EXIT_KEY NANO_CONTROL_X
#define MAIN_VISIBLE 12
-#define VIEW 1
-#define NOVIEW 0
+#define VIEW TRUE
+#define NOVIEW FALSE
typedef enum {
JUSTIFY, BEGIN, END
#endif
/* 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,
#ifndef DISABLE_HELP
const char *help,
#endif
);
#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
size_t xplustabs(void);
size_t actual_x(const char *str, size_t xplus);
#ifndef DISABLE_MOUSE
/* 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,
- * if allow_shortcuts is zero, return 0. Otherwise, if the mouse event
- * took place on the shortcut list on the bottom two lines of the screen
- * (assuming that the shortcut list is visible), figure out which
- * shortcut was clicked and ungetch() the equivalent keystroke(s).
- * Return 0 if no keystrokes were ungetch()ed, or 1 if at least one was.
- * Assume that KEY_MOUSE has already been read in. */
+ * assuming allow_shortcuts is FALSE, if the shortcut list on the
+ * bottom two lines of the screen is visible and the mouse event took
+ * place on it, figure out which shortcut was clicked and ungetch() the
+ * equivalent keystroke(s). Return FALSE if no keystrokes were
+ * ungetch()ed, or TRUE if at least one was. Assume that KEY_MOUSE has
+ * already been read in. */
int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
{
MEVENT mevent;
/* First, get the actual mouse event. */
if (getmouse(&mevent) == ERR)
- return 0;
+ return FALSE;
/* Save the screen coordinates where the mouse event took place. */
*mouse_x = mevent.x;
/* If we're not allowing shortcuts' we're done now. */
if (!allow_shortcuts)
- return 0;
+ return FALSE;
/* Otherwise, if the current shortcut list is being displayed on the
* last two lines of the screen and the mouse event took place
* ungetch() the equivalent keystroke(s) for it. */
if (!ISSET(NO_HELP) && wenclose(bottomwin, *mouse_y, *mouse_x)) {
int i, j;
- int currslen;
+ size_t currslen;
/* The number of shortcuts in the current shortcut list. */
const shortcut *s = currshortcut;
/* The actual shortcut we clicked on, starting at the first
ungetch(NANO_CONTROL_3);
}
- return 1;
+ return TRUE;
}
- return 0;
+ return FALSE;
}
#endif
/* Look ma! We get to duplicate lots of code from
* do_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) &&
wenclose(bottomwin, mouse_y, mouse_x) && mouse_x <
int do_cursorpos_void(void)
{
- return do_cursorpos(0);
+ return do_cursorpos(FALSE);
}
/* Calculate the next line of help_text, starting at ptr. */