1
1

new feature: option --guidestripe that shows a vertical guiding bar

Option -J (--guidestripe) takes a column number as argument and then
shows a vertical, colored bar over the entire height of the buffer,
to aid the user in regulating the width of the text when the terminal
is wider than this desired width.

This fulfills https://bugs.debian.org/916392.
Requested-by: Arturo Borrero González <arturo@debian.org>
And fulfills https://savannah.gnu.org/bugs/?55315.
Requested-by: Bryan Christ <bryan.christ@gmail.com>
Этот коммит содержится в:
Benno Schulenberg 2018-12-17 19:57:30 +01:00
родитель 43b42246d3
Коммит 66c6eb5166
5 изменённых файлов: 36 добавлений и 1 удалений

Просмотреть файл

@ -111,6 +111,8 @@ int editwincols = -1;
/* The number of usable columns in the edit window: COLS - margin. */ /* The number of usable columns in the edit window: COLS - margin. */
int margin = 0; int margin = 0;
/* The amount of space reserved at the left for line numbers. */ /* The amount of space reserved at the left for line numbers. */
ssize_t stripe_column = 0;
/* The column at which a vertical bar will be drawn. */
filestruct *cutbuffer = NULL; filestruct *cutbuffer = NULL;
/* The buffer where we store cut text. */ /* The buffer where we store cut text. */

Просмотреть файл

@ -797,6 +797,10 @@ void usage(void)
#endif #endif
#ifdef ENABLE_NANORC #ifdef ENABLE_NANORC
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files")); print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
#endif
#ifndef NANO_TINY
print_opt("-J <number>", "--guidestripe=<number>",
N_("Show a guiding bar at this column"));
#endif #endif
print_opt("-K", "--rawsequences", print_opt("-K", "--rawsequences",
N_("Fix numeric keypad key confusion problem")); N_("Fix numeric keypad key confusion problem"));
@ -2022,6 +2026,7 @@ int main(int argc, char **argv)
{"tabstospaces", 0, NULL, 'E'}, {"tabstospaces", 0, NULL, 'E'},
{"locking", 0, NULL, 'G'}, {"locking", 0, NULL, 'G'},
{"historylog", 0, NULL, 'H'}, {"historylog", 0, NULL, 'H'},
{"guidestripe", 1, NULL, 'J'},
{"noconvert", 0, NULL, 'N'}, {"noconvert", 0, NULL, 'N'},
{"positionlog", 0, NULL, 'P'}, {"positionlog", 0, NULL, 'P'},
{"smooth", 0, NULL, 'S'}, {"smooth", 0, NULL, 'S'},
@ -2092,7 +2097,7 @@ int main(int argc, char **argv)
while ((optchr = while ((optchr =
getopt_long(argc, argv, getopt_long(argc, argv,
"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:Zabcdefghijklmno:pr:s:tuvwxyz$", "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Zabcdefghijklmno:pr:s:tuvwxyz$",
long_options, NULL)) != -1) { long_options, NULL)) != -1) {
switch (optchr) { switch (optchr) {
#ifndef NANO_TINY #ifndef NANO_TINY
@ -2134,6 +2139,13 @@ int main(int argc, char **argv)
ignore_rcfiles = TRUE; ignore_rcfiles = TRUE;
break; break;
#endif #endif
case 'J':
if (!parse_num(optarg, &stripe_column) || stripe_column <= 0) {
fprintf(stderr, _("Stripe column \"%s\" is invalid"), optarg);
fprintf(stderr, "\n");
exit(1);
}
break;
case 'K': case 'K':
SET(RAW_SEQUENCES); SET(RAW_SEQUENCES);
break; break;
@ -2330,6 +2342,7 @@ int main(int argc, char **argv)
ssize_t fill_cmdline = fill; ssize_t fill_cmdline = fill;
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
size_t stripeclm_cmdline = stripe_column;
char *backup_dir_cmdline = backup_dir; char *backup_dir_cmdline = backup_dir;
char *word_chars_cmdline = word_chars; char *word_chars_cmdline = word_chars;
#endif #endif
@ -2376,6 +2389,8 @@ int main(int argc, char **argv)
fill = fill_cmdline; fill = fill_cmdline;
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
if (stripeclm_cmdline > 0)
stripe_column = stripeclm_cmdline;
if (backup_dir_cmdline != NULL) { if (backup_dir_cmdline != NULL) {
free(backup_dir); free(backup_dir);
backup_dir = backup_dir_cmdline; backup_dir = backup_dir_cmdline;

Просмотреть файл

@ -88,6 +88,7 @@ extern WINDOW *bottomwin;
extern int editwinrows; extern int editwinrows;
extern int editwincols; extern int editwincols;
extern int margin; extern int margin;
extern ssize_t stripe_column;
extern filestruct *cutbuffer; extern filestruct *cutbuffer;
extern filestruct *cutbottom; extern filestruct *cutbottom;

Просмотреть файл

@ -102,6 +102,7 @@ static const rcoption rcopts[] = {
{"backupdir", 0}, {"backupdir", 0},
{"casesensitive", CASE_SENSITIVE}, {"casesensitive", CASE_SENSITIVE},
{"cutfromcursor", CUT_FROM_CURSOR}, {"cutfromcursor", CUT_FROM_CURSOR},
{"guidestripe", 0},
{"locking", LOCKING}, {"locking", LOCKING},
{"matchbrackets", 0}, {"matchbrackets", 0},
{"noconvert", NO_CONVERT}, {"noconvert", NO_CONVERT},
@ -1116,6 +1117,13 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
} else } else
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
if (strcasecmp(rcopts[i].name, "guidestripe") == 0) {
if (!parse_num(option, &stripe_column) || stripe_column <= 0) {
rcfile_error(N_("Edge column \"%s\" is invalid"), option);
stripe_column = 0;
}
free(option);
}
if (strcasecmp(rcopts[i].name, "matchbrackets") == 0) { if (strcasecmp(rcopts[i].name, "matchbrackets") == 0) {
matchbrackets = option; matchbrackets = option;
if (has_blank_mbchars(matchbrackets)) { if (has_blank_mbchars(matchbrackets)) {

Просмотреть файл

@ -2685,6 +2685,15 @@ void edit_draw(filestruct *fileptr, const char *converted,
} }
#endif /* ENABLE_COLOR */ #endif /* ENABLE_COLOR */
if (stripe_column > 0 && !inhelp) {
const char *text = converted + actual_x(converted, stripe_column - 1);
const char *striped_char = (*text == '\0') ? " " : text;
wattron(edit, interface_color_pair[ERROR_MESSAGE]);
mvwaddnstr(edit, row, margin + stripe_column - 1, striped_char, 1);
wattroff(edit, interface_color_pair[ERROR_MESSAGE]);
}
#ifndef NANO_TINY #ifndef NANO_TINY
/* If the mark is on, and fileptr is at least partially selected, we /* If the mark is on, and fileptr is at least partially selected, we
* need to paint it. */ * need to paint it. */