options: add -b, --breaklonglines, the counterpart of --nowrap

master
Benno Schulenberg 2019-01-25 14:40:30 +01:00
parent 7811f3fc5a
commit cd9328fbf5
2 changed files with 20 additions and 13 deletions

View File

@ -843,6 +843,9 @@ void usage(void)
#ifndef NANO_TINY #ifndef NANO_TINY
print_opt("-Z", "--zap", N_("Let Bsp and Del erase a marked region")); print_opt("-Z", "--zap", N_("Let Bsp and Del erase a marked region"));
print_opt("-a", "--atblanks", N_("When soft-wrapping, do it at whitespace")); print_opt("-a", "--atblanks", N_("When soft-wrapping, do it at whitespace"));
#endif
#ifdef ENABLE_WRAPPING
print_opt("-b", "--breaklonglines", N_("Automatically hard-wrap overlong lines"));
#endif #endif
print_opt("-c", "--constantshow", N_("Constantly show cursor position")); print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete", print_opt("-d", "--rebinddelete",
@ -883,7 +886,7 @@ void usage(void)
#endif #endif
print_opt("-v", "--view", N_("View mode (read-only)")); print_opt("-v", "--view", N_("View mode (read-only)"));
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
print_opt("-w", "--nowrap", N_("Don't hard-wrap long lines")); print_opt("-w", "--nowrap", N_("Don't hard-wrap long lines [default]"));
#endif #endif
print_opt("-x", "--nohelp", N_("Don't show the two help lines")); print_opt("-x", "--nohelp", N_("Don't show the two help lines"));
#ifndef NANO_TINY #ifndef NANO_TINY
@ -1943,10 +1946,6 @@ int main(int argc, char **argv)
bool fill_used = FALSE; bool fill_used = FALSE;
/* Was the fill option used on the command line? */ /* Was the fill option used on the command line? */
#endif #endif
#ifdef ENABLE_WRAPPING
bool forced_wrapping = FALSE;
/* Should long lines be automatically hard wrapped? */
#endif
#ifdef ENABLE_JUSTIFY #ifdef ENABLE_JUSTIFY
int quoterc; int quoterc;
/* Whether the quoting regex was compiled successfully. */ /* Whether the quoting regex was compiled successfully. */
@ -1974,6 +1973,9 @@ int main(int argc, char **argv)
{"version", 0, NULL, 'V'}, {"version", 0, NULL, 'V'},
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
{"syntax", 1, NULL, 'Y'}, {"syntax", 1, NULL, 'Y'},
#endif
#ifdef ENABLE_WRAPPING
{"breaklonglines", 0, NULL, 'b'},
#endif #endif
{"constantshow", 0, NULL, 'c'}, {"constantshow", 0, NULL, 'c'},
{"rebinddelete", 0, NULL, 'd'}, {"rebinddelete", 0, NULL, 'd'},
@ -2082,7 +2084,7 @@ int main(int argc, char **argv)
while ((optchr = while ((optchr =
getopt_long(argc, argv, getopt_long(argc, argv,
"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:Zacdghiklmno:pr:s:tuvwxyz$", "ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:Zabcdghiklmno:pr:s:tuvwxyz$",
long_options, NULL)) != -1) { long_options, NULL)) != -1) {
switch (optchr) { switch (optchr) {
#ifndef NANO_TINY #ifndef NANO_TINY
@ -2194,6 +2196,11 @@ int main(int argc, char **argv)
case 'a': case 'a':
SET(AT_BLANKS); SET(AT_BLANKS);
break; break;
#endif
#ifdef ENABLE_WRAPPING
case 'b':
SET(BREAK_LONG_LINES);
break;
#endif #endif
case 'c': case 'c':
SET(CONSTANT_SHOW); SET(CONSTANT_SHOW);
@ -2247,7 +2254,7 @@ int main(int argc, char **argv)
fill_used = TRUE; fill_used = TRUE;
#endif #endif
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
forced_wrapping = TRUE; SET(BREAK_LONG_LINES);
#endif #endif
break; break;
#endif #endif
@ -2269,10 +2276,7 @@ int main(int argc, char **argv)
break; break;
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
case 'w': case 'w':
SET(NO_WRAP); UNSET(BREAK_LONG_LINES);
/* If both --fill and --nowrap are given on the
* command line, the last given option wins. */
forced_wrapping = FALSE;
break; break;
#endif #endif
case 'x': case 'x':
@ -2392,8 +2396,10 @@ int main(int argc, char **argv)
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
/* A --fill on the command line overrides a "set nowrap" in an rcfile. */ /* A --fill on the command line overrides a "set nowrap" in an rcfile. */
if (forced_wrapping) if (ISSET(BREAK_LONG_LINES))
UNSET(NO_WRAP); UNSET(NO_WRAP);
else
SET(NO_WRAP);
#endif #endif
/* If the user wants bold instead of reverse video for hilited text... */ /* If the user wants bold instead of reverse video for hilited text... */

View File

@ -540,7 +540,8 @@ enum
NO_PAUSES, NO_PAUSES,
AT_BLANKS, AT_BLANKS,
AFTER_ENDS, AFTER_ENDS,
LET_THEM_ZAP LET_THEM_ZAP,
BREAK_LONG_LINES
}; };
/* Flags for the menus in which a given function should be present. */ /* Flags for the menus in which a given function should be present. */