[PATCH] Added 'fullscrolling' option.
xylia allegretta <[email protected]> Sat, 3 Jan 2026 13:26:08 +0000
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <CAE7GgQ-wsJvr4kNh6F_kLB+wSSNdbCDppF2szhWOOADrR5Jcnw@mail.gmail.com> |
This option makes the entire screen scroll horizontally instead of only the current line. The main reason for doing this is that it can be somewhat frustrating to look at very wide tables with the way that horizontal scrolling works normally. You either have to only look at the current part of one line at a time, or you have to enable wrapping and have the table messily split in half. By giving the option to scroll the entire screen, the table can be viewed much more easily. Signed-off-by: Xylia Allegretta <[email protected]>
0001-Added-fullscrolling-option.patch
(text/x-patch, 10.8 KB)
From a5e00d3be7ac4a5ceb8d68424c2ba2aa809e9fb2 Mon Sep 17 00:00:00 2001 From: Xylia Allegretta <[email protected]> Date: Sat, 3 Jan 2026 08:10:18 -0500 Subject: [PATCH] Added 'fullscrolling' option. This option makes the entire screen scroll horizontally instead of only the current line. The main reason for doing this is that it can be somewhat frustrating to look at very wide tables with the way that horizontal scrolling works normally. You either have to only look at the current part of one line at a time, or you have to enable wrapping and have the table messily split in half. By giving the option to scroll the entire screen, the table can be viewed much more easily. Signed-off-by: Xylia Allegretta <[email protected]> --- doc/sample.nanorc.in | 3 ++ src/definitions.h | 3 +- src/global.c | 3 ++ src/nano.c | 10 ++++++- src/rcfile.c | 1 + src/winio.c | 66 ++++++++++++++++++++++++++++++++++++++++---- syntax/nanorc.nanorc | 2 +- 7 files changed, 80 insertions(+), 8 deletions(-) diff --git a/doc/sample.nanorc.in b/doc/sample.nanorc.in index 4b81f360..b02b373c 100644 --- a/doc/sample.nanorc.in +++ b/doc/sample.nanorc.in @@ -171,6 +171,9 @@ ## Spread overlong lines over multiple screen lines. # set softwrap +## Horizontal scrolling moves entire screen. +# set fullscrolling + ## Use this spelling checker instead of the internal one. This option ## does not have a default value. # set speller "aspell -x -c" diff --git a/src/definitions.h b/src/definitions.h index dfe2106f..d8ce3518 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -376,7 +376,8 @@ enum { USE_MAGIC, MINIBAR, ZERO, - MODERN_BINDINGS + MODERN_BINDINGS, + FULLSCROLL }; /* Structure types. */ diff --git a/src/global.c b/src/global.c index 84912f17..e6645e6e 100644 --- a/src/global.c +++ b/src/global.c @@ -1457,6 +1457,7 @@ void shortcut_init(void) #ifndef NANO_TINY /* Group of "Appearance" toggles. */ + add_to_sclist(MMAIN, "M-|", 0, do_toggle, FULLSCROLL); add_to_sclist(MMAIN, "M-Z", 0, do_toggle, ZERO); add_to_sclist((MMOST|MBROWSER|MYESNO) & ~MFINDINHELP, "M-X", 0, do_toggle, NO_HELP); add_to_sclist(MMAIN, "M-C", 0, do_toggle, CONSTANT_SHOW); @@ -1611,6 +1612,8 @@ const char *epithet_of_flag(int flag) return N_("Help mode"); case CONSTANT_SHOW: return N_("Constant cursor position display"); + case FULLSCROLL: + return N_("Horizontal scrolling of entire screen"); case SOFTWRAP: return N_("Soft wrapping of overlong lines"); case LINE_NUMBERS: diff --git a/src/nano.c b/src/nano.c index 2b45ca76..5a1272cc 100644 --- a/src/nano.c +++ b/src/nano.c @@ -654,6 +654,7 @@ void usage(void) print_opt("-0", "--zero", N_("Hide all bars, use whole terminal")); #endif print_opt("-/", "--modernbindings", N_("Use better-known key bindings")); + print_opt("-=", "--fullscrolling", N_("Scroll entire screen horizontally")); } /* Display the version number of this nano, a copyright notice, some contact @@ -1116,6 +1117,9 @@ void toggle_this(int flag) openfile->firstcolumn = 0; refresh_needed = TRUE; break; + case FULLSCROLL: + refresh_needed = TRUE; + break; case WHITESPACE_DISPLAY: titlebar(NULL); refresh_needed = TRUE; @@ -1805,6 +1809,7 @@ int main(int argc, char **argv) {"listsyntaxes", 0, NULL, 'z'}, #endif {"modernbindings", 0, NULL, '/'}, + {"fullscrolling", 0, NULL, '='}, #ifndef NANO_TINY {"smarthome", 0, NULL, 'A'}, {"backup", 0, NULL, 'B'}, @@ -1882,7 +1887,7 @@ int main(int argc, char **argv) SET(RESTRICTED); while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z" - "abcdef:ghijklmno:pqr:s:tuvwxyz!@%_0/", long_options, NULL)) > 0) { + "abcdef:ghijklmno:pqr:s:tuvwxyz!@%_0/=", long_options, NULL)) > 0) { switch (optchr) { #ifndef NANO_TINY case 'A': @@ -2147,6 +2152,9 @@ int main(int argc, char **argv) case '/': SET(MODERN_BINDINGS); break; + case '=': + SET(FULLSCROLL); + break; default: printf(_("Type '%s -h' for a list of available options.\n"), argv[0]); exit(1); diff --git a/src/rcfile.c b/src/rcfile.c index 8d5eddb2..c14a65e4 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -87,6 +87,7 @@ static const rcoption rcopts[] = { {"rebinddelete", REBIND_DELETE}, {"regexp", USE_REGEXP}, {"saveonexit", SAVE_ON_EXIT}, + {"fullscrolling", FULLSCROLL}, #ifdef ENABLE_SPELLER {"speller", 0}, #endif diff --git a/src/winio.c b/src/winio.c index 277851d9..88ebf43d 100644 --- a/src/winio.c +++ b/src/winio.c @@ -81,6 +81,8 @@ static size_t macro_length = 0; /* The current length of the macro. */ static size_t milestone = 0; /* Where the last burst of recorded keystrokes started. */ +static bool fullsc_culled = FALSE; + /* If a line has been culled due to being offscreen. */ /* Add the given code to the macro buffer. */ void add_to_macrobuffer(int code) @@ -1787,6 +1789,25 @@ char *display_string(const char *text, size_t column, size_t span, size_t beyond = column + span; /* The column number just beyond the last shown character. */ + if(isdata && ISSET(FULLSCROLL)) + { + size_t cur_page = get_page_start(xplustabs()); + /* Is text offscreen? */ + if(cur_page > get_page_start(breadth(text))) + { + /* Create blank string. */ + size_t i; + for(i=0; i<allocsize-1; i++) + converted[i]=' '; + converted[i]='\0'; + has_more = FALSE; + fullsc_culled = TRUE; + return converted; + } + else + fullsc_culled = FALSE; + } + text += start_x; #ifndef NANO_TINY @@ -2838,14 +2859,17 @@ int update_line(linestruct *line, size_t index) #endif row = line->lineno - openfile->edittop->lineno; - from_col = get_page_start(wideness(line->data, index)); + if(ISSET(FULLSCROLL)) + from_col = get_page_start(xplustabs()); + else + from_col = get_page_start(wideness(line->data, index)); /* Expand the piece to be drawn to its representable form, and draw it. */ converted = display_string(line->data, from_col, editwincols, TRUE, FALSE); draw_row(row, converted, line, from_col); free(converted); - if (from_col > 0) { + if (from_col > 0 || (ISSET(FULLSCROLL) && fullsc_culled)) { wattron(midwin, hilite_attribute); mvwaddch(midwin, row, margin, '<'); wattroff(midwin, hilite_attribute); @@ -3067,6 +3091,23 @@ void draw_scrollbar(void) } #endif +/* If fullscrolling is on and the "page" has changed, refresh the screen. */ +bool fullsc_update() +{ + static size_t oldxplustabs = 0; + if (ISSET(FULLSCROLL)) + { + if(get_page_start(oldxplustabs) != get_page_start(xplustabs())) + { + oldxplustabs = xplustabs(); + return 1; + } + } + oldxplustabs = xplustabs(); + + return 0; +} + /* Scroll the edit window one row in the given direction, and * draw the relevant content on the resultant blank row. */ void edit_scroll(bool direction) @@ -3086,6 +3127,13 @@ void edit_scroll(bool direction) wscrl(midwin, (direction == BACKWARD) ? -1 : 1); scrollok(midwin, FALSE); + /* If fullscrolling, and the page changed, refresh. */ + if(fullsc_update()) + { + refresh_needed = 1; + return; + } + /* If we're not on the first "page" (when not softwrapping), or the mark * is on, the row next to the scrolled region needs to be redrawn too. */ if (line_needs_update(openfile->placewewant, 0) && nrows < editwinrows) @@ -3329,6 +3377,7 @@ bool current_is_offscreen(void) return (current_is_above_screen() || current_is_below_screen()); } + /* Update any lines between old_current and current that need to be * updated. Use this if we've moved without changing any text. */ void edit_redraw(linestruct *old_current, update_type manner) @@ -3344,6 +3393,12 @@ void edit_redraw(linestruct *old_current, update_type manner) return; } + if(fullsc_update()) + { + refresh_needed = TRUE; + return; + } + #ifndef NANO_TINY /* If the mark is on, update all lines between old_current and current. */ if (openfile->mark) { @@ -3351,15 +3406,16 @@ void edit_redraw(linestruct *old_current, update_type manner) while (line != openfile->current) { update_line(line, 0); - line = (line->lineno > openfile->current->lineno) ? line->prev : line->next; } } else #endif /* Otherwise, update old_current only if it differs from current - * and was horizontally scrolled. */ - if (old_current != openfile->current && get_page_start(was_pww) > 0) + * and was horizontally scrolled. When fullscrolled, there's no + * reason to do this. */ + if (old_current != openfile->current && (get_page_start(was_pww) > 0 + && !ISSET(FULLSCROLL))) update_line(old_current, 0); /* Update current if the mark is on or it has changed "page", or if it diff --git a/syntax/nanorc.nanorc b/syntax/nanorc.nanorc index 0c16a6be..269b605d 100644 --- a/syntax/nanorc.nanorc +++ b/syntax/nanorc.nanorc @@ -14,7 +14,7 @@ color bold,purple "^[[:blank:]]*include[[:blank:]]+[^[:blank:]"]+" color lime "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:blank:]]+.*" # The arguments of commands -color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|colonparsing|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|tabstospaces|trimblanks|unix|whitespacedisplay|wordbounds|zap|zero)\>" +color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|colonparsing|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|fullscrolling|tabstospaces|trimblanks|unix|whitespacedisplay|wordbounds|zap|zero)\>" color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|minicolor|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+" color brightgreen "^[[:blank:]]*set[[:blank:]]+(fill[[:blank:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:blank:]]+[1-9][0-9]*)\>" color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([[:alpha:]]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[[:alpha:]]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([[:lower:]]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|execute|browser|whereisfile|gotodir|spell|linter|all)\>" -- 2.51.2