opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

0004-Don-t-wrap-when-adding-past-last-line-in-non-scrolli.patch (3542B)


      1 From de7a1acf3168a35c19a569cc7f6f572c39e96c82 Mon Sep 17 00:00:00 2001
      2 From: Michael Forney <mforney@mforney.org>
      3 Date: Thu, 3 Jun 2021 00:32:57 -0700
      4 Subject: [PATCH] Don't wrap when adding past last line in non-scrolling window
      5 
      6 X/Open curses says
      7 
      8 > If scrolling is disabled, any characters that would extend beyond
      9 > the last column of the last line are truncated.
     10 
     11 However, currently libcurses wraps the cursor back to the beginning
     12 of the last line.
     13 
     14 To fix this, when we try to add a character that would go past the
     15 end of the last line, leave the cursor where it is. If the character
     16 goes exactly to the end of the last line, add the character but set
     17 the cursor to the last column (to match ncurses behavior).
     18 
     19 [0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/intov.html#tag_001_004_002_002
     20 ---
     21  lib/libcurses/addbytes.c | 20 +++++++++++---------
     22  1 file changed, 11 insertions(+), 9 deletions(-)
     23 
     24 diff --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c
     25 index 9fd917ca..e52dc310 100644
     26 --- a/lib/libcurses/addbytes.c
     27 +++ b/lib/libcurses/addbytes.c
     28 @@ -232,8 +232,6 @@ _cursesi_addbyte(WINDOW *win, __LINE **lp, int *y, int *x, int c,
     29  #endif
     30  
     31  	if (char_interp && ((*lp)->flags & __ISPASTEOL)) {
     32 -		*x = 0;
     33 -		(*lp)->flags &= ~__ISPASTEOL;
     34  		if (*y == win->scr_b) {
     35  #ifdef DEBUG
     36  			__CTRACE(__CTRACE_INPUT,
     37 @@ -246,6 +244,8 @@ _cursesi_addbyte(WINDOW *win, __LINE **lp, int *y, int *x, int c,
     38  		} else {
     39  			(*y)++;
     40  		}
     41 +		*x = 0;
     42 +		(*lp)->flags &= ~__ISPASTEOL;
     43  		*lp = win->alines[*y];
     44  		if (c == '\n')
     45  			return OK;
     46 @@ -341,8 +341,6 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
     47  			return OK;
     48  		case L'\n':
     49  			wclrtoeol(win);
     50 -			*x = 0;
     51 -			(*lnp)->flags &= ~__ISPASTEOL;
     52  			if (*y == win->scr_b) {
     53  				if (!(win->flags & __SCROLLOK))
     54  					return ERR;
     55 @@ -350,6 +348,8 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
     56  			} else {
     57  				(*y)++;
     58  			}
     59 +			*x = 0;
     60 +			(*lnp)->flags &= ~__ISPASTEOL;
     61  			return OK;
     62  		case L'\t':
     63  			cc.vals[0] = L' ';
     64 @@ -395,8 +395,6 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
     65  	}
     66  	/* check for new line first */
     67  	if (char_interp && ((*lnp)->flags & __ISPASTEOL)) {
     68 -		*x = 0;
     69 -		(*lnp)->flags &= ~__ISPASTEOL;
     70  		if (*y == win->scr_b) {
     71  			if (!(win->flags & __SCROLLOK))
     72  				return ERR;
     73 @@ -404,6 +402,8 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
     74  		} else {
     75  			(*y)++;
     76  		}
     77 +		*x = 0;
     78 +		(*lnp)->flags &= ~__ISPASTEOL;
     79  		(*lnp) = win->alines[*y];
     80  		lp = &win->alines[*y]->line[*x];
     81  	}
     82 @@ -459,7 +459,6 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
     83  		if (newx > *(*lnp)->lastchp)
     84  			*(*lnp)->lastchp = newx;
     85  		__touchline(win, *y, sx, (int) win->maxx - 1);
     86 -		sx = *x = 0;
     87  		if (*y == win->scr_b) {
     88  			if (!(win->flags & __SCROLLOK))
     89  				return ERR;
     90 @@ -467,6 +466,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
     91  		} else {
     92  			(*y)++;
     93  		}
     94 +		sx = *x = 0;
     95  		lp = &win->alines[*y]->line[0];
     96  		(*lnp) = win->alines[*y];
     97  	}
     98 @@ -547,14 +547,16 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
     99  		if (newx > *(*lnp)->lastchp)
    100  			*(*lnp)->lastchp = newx;
    101  		__touchline(win, *y, sx, (int) win->maxx - 1);
    102 -		*x = sx = 0;
    103  		if (*y == win->scr_b) {
    104 -			if (!(win->flags & __SCROLLOK))
    105 +			if (!(win->flags & __SCROLLOK)) {
    106 +				*x = win->maxx - 1;
    107  				return ERR;
    108 +			}
    109  			scroll(win);
    110  		} else {
    111  			(*y)++;
    112  		}
    113 +		*x = sx = 0;
    114  		lp = &win->alines[*y]->line[0];
    115  		(*lnp) = win->alines[*y];
    116  	} else {
    117 -- 
    118 2.31.1
    119