diff --git a/ChangeLog b/ChangeLog index ed93a4dc..c28e2d55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,11 @@ Changes being incompatible with pico. Removed all code for different search/replace string editing and alternate shortcut list. I'm sure I won't even have to ask for feedback on this one :-) + - Add in Pico's -p flag, (-p, --preserve). To preserve the XON and XOFF + keys (^Q and ^S). Add warning if we invoke -p and add checks for + using --preserve (to skip warning) and --pico (to force showing it). + New flag PRESERVE, function do_preserve_msg(), changes to main(), + signal_init(). - Search history and replace history up/down cursor arrows, w/history tab completion, not available w/NANO_SMALL. Changes to statusq, others (Ken Tyler). Added shortcut to search/replace diff --git a/nano.c b/nano.c index 0b8a64e4..a12602da 100644 --- a/nano.c +++ b/nano.c @@ -657,6 +657,7 @@ void usage(void) #ifndef DISABLE_OPERATINGDIR print1opt(_("-o [dir]"), _("--operatingdir=[dir]"), _("Set operating directory")); #endif + print1opt(_("-p"), _("--preserve"), _("Preserve XON (^Q) and XOFF (^S) keys")); #ifndef DISABLE_WRAPJUSTIFY print1opt(_("-r [#cols]"), _("--fill=[#cols]"), _("Set fill cols to (wrap lines at) #cols")); #endif @@ -759,11 +760,20 @@ void nano_disabled_msg(void) } #endif +void do_preserve_msg(void) +{ + fprintf(stderr, _("\nThe -p flag now invokes the Pico \"preserve\" flag. The Pico compatibility\n")); + fprintf(stderr, _("flag been removed as nano is now fully Pico compatible. Please see the nano\n")); + fprintf(stderr, _("FAQ for more info on this change...\n\n")); + fprintf(stderr, _("Press return to continue\n")); + while (getchar() != '\n'); +} + + #ifndef NANO_SMALL static int pid; /* This is the PID of the newly forked process * below. It must be global since the signal * handler needs it. */ - RETSIGTYPE cancel_fork(int signal) { if (kill(pid, SIGKILL) == -1) @@ -2754,9 +2764,11 @@ void signal_init(void) #ifdef _POSIX_VDISABLE tcgetattr(0, &term); - /* Ignore ^S, much to Chris' chagrin */ - term.c_cc[VSTOP] = _POSIX_VDISABLE; - + if (!ISSET(PRESERVE)) { + /* Ignore ^S and ^Q, much to Chris' chagrin */ + term.c_cc[VSTOP] = _POSIX_VDISABLE; + term.c_cc[VSTART] = _POSIX_VDISABLE; + } #ifdef VDSUSP term.c_cc[VDSUSP] = _POSIX_VDISABLE; #endif /* VDSUSP */ @@ -2998,6 +3010,9 @@ int main(int argc, char *argv[]) int keyhandled; /* Have we handled the keystroke yet? */ int modify_control_seq; const shortcut *s; +#ifdef HAVE_GETOPT_LONG + int preserveopt = 0; /* Did the cmdline include --preserve? */ +#endif #ifndef NANO_SMALL const toggle *t; #endif @@ -3036,6 +3051,7 @@ int main(int argc, char *argv[]) #ifndef DISABLE_OPERATINGDIR {"operatingdir", 1, 0, 'o'}, #endif + {"preserve", 0, 0, 'p'}, #ifndef DISABLE_WRAPJUSTIFY {"fill", 1, 0, 'r'}, #endif @@ -3074,7 +3090,8 @@ int main(int argc, char *argv[]) first, so that it's handled before we call do_rcfile() and read the other options; don't use getopt()/getopt_long() here, because there's no way to reset it properly - afterward */ + afterward. Also check for the --preserve flag, and report + error if people are still using --pico. */ int i; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "--")) @@ -3084,6 +3101,10 @@ int main(int argc, char *argv[]) #ifdef HAVE_GETOPT_LONG else if (!strcmp(argv[i], "--ignorercfiles")) SET(NO_RCFILE); + else if (!strcmp(argv[i], "--preserve")) + preserveopt = 1; + else if (!strcmp(argv[i], "--pico")) + do_preserve_msg(); #endif } } @@ -3216,6 +3237,11 @@ int main(int argc, char *argv[]) break; #endif case 'p': + SET(PRESERVE); +#ifdef HAVE_GETOPT_LONG + if (!preserveopt) + do_preserve_msg(); +#endif break; #ifndef DISABLE_WRAPJUSTIFY case 'r': @@ -3608,6 +3634,8 @@ int main(int argc, char *argv[]) /* Don't even think about changing this string */ if (kbinput == 19) statusbar(_("XOFF ignored, mumble mumble.")); + if (kbinput == 17) + statusbar(_("XON ignored, mumble mumble.")); #endif /* If we're in raw mode or using Alt-Alt-x, we have to catch Control-S and Control-Q */ diff --git a/nano.h b/nano.h index cc15f134..caea215b 100644 --- a/nano.h +++ b/nano.h @@ -244,6 +244,7 @@ typedef struct historyheadtype { #define BACKUP_FILE (1<<25) #define NO_RCFILE (1<<26) #define COLOR_SYNTAX (1<<27) +#define PRESERVE (1<<28) /* Control key sequences, changing these would be very very bad */