nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 16a3dc90c7f3a9d09b24725cef0346abcfa02c31
parent 769a0e661f2f9f438396e68c6fd8ce19cc51edb1
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Wed, 17 Oct 2018 18:01:01 -0500

wrapping: make relative fill values work again also for screen resizes

The 'wrap_at' variable, removed in commit e90b7cf4, is actually needed
to store the original value of the --fill option when it is negative.
Otherwise, changing the screen width will not update the wrapping point
properly.

This fixes https://savannah.gnu.org/bugs/?54861.
Reported-by: Brand Huntsman <alpha@qzx.com>

Diffstat:
Msrc/global.c | 6++++--
Msrc/nano.c | 3++-
Msrc/proto.h | 2+-
Msrc/rcfile.c | 4++--
4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -80,8 +80,10 @@ int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown; #endif #ifdef ENABLED_WRAPORJUSTIFY -ssize_t fill = -COLUMNS_FROM_EOL; - /* The column where we will wrap lines. */ +ssize_t wrap_at = -COLUMNS_FROM_EOL; + /* The relative column where we will wrap lines. */ +ssize_t fill = 0; + /* The actual column where we will wrap lines, based on wrap_at. */ #endif char *last_search = NULL; diff --git a/src/nano.c b/src/nano.c @@ -721,6 +721,7 @@ void window_init(void) #ifdef ENABLED_WRAPORJUSTIFY /* Set up the wrapping point, accounting for screen width when negative. */ + fill = wrap_at; if (fill <= 0) fill += COLS; if (fill < 0) @@ -2242,7 +2243,7 @@ int main(int argc, char **argv) #endif #ifdef ENABLED_WRAPORJUSTIFY case 'r': - if (!parse_num(optarg, &fill)) { + if (!parse_num(optarg, &wrap_at)) { fprintf(stderr, _("Requested fill size \"%s\" is invalid"), optarg); fprintf(stderr, "\n"); exit(1); diff --git a/src/proto.h b/src/proto.h @@ -72,7 +72,7 @@ extern int shiftaltup, shiftaltdown; #endif #ifdef ENABLED_WRAPORJUSTIFY -extern ssize_t fill; +extern ssize_t wrap_at, fill; #endif extern char *last_search; diff --git a/src/rcfile.c b/src/rcfile.c @@ -1104,10 +1104,10 @@ void parse_rcfile(FILE *rcstream, bool syntax_only) #endif #ifdef ENABLED_WRAPORJUSTIFY if (strcasecmp(rcopts[i].name, "fill") == 0) { - if (!parse_num(option, &fill)) { + if (!parse_num(option, &wrap_at)) { rcfile_error(N_("Requested fill size \"%s\" is invalid"), option); - fill = -COLUMNS_FROM_EOL; + wrap_at = -COLUMNS_FROM_EOL; } else UNSET(NO_WRAP); free(option);