CVS code -
+- files.c:
+ open_prevfile(), open_nextfile()
+ - Translate the "New Buffer" string when displaying "Switched
+ to" messages on the statusbar. (DLR)
+ input_tab()
+ - Fix snprintf() call so that we don't segfault when trying to
+ complete a filename containing %'s. (Ulf Härnhammar)
+- global.c:
+ shortcut_init()
+ - Move the "Cancel" shortcut up so that it's just after the "Get
+ Help" shortcut, for consistency with the other shortcut lists.
+ (DLR)
+- nano.c:
+ do_int_spell_fix()
+ - Move the REVERSE_SEARCH flag toggling into the NANO_SMALL
+ #ifdef, since the tiny version of nano doesn't support reverse
+ searching. Also, turn the USE_REGEXP flag off during spell
+ checking in order to avoid a potential segfault. (DLR)
+ quote_length()
+ - Fix problem where quoted justify wouldn't work if HAVE_REGEX_H
+ wasn't set. (David Benbennick)
+ main()
+ - Interpret the escape sequences Esc O F and Esc O H as End and
+ Home, respectively, as nanogetstr() does. Also, don't
+ interpret Esc O z as a "NumLock glitch" value. (DLR)
+ - Call setlocale() outside the ENABLE_NLS #ifdef, since UTF-8
+ support won't work properly if the locale isn't set, whether
+ NLS is enabled or not. (Junichi Uekawa)
+- winio.c:
+ blocking_wgetch()
+ - New function used in place of blocking wgetch() calls. If we
+ get ERR when using blocking input, it means that the input
+ source that we were using is gone. In this case, call
+ handle_hupterm(), so that nano dies gracefully instead of
+ going into an infinite loop. (DLR, found by Jim Uhl)
+ get_page_start()
+ - For consistency, tweak so that scrolling always occurs when we
+ try to move onto the "$" at the end of the line, as opposed to
+ (a) when we move onto the "$" at the end of the line on the
+ first page and (b) when we move onto the character just before
+ the "$" on subsequent pages. (DLR)
GNU nano 1.2.4 - 2004.06.27
- General:
load_open_file();
statusbar(_("Switched to %s"),
- ((open_files->filename[0] == '\0') ? "New Buffer" : open_files->filename));
+ ((open_files->filename[0] == '\0') ? _("New Buffer") : open_files->filename));
#ifdef DEBUG
dump_buffer(current);
load_open_file();
statusbar(_("Switched to %s"),
- ((open_files->filename[0] == '\0') ? "New Buffer" : open_files->filename));
+ ((open_files->filename[0] == '\0') ? _("New Buffer") : open_files->filename));
#ifdef DEBUG
dump_buffer(current);
/* make each filename shown be the same length as the longest
filename, with two spaces at the end */
- snprintf(foo, longestname + 1, matches[i]);
+ snprintf(foo, longestname + 1, "%s", matches[i]);
while (strlen(foo) < longestname)
strcat(foo, " ");
}
}
wrefresh(edit);
- } while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY);
+ } while ((kbinput = blocking_wgetch(edit)) != NANO_EXIT_KEY);
curs_set(1);
blank_edit();
titlebar(NULL);
sc_init_one(&writefile_list, NANO_HELP_KEY, _("Get Help"),
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
+ sc_init_one(&writefile_list, NANO_CANCEL_KEY, _("Cancel"),
+ IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
+
#ifndef DISABLE_BROWSER
/* Translators: try to keep this string under 16 characters long */
sc_init_one(&writefile_list, NANO_TOFILES_KEY, _("To Files"),
IFHELP(nano_backup_msg, 0), 0, 0, NOVIEW, 0);
#endif
- sc_init_one(&writefile_list, NANO_CANCEL_KEY, _("Cancel"),
- IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
-
free_shortcutage(&insertfile_list);
sc_init_one(&insertfile_list, NANO_HELP_KEY, _("Get Help"),
/* Save where we are. */
int i = 0;
/* The return value. */
- int reverse_search_set = ISSET(REVERSE_SEARCH);
#ifndef NANO_SMALL
int case_sens_set = ISSET(CASE_SENSITIVE);
+ int reverse_search_set = ISSET(REVERSE_SEARCH);
int mark_set = ISSET(MARK_ISSET);
+#endif
+#ifdef HAVE_REGEX_H
+ int regexp_set = ISSET(USE_REGEXP);
+#endif
+#ifndef NANO_SMALL
+ /* Make sure Spell Check is case sensitive */
SET(CASE_SENSITIVE);
+ /* Make sure Spell Check goes forward only */
+ UNSET(REVERSE_SEARCH);
/* Make sure the marking highlight is off during Spell Check */
UNSET(MARK_ISSET);
#endif
- /* Make sure Spell Check goes forward only */
- UNSET(REVERSE_SEARCH);
+#ifdef HAVE_REGEX_H
+ /* Make sure Spell Check doesn't use regular expressions */
+ UNSET(USE_REGEXP);
+#endif
/* save the current search/replace strings */
search_init_globals();
current_x = current_x_save;
edittop = edittop_save;
- /* restore Search/Replace direction */
- if (reverse_search_set)
- SET(REVERSE_SEARCH);
-
#ifndef NANO_SMALL
+ /* restore case sensitivity setting */
if (!case_sens_set)
UNSET(CASE_SENSITIVE);
+ /* restore Search/Replace direction */
+ if (reverse_search_set)
+ SET(REVERSE_SEARCH);
+
/* restore marking highlight */
if (mark_set)
SET(MARK_ISSET);
#endif
+#ifdef HAVE_REGEX_H
+ /* restore regular expression usage setting */
+ if (regexp_set)
+ SET(USE_REGEXP);
+#endif
return i != -1;
}
size_t qlen = strlen(quotestr);
/* Compute quote depth level */
- while (!strcmp(line + qdepth, quotestr))
+ while (strncmp(line + qdepth, quotestr, quotelen) == 0)
qdepth += qlen;
return qdepth;
}
#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)
+ if ((i = blocking_wgetch(edit)) == KEY_MOUSE)
do_mouse();
else
ungetch(i);
#endif
- if ((i = wgetch(edit)) != NANO_UNJUSTIFY_KEY) {
+ if ((i = blocking_wgetch(edit)) != NANO_UNJUSTIFY_KEY) {
ungetch(i);
/* Did we back up anything at all? */
if (cutbuffer != cutbuffer_save)
};
#endif
-#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
+#ifdef ENABLE_NLS
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
#endif
raw();
#endif
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
#ifdef DEBUG
fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
#endif
if (kbinput == 27) { /* Grab Alt-key stuff first */
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
switch (kbinput) {
/* Alt-O, suddenly very important ;) */
case 'O':
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
/* Shift or Ctrl + Arrows are Alt-O-[2,5,6]-[A,B,C,D] on some terms */
if (kbinput == '2' || kbinput == '5' || kbinput == '6')
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
if ((kbinput <= 'D' && kbinput >= 'A') ||
(kbinput <= 'd' && kbinput >= 'a'))
kbinput = abcd(kbinput);
- else if (kbinput <= 'z' && kbinput >= 'j')
- print_numlock_warning();
+ /* Alt-O-H and Alt-O-F are Home and End on some terms */
+ else if (kbinput == 'F')
+ kbinput = KEY_END;
+ else if (kbinput == 'H')
+ kbinput = KEY_HOME;
+ /* Alt-O-P through Alt-O-S are F1 through F4 on some terms */
else if (kbinput <= 'S' && kbinput >= 'P')
kbinput = KEY_F(kbinput - 79);
+ /* Alt-O-j through Alt-O-y are produced by the NumLock glitch */
+ else if (kbinput <= 'y' && kbinput >= 'j')
+ print_numlock_warning();
#ifdef DEBUG
else {
fprintf(stderr, "I got Alt-O-%c! (%d)\n",
keyhandled = 1;
break;
case '[':
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
switch (kbinput) {
case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
if (kbinput >= '1' && kbinput <= '5') {
kbinput = KEY_F(kbinput - 48);
- wgetch(edit);
+ blocking_wgetch(edit);
} else if (kbinput >= '7' && kbinput <= '9') {
kbinput = KEY_F(kbinput - 49);
- wgetch(edit);
+ blocking_wgetch(edit);
} else if (kbinput == '~')
kbinput = KEY_HOME;
#ifdef DEBUG
#endif
break;
case '2': /* Alt-[-2-[0,1,3,4] = F9-F12 in many terms */
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
switch (kbinput) {
case '0':
kbinput = KEY_F(9);
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case '1':
kbinput = KEY_F(10);
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case '3':
kbinput = KEY_F(11);
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case '4':
kbinput = KEY_F(12);
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case '~':
kbinput = NANO_INSERTFILE_KEY;
break;
case '3': /* Alt-[-3 = Delete? */
kbinput = NANO_DELETE_KEY;
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case '4': /* Alt-[-4 = End? */
kbinput = NANO_END_KEY;
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case '5': /* Alt-[-5 = Page Up */
kbinput = KEY_PPAGE;
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case 'V': /* Alt-[-V = Page Up in Hurd Console */
case 'I': /* Alt-[-I = Page Up - FreeBSD Console */
break;
case '6': /* Alt-[-6 = Page Down */
kbinput = KEY_NPAGE;
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case 'U': /* Alt-[-U = Page Down in Hurd Console */
case 'G': /* Alt-[-G = Page Down - FreeBSD Console */
break;
case '7':
kbinput = KEY_HOME;
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case '8':
kbinput = KEY_END;
- wgetch(edit);
+ blocking_wgetch(edit);
break;
case '9': /* Alt-[-9 = Delete in Hurd Console */
kbinput = KEY_DC;
kbinput = NANO_INSERTFILE_KEY;
break;
case '[': /* Alt-[-[-[A-E], F1-F5 in Linux console */
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
if (kbinput >= 'A' && kbinput <= 'E')
kbinput = KEY_F(kbinput - 64);
break;
#endif
/* Public functions in winio.c */
+int blocking_wgetch(WINDOW *win);
int do_first_line(void);
int do_last_line(void);
int xpt(const filestruct *fileptr, int index);
we call statusbar(), before we
actually blank the statusbar */
+int blocking_wgetch(WINDOW *win)
+{
+ int retval = wgetch(win);
+
+ /* If we get ERR when using blocking input, it means that the input
+ * source that we were using is gone, so die gracefully. */
+ if (retval == ERR)
+ handle_hupterm(0);
+
+ return retval;
+}
+
int do_first_line(void)
{
current = fileage;
input */
wrefresh(edit);
- while ((kbinput = wgetch(bottomwin)) != 13) {
+ while ((kbinput = blocking_wgetch(bottomwin)) != 13) {
for (t = s; t != NULL; t = t->next) {
#ifdef DEBUG
fprintf(stderr, "Aha! \'%c\' (%d)\n", kbinput, kbinput);
case KEY_DC:
goto do_deletekey;
case 27:
- switch (kbinput = wgetch(edit)) {
+ switch (kbinput = blocking_wgetch(edit)) {
case 'O':
- switch (kbinput = wgetch(edit)) {
+ switch (kbinput = blocking_wgetch(edit)) {
case 'F':
x = xend;
break;
}
break;
case '[':
- switch (kbinput = wgetch(edit)) {
+ switch (kbinput = blocking_wgetch(edit)) {
case 'A':
#ifndef NANO_SMALL
goto do_upkey;
int get_page_start(int column)
{
assert(COLS > 9);
- return column < COLS - 1 ? 0 : column - 7 - (column - 8) % (COLS - 9);
+ return column < COLS - 1 ? 0 : column - 7 - (column - 7) % (COLS - 8);
}
/* Resets current_y, based on the position of current, and puts the
wrefresh(bottomwin);
do {
- int kbinput = wgetch(edit);
+ int kbinput = blocking_wgetch(edit);
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
MEVENT mevent;
#endif
break;
#endif
case 27:
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
switch(kbinput) {
case '[':
- kbinput = wgetch(edit);
+ kbinput = blocking_wgetch(edit);
switch(kbinput) {
case '5': /* Alt-[-5 = Page Up */
- wgetch(edit);
+ blocking_wgetch(edit);
goto do_pageupkey;
case 'V': /* Alt-[-V = Page Up in Hurd Console */
case 'I': /* Alt-[-I = Page Up - FreeBSD Console */
goto do_pageupkey;
case '6': /* Alt-[-6 = Page Down */
- wgetch(edit);
+ blocking_wgetch(edit);
goto do_pagedownkey;
case 'U': /* Alt-[-U = Page Down in Hurd Console */
case 'G': /* Alt-[-G = Page Down - FreeBSD Console */
no_more = 1;
continue;
}
- } while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY &&
+ } while ((kbinput = blocking_wgetch(edit)) != NANO_EXIT_KEY &&
kbinput != NANO_EXIT_FKEY);
currshortcut = oldshortcut;