556
551
/* Unlink a node from the rest of the openfilestruct, and delete it. */
557
552
void unlink_opennode(openfilestruct *fileptr)
559
assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL && fileptr != fileptr->prev && fileptr != fileptr->next);
554
assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL &&
555
fileptr != fileptr->prev && fileptr != fileptr->next);
561
557
fileptr->prev->next = fileptr->next;
562
558
fileptr->next->prev = fileptr->prev;
851
845
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
852
846
N_("Directory for saving unique backup files"));
854
print_opt("-D", "--boldtext",
855
N_("Use bold instead of reverse video text"));
848
print_opt("-D", "--boldtext", N_("Use bold instead of reverse video text"));
856
849
#ifndef NANO_TINY
857
print_opt("-E", "--tabstospaces",
858
N_("Convert typed tabs to spaces"));
850
print_opt("-E", "--tabstospaces", N_("Convert typed tabs to spaces"));
860
852
#ifndef DISABLE_MULTIBUFFER
861
print_opt("-F", "--multibuffer", N_("Enable multiple file buffers"));
853
print_opt("-F", "--multibuffer",
854
N_("Read a file into a new buffer by default"));
863
856
#ifndef NANO_TINY
864
print_opt("-G", "--locking",
865
N_("Use (vim-style) lock files"));
857
print_opt("-G", "--locking", N_("Use (vim-style) lock files"));
867
859
#ifndef DISABLE_HISTORIES
868
860
print_opt("-H", "--historylog",
869
861
N_("Log & read search/replace string history"));
871
863
#ifndef DISABLE_NANORC
872
print_opt("-I", "--ignorercfiles",
873
N_("Don't look at nanorc files"));
864
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
875
866
print_opt("-K", "--rebindkeypad",
876
867
N_("Fix numeric keypad key confusion problem"));
883
874
print_opt("-O", "--morespace", N_("Use one more line for editing"));
884
875
#ifndef DISABLE_HISTORIES
885
print_opt("-P", "--poslog",
886
N_("Log & read location of cursor position"));
876
print_opt("-P", "--poslog", N_("Log & read location of cursor position"));
888
878
#ifndef DISABLE_JUSTIFY
889
print_opt(_("-Q <str>"), _("--quotestr=<str>"),
890
N_("Quoting string"));
879
print_opt(_("-Q <str>"), _("--quotestr=<str>"), N_("Quoting string"));
892
881
print_opt("-R", "--restricted", N_("Restricted mode"));
893
882
#ifndef NANO_TINY
894
print_opt("-S", "--smooth",
895
N_("Scroll by line instead of half-screen"));
883
print_opt("-S", "--smooth", N_("Scroll by line instead of half-screen"));
897
885
print_opt(_("-T <#cols>"), _("--tabsize=<#cols>"),
898
886
N_("Set width of a tab to #cols columns"));
899
887
#ifndef NANO_TINY
900
888
print_opt("-U", "--quickblank", N_("Do quick statusbar blanking"));
902
print_opt("-V", "--version",
903
N_("Print version information and exit"));
890
print_opt("-V", "--version", N_("Print version information and exit"));
904
891
#ifndef NANO_TINY
905
892
print_opt("-W", "--wordbounds",
906
893
N_("Detect word boundaries more accurately"));
914
901
N_("Fix Backspace/Delete confusion problem"));
915
902
print_opt("-h", "--help", N_("Show this help text"));
916
903
#ifndef NANO_TINY
917
print_opt("-i", "--autoindent",
918
N_("Automatically indent new lines"));
904
print_opt("-i", "--autoindent", N_("Automatically indent new lines"));
919
905
print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
921
print_opt("-l", "--nofollow",
922
N_("Don't follow symbolic links, overwrite"));
907
print_opt("-l", "--nofollow", N_("Don't follow symbolic links, overwrite"));
923
908
#ifndef DISABLE_MOUSE
924
909
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
928
913
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
929
914
N_("Set operating directory"));
931
print_opt("-p", "--preserve",
932
N_("Preserve XON (^Q) and XOFF (^S) keys"));
916
print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
933
917
#ifndef DISABLE_NANORC
934
918
print_opt("-q", "--quiet",
935
919
N_("Silently ignore startup issues like rc file errors"));
942
926
print_opt(_("-s <prog>"), _("--speller=<prog>"),
943
927
N_("Enable alternate speller"));
945
print_opt("-t", "--tempfile",
946
N_("Auto save on exit, don't prompt"));
929
print_opt("-t", "--tempfile", N_("Auto save on exit, don't prompt"));
947
930
print_opt("-v", "--view", N_("View mode (read-only)"));
948
931
#ifndef DISABLE_WRAPPING
949
932
print_opt("-w", "--nowrap", N_("Don't hard-wrap long lines"));
1170
static struct sigaction pager_oldaction, pager_newaction; /* Original and temporary handlers for SIGINT. */
1171
static bool pager_sig_failed = FALSE; /* Did sigaction() fail without changing the signal handlers? */
1172
static bool pager_input_aborted = FALSE; /* Did someone invoke the pager and abort it via ^C? */
1153
static struct sigaction pager_oldaction, pager_newaction;
1154
/* Original and temporary handlers for SIGINT. */
1155
static bool pager_sig_failed = FALSE;
1156
/* Did sigaction() fail without changing the signal handlers? */
1157
static bool pager_input_aborted = FALSE;
1158
/* Did someone invoke the pager and abort it via ^C? */
1174
1160
/* Things which need to be run regardless of whether
1175
1161
* we finished the stdin pipe correctly or not. */
1237
1223
/* Initialize the signal handlers. */
1238
1224
void signal_init(void)
1240
/* Trap SIGINT and SIGQUIT because we want them to do useful
1226
/* Trap SIGINT and SIGQUIT because we want them to do useful things. */
1242
1227
memset(&act, 0, sizeof(struct sigaction));
1243
1228
act.sa_handler = SIG_IGN;
1244
1229
sigaction(SIGINT, &act, NULL);
1253
1238
/* Trap SIGWINCH because we want to handle window resizes. */
1254
1239
act.sa_handler = handle_sigwinch;
1255
1240
sigaction(SIGWINCH, &act, NULL);
1256
allow_pending_sigwinch(FALSE);
1259
1243
/* Trap normal suspend (^Z) so we can handle it ourselves. */
1352
1336
/* Handler for SIGWINCH (window size change). */
1353
1337
RETSIGTYPE handle_sigwinch(int signal)
1339
/* Let the input routine know that a SIGWINCH has occurred. */
1343
/* Reinitialize and redraw the screen completely. */
1344
void regenerate_screen(void)
1355
1346
const char *tty = ttyname(0);
1356
1347
int fd, result = 0;
1357
1348
struct winsize win;
1375
1366
LINES = win.ws_row;
1378
/* If we've partitioned the filestruct, unpartition it now. */
1379
if (filepart != NULL)
1380
unpartition_filestruct(&filepart);
1382
1369
#ifdef USE_SLANG
1383
1370
/* Slang curses emulation brain damage, part 1: If we just do what
1384
1371
* curses does here, it'll only work properly if the resize made the
2119
2104
#ifdef HAVE_GETOPT_LONG
2120
2105
const struct option long_options[] = {
2121
{"help", 0, NULL, 'h'},
2122
2106
{"boldtext", 0, NULL, 'D'},
2123
2107
#ifndef DISABLE_MULTIBUFFER
2124
2108
{"multibuffer", 0, NULL, 'F'},
2141
2125
{"const", 0, NULL, 'c'},
2142
2126
{"rebinddelete", 0, NULL, 'd'},
2127
{"help", 0, NULL, 'h'},
2143
2128
{"nofollow", 0, NULL, 'l'},
2144
2129
#ifndef DISABLE_MOUSE
2145
2130
{"mouse", 0, NULL, 'm'},
2174
2159
{"poslog", 0, NULL, 'P'},
2175
2160
{"smooth", 0, NULL, 'S'},
2176
2161
{"quickblank", 0, NULL, 'U'},
2177
{"undo", 0, NULL, 'u'},
2178
2162
{"wordbounds", 0, NULL, 'W'},
2179
2163
{"autoindent", 0, NULL, 'i'},
2180
2164
{"cut", 0, NULL, 'k'},
2647
2631
#endif /* !DISABLE_NANORC */
2648
2632
#endif /* !NANO_TINY */
2634
/* Initialize the search and replace strings. */
2635
last_search = mallocstrcpy(NULL, "");
2636
last_replace = mallocstrcpy(NULL, "");
2650
2638
/* If tabsize wasn't specified, set its default value. */
2651
2639
if (tabsize == -1)
2652
2640
tabsize = WIDTH_OF_TAB;
2802
2790
reset_cursor();
2803
2791
wnoutrefresh(edit);
2806
if (!jump_buf_main) {
2807
/* If we haven't already, we're going to set jump_buf so
2808
* that we return here after a SIGWINCH. Indicate this. */
2809
jump_buf_main = TRUE;
2811
/* Return here after a SIGWINCH. */
2812
sigsetjmp(jump_buf, 1);
2816
2793
/* Just in case we were at the statusbar prompt, make sure the
2817
2794
* statusbar cursor position is reset. */
2818
2795
do_prompt_abort();