Implemented suspend code to work with Meta-Z

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@201 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2000-09-04 03:20:38 +00:00
parent f8163dc2e7
commit 18f8be0058
3 changed files with 111 additions and 75 deletions

View File

@ -5,7 +5,8 @@ CVS Code
toggles in nano.h, toggle_init(), toggle_init_one() in global.c toggles in nano.h, toggle_init(), toggle_init_one() in global.c
called from shortcut_init(), and do_toggle in nano.c. Also called from shortcut_init(), and do_toggle in nano.c. Also
moved the signal code into a separate function in nano.c called moved the signal code into a separate function in nano.c called
signal_init(). signal_init(). Moved "struct sigaction act"into a static in
nano.c.
- Changed from Alt-key symbol (@) which is completely nonstandard - Changed from Alt-key symbol (@) which is completely nonstandard
to the *nix "Meta" symbol (M-). Changed help_init to show to the *nix "Meta" symbol (M-). Changed help_init to show
the M-key usage and the help text to explain keys whcih generate the M-key usage and the help text to explain keys whcih generate
@ -26,6 +27,9 @@ CVS Code
do_toggle() do_toggle()
- Added checks for no help and no wrap mode, and print opposite - Added checks for no help and no wrap mode, and print opposite
enable/disable message. enable/disable message.
do_suspend(), do_cont():
- New functions, handle suspend signal in a Pico-like manner and
work with Meta-Z.
- winio.c: - winio.c:
total_refresh() total_refresh()
- Added edit_refresh() call to actually update the screen if messy. - Added edit_refresh() call to actually update the screen if messy.

38
nano.c
View File

@ -64,6 +64,7 @@ static char *alt_speller; /* Alternative spell command */
struct termios oldterm; /* The user's original term settings */ struct termios oldterm; /* The user's original term settings */
static char *help_text_init = ""; static char *help_text_init = "";
/* Initial message, not including shortcuts */ /* Initial message, not including shortcuts */
static struct sigaction act; /* For all out fun signal handlers */
/* What we do when we're all set to exit */ /* What we do when we're all set to exit */
RETSIGTYPE finish(int sigage) RETSIGTYPE finish(int sigage)
@ -1216,6 +1217,29 @@ RETSIGTYPE handle_hup(int signal)
finish(1); finish(1);
} }
/* What do we do when we catch the suspend signal */
RETSIGTYPE do_suspend(int signal)
{
act.sa_handler = SIG_DFL;
sigemptyset(&act.sa_mask);
sigaction(SIGTSTP, &act, NULL);
endwin();
fprintf(stderr,"\n\n\n\nUse \"fg\" to return to nano\n");
raise(SIGTSTP);
}
/* Restore the suspend handler when we come back into the prog */
RETSIGTYPE do_cont(int signal)
{
act.sa_handler = do_suspend;
sigemptyset(&act.sa_mask);
sigaction(SIGTSTP, &act, NULL);
initscr();
total_refresh();
}
void handle_sigwinch(int s) void handle_sigwinch(int s)
{ {
@ -1288,16 +1312,24 @@ void handle_sigwinch(int s)
void signal_init(void) void signal_init(void)
{ {
struct sigaction act; /* For our lovely signals */
/* Trap SIGINT and SIGQUIT cuz we want them to do useful things. */ /* Trap SIGINT and SIGQUIT cuz we want them to do useful things. */
memset(&act, 0, sizeof(struct sigaction)); memset(&act, 0, sizeof(struct sigaction));
act.sa_handler = SIG_IGN; act.sa_handler = SIG_IGN;
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
sigaction(SIGQUIT, &act, NULL);
if (!ISSET(SUSPEND)) if (!ISSET(SUSPEND)) {
sigaction(SIGTSTP, &act, NULL); sigaction(SIGTSTP, &act, NULL);
}
else
{
act.sa_handler = do_suspend;
sigaction(SIGTSTP, &act, NULL);
act.sa_handler = do_cont;
sigaction (SIGCONT, &act, NULL);
}
/* Trap SIGHUP cuz we want to write the file out. */ /* Trap SIGHUP cuz we want to write the file out. */
act.sa_handler = handle_hup; act.sa_handler = handle_hup;

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-09-02 21:13-0400\n" "POT-Creation-Date: 2000-09-03 23:17-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -55,7 +55,7 @@ msgstr ""
msgid "File to insert [from ./] " msgid "File to insert [from ./] "
msgstr "" msgstr ""
#: files.c:273 files.c:297 files.c:487 nano.c:1131 #: files.c:273 files.c:297 files.c:487 nano.c:1132
msgid "Cancelled" msgid "Cancelled"
msgstr "" msgstr ""
@ -388,17 +388,17 @@ msgstr ""
msgid "No Replace" msgid "No Replace"
msgstr "" msgstr ""
#: nano.c:114 #: nano.c:115
msgid "" msgid ""
"\n" "\n"
"Buffer written to 'nano.save'\n" "Buffer written to 'nano.save'\n"
msgstr "" msgstr ""
#: nano.c:121 #: nano.c:122
msgid "Key illegal in VIEW mode" msgid "Key illegal in VIEW mode"
msgstr "" msgstr ""
#: nano.c:157 #: nano.c:158
msgid "" msgid ""
" nano help text\n" " nano help text\n"
"\n" "\n"
@ -419,280 +419,280 @@ msgid ""
"\n" "\n"
msgstr "" msgstr ""
#: nano.c:260 #: nano.c:261
msgid "free_node(): free'd a node, YAY!\n" msgid "free_node(): free'd a node, YAY!\n"
msgstr "" msgstr ""
#: nano.c:265 #: nano.c:266
msgid "free_node(): free'd last node.\n" msgid "free_node(): free'd last node.\n"
msgstr "" msgstr ""
#: nano.c:317 #: nano.c:318
msgid "" msgid ""
"Usage: nano [GNU long option] [option] +LINE <file>\n" "Usage: nano [GNU long option] [option] +LINE <file>\n"
"\n" "\n"
msgstr "" msgstr ""
#: nano.c:318 #: nano.c:319
msgid "Option\t\tLong option\t\tMeaning\n" msgid "Option\t\tLong option\t\tMeaning\n"
msgstr "" msgstr ""
#: nano.c:320 #: nano.c:321
msgid " -T \t\t--tabsize=[num]\t\tSet width of a tab to num\n" msgid " -T \t\t--tabsize=[num]\t\tSet width of a tab to num\n"
msgstr "" msgstr ""
#: nano.c:323 #: nano.c:324
msgid " -R\t\t--regexp\t\tUse regular expressions for search\n" msgid " -R\t\t--regexp\t\tUse regular expressions for search\n"
msgstr "" msgstr ""
#: nano.c:327 #: nano.c:328
msgid " -V \t\t--version\t\tPrint version information and exit\n" msgid " -V \t\t--version\t\tPrint version information and exit\n"
msgstr "" msgstr ""
#: nano.c:329 #: nano.c:330
msgid " -c \t\t--const\t\t\tConstantly show cursor position\n" msgid " -c \t\t--const\t\t\tConstantly show cursor position\n"
msgstr "" msgstr ""
#: nano.c:331 #: nano.c:332
msgid " -h \t\t--help\t\t\tShow this message\n" msgid " -h \t\t--help\t\t\tShow this message\n"
msgstr "" msgstr ""
#: nano.c:334 #: nano.c:335
msgid " -k \t\t--cut\t\t\tLet ^K cut from cursor to end of line\n" msgid " -k \t\t--cut\t\t\tLet ^K cut from cursor to end of line\n"
msgstr "" msgstr ""
#: nano.c:337 #: nano.c:338
msgid " -i \t\t--autoindent\t\tAutomatically indent new lines\n" msgid " -i \t\t--autoindent\t\tAutomatically indent new lines\n"
msgstr "" msgstr ""
#: nano.c:339 #: nano.c:340
msgid " -l \t\t--nofollow\t\tDon't follow symbolic links, overwrite.\n" msgid " -l \t\t--nofollow\t\tDon't follow symbolic links, overwrite.\n"
msgstr "" msgstr ""
#: nano.c:342 #: nano.c:343
msgid " -m \t\t--mouse\t\t\tEnable mouse\n" msgid " -m \t\t--mouse\t\t\tEnable mouse\n"
msgstr "" msgstr ""
#: nano.c:347 #: nano.c:348
msgid "" msgid ""
" -r [#cols] \t--fill=[#cols]\t\tSet fill cols to (wrap lines at) #cols\n" " -r [#cols] \t--fill=[#cols]\t\tSet fill cols to (wrap lines at) #cols\n"
msgstr "" msgstr ""
#: nano.c:349 #: nano.c:350
msgid " -p\t \t--pico\t\t\tMake bottom 2 lines more Pico-like\n" msgid " -p\t \t--pico\t\t\tMake bottom 2 lines more Pico-like\n"
msgstr "" msgstr ""
#: nano.c:351 #: nano.c:352
msgid " -s [prog] \t--speller=[prog]\tEnable alternate speller\n" msgid " -s [prog] \t--speller=[prog]\tEnable alternate speller\n"
msgstr "" msgstr ""
#: nano.c:353 #: nano.c:354
msgid " -t \t\t--tempfile\t\tAuto save on exit, don't prompt\n" msgid " -t \t\t--tempfile\t\tAuto save on exit, don't prompt\n"
msgstr "" msgstr ""
#: nano.c:355 #: nano.c:356
msgid " -v \t\t--view\t\t\tView (read only) mode\n" msgid " -v \t\t--view\t\t\tView (read only) mode\n"
msgstr "" msgstr ""
#: nano.c:357 #: nano.c:358
msgid " -w \t\t--nowrap\t\tDon't wrap long lines\n" msgid " -w \t\t--nowrap\t\tDon't wrap long lines\n"
msgstr "" msgstr ""
#: nano.c:359 #: nano.c:360
msgid " -x \t\t--nohelp\t\tDon't show help window\n" msgid " -x \t\t--nohelp\t\tDon't show help window\n"
msgstr "" msgstr ""
#: nano.c:361 #: nano.c:362
msgid " -z \t\t--suspend\t\tEnable suspend\n" msgid " -z \t\t--suspend\t\tEnable suspend\n"
msgstr "" msgstr ""
#: nano.c:363 #: nano.c:364
msgid " +LINE\t\t\t\t\tStart at line number LINE\n" msgid " +LINE\t\t\t\t\tStart at line number LINE\n"
msgstr "" msgstr ""
#: nano.c:365 #: nano.c:366
msgid "" msgid ""
"Usage: nano [option] +LINE <file>\n" "Usage: nano [option] +LINE <file>\n"
"\n" "\n"
msgstr "" msgstr ""
#: nano.c:366 #: nano.c:367
msgid "Option\t\tMeaning\n" msgid "Option\t\tMeaning\n"
msgstr "" msgstr ""
#: nano.c:367 #: nano.c:368
msgid " -T [num]\tSet width of a tab to num\n" msgid " -T [num]\tSet width of a tab to num\n"
msgstr "" msgstr ""
#: nano.c:368 #: nano.c:369
msgid " -R\t\tUse regular expressions for search\n" msgid " -R\t\tUse regular expressions for search\n"
msgstr "" msgstr ""
#: nano.c:369 #: nano.c:370
msgid " -V \t\tPrint version information and exit\n" msgid " -V \t\tPrint version information and exit\n"
msgstr "" msgstr ""
#: nano.c:370 #: nano.c:371
msgid " -c \t\tConstantly show cursor position\n" msgid " -c \t\tConstantly show cursor position\n"
msgstr "" msgstr ""
#: nano.c:371 #: nano.c:372
msgid " -h \t\tShow this message\n" msgid " -h \t\tShow this message\n"
msgstr "" msgstr ""
#: nano.c:373 #: nano.c:374
msgid " -k \t\tLet ^K cut from cursor to end of line\n" msgid " -k \t\tLet ^K cut from cursor to end of line\n"
msgstr "" msgstr ""
#: nano.c:375 #: nano.c:376
msgid " -i \t\tAutomatically indent new lines\n" msgid " -i \t\tAutomatically indent new lines\n"
msgstr "" msgstr ""
#: nano.c:377 #: nano.c:378
msgid " -l \t\tDon't follow symbolic links, overwrite.\n" msgid " -l \t\tDon't follow symbolic links, overwrite.\n"
msgstr "" msgstr ""
#: nano.c:380 #: nano.c:381
msgid " -m \t\tEnable mouse\n" msgid " -m \t\tEnable mouse\n"
msgstr "" msgstr ""
#: nano.c:384 #: nano.c:385
msgid " -r [#cols] \tSet fill cols to (wrap lines at) #cols\n" msgid " -r [#cols] \tSet fill cols to (wrap lines at) #cols\n"
msgstr "" msgstr ""
#: nano.c:385 #: nano.c:386
msgid " -s [prog] \tEnable alternate speller\n" msgid " -s [prog] \tEnable alternate speller\n"
msgstr "" msgstr ""
#: nano.c:386 #: nano.c:387
msgid " -p \t\tMake bottom 2 lines more Pico-like\n" msgid " -p \t\tMake bottom 2 lines more Pico-like\n"
msgstr "" msgstr ""
#: nano.c:387 #: nano.c:388
msgid " -t \t\tAuto save on exit, don't prompt\n" msgid " -t \t\tAuto save on exit, don't prompt\n"
msgstr "" msgstr ""
#: nano.c:388 #: nano.c:389
msgid " -v \t\tView (read only) mode\n" msgid " -v \t\tView (read only) mode\n"
msgstr "" msgstr ""
#: nano.c:389 #: nano.c:390
msgid " -w \t\tDon't wrap long lines\n" msgid " -w \t\tDon't wrap long lines\n"
msgstr "" msgstr ""
#: nano.c:390 #: nano.c:391
msgid " -x \t\tDon't show help window\n" msgid " -x \t\tDon't show help window\n"
msgstr "" msgstr ""
#: nano.c:391 #: nano.c:392
msgid " -z \t\tEnable suspend\n" msgid " -z \t\tEnable suspend\n"
msgstr "" msgstr ""
#: nano.c:392 #: nano.c:393
msgid " +LINE\t\tStart at line number LINE\n" msgid " +LINE\t\tStart at line number LINE\n"
msgstr "" msgstr ""
#: nano.c:399 #: nano.c:400
#, c-format #, c-format
msgid " nano version %s by Chris Allegretta (compiled %s, %s)\n" msgid " nano version %s by Chris Allegretta (compiled %s, %s)\n"
msgstr "" msgstr ""
#: nano.c:401 #: nano.c:402
msgid " Email: nano@asty.org\tWeb: http://www.asty.org/nano\n" msgid " Email: nano@asty.org\tWeb: http://www.asty.org/nano\n"
msgstr "" msgstr ""
#: nano.c:436 #: nano.c:437
msgid "Mark Set" msgid "Mark Set"
msgstr "" msgstr ""
#: nano.c:441 #: nano.c:442
msgid "Mark UNset" msgid "Mark UNset"
msgstr "" msgstr ""
#: nano.c:866 #: nano.c:867
#, c-format #, c-format
msgid "check_wrap called with inptr->data=\"%s\"\n" msgid "check_wrap called with inptr->data=\"%s\"\n"
msgstr "" msgstr ""
#: nano.c:917 #: nano.c:918
#, c-format #, c-format
msgid "current->data now = \"%s\"\n" msgid "current->data now = \"%s\"\n"
msgstr "" msgstr ""
#: nano.c:970 #: nano.c:971
#, c-format #, c-format
msgid "After, data = \"%s\"\n" msgid "After, data = \"%s\"\n"
msgstr "" msgstr ""
#: nano.c:1040 #: nano.c:1041
msgid "Error deleting tempfile, ack!" msgid "Error deleting tempfile, ack!"
msgstr "" msgstr ""
#: nano.c:1058 #: nano.c:1059
#, c-format #, c-format
msgid "Could not create a temporary filename: %s" msgid "Could not create a temporary filename: %s"
msgstr "" msgstr ""
#: nano.c:1081 #: nano.c:1082
#, c-format #, c-format
msgid "Could not invoke spell program \"%s\"" msgid "Could not invoke spell program \"%s\""
msgstr "" msgstr ""
#. Why 32512? I dont know! #. Why 32512? I dont know!
#: nano.c:1087 #: nano.c:1088
msgid "Could not invoke \"ispell\"" msgid "Could not invoke \"ispell\""
msgstr "" msgstr ""
#: nano.c:1100 #: nano.c:1101
msgid "Finished checking spelling" msgid "Finished checking spelling"
msgstr "" msgstr ""
#: nano.c:1118 #: nano.c:1119
msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? " msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "
msgstr "" msgstr ""
#: nano.c:1259 #: nano.c:1283
msgid "Cannot resize top win" msgid "Cannot resize top win"
msgstr "" msgstr ""
#: nano.c:1261 #: nano.c:1285
msgid "Cannot move top win" msgid "Cannot move top win"
msgstr "" msgstr ""
#: nano.c:1263 #: nano.c:1287
msgid "Cannot resize edit win" msgid "Cannot resize edit win"
msgstr "" msgstr ""
#: nano.c:1265 #: nano.c:1289
msgid "Cannot move edit win" msgid "Cannot move edit win"
msgstr "" msgstr ""
#: nano.c:1267 #: nano.c:1291
msgid "Cannot resize bottom win" msgid "Cannot resize bottom win"
msgstr "" msgstr ""
#: nano.c:1269 #: nano.c:1293
msgid "Cannot move bottom win" msgid "Cannot move bottom win"
msgstr "" msgstr ""
#: nano.c:1818 #: nano.c:1850
msgid "Main: set up windows\n" msgid "Main: set up windows\n"
msgstr "" msgstr ""
#: nano.c:1833 #: nano.c:1865
msgid "Main: bottom win\n" msgid "Main: bottom win\n"
msgstr "" msgstr ""
#: nano.c:1839 #: nano.c:1871
msgid "Main: open file\n" msgid "Main: open file\n"
msgstr "" msgstr ""
#: nano.c:1907 #: nano.c:1939
#, c-format #, c-format
msgid "I got Alt-[-%c! (%d)\n" msgid "I got Alt-[-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:1933 #: nano.c:1965
#, c-format #, c-format
msgid "I got Alt-%c! (%d)\n" msgid "I got Alt-%c! (%d)\n"
msgstr "" msgstr ""