From 0cb17997864c62102a66f7e110b45badae554e2d Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 30 Aug 2021 12:30:29 +0800 Subject: [PATCH] Revise refresh of extended lines. --- display.c | 43 ++++++++++++++++--------------------------- names.c | 2 +- window.c | 32 +++++++++++++++----------------- window.h | 2 +- 4 files changed, 33 insertions(+), 46 deletions(-) diff --git a/display.c b/display.c index cb57a91..419ae98 100644 --- a/display.c +++ b/display.c @@ -63,7 +63,6 @@ static int curcol ; /* Cursor column */ static int vtrow = 0 ; /* Row location of SW cursor */ static int vtcol = 0 ; /* Column location of SW cursor */ static int lbound = 0 ; /* leftmost column of current line being displayed */ -static int taboff = 0 ; /* tab offset for display */ int mpresf = FALSE ; /* TRUE if message in last line */ int scrollcount = 1 ; /* number of lines to scroll */ @@ -218,7 +217,7 @@ static void vtputuc( unicode_t c) { if( c == '\t') { sane_vtputc( viewtab ? 0xBB : ' ') ; /* 0xBB: 'ยป' */ - while( ((vtcol + taboff) % tabwidth) != 0) + while( ((vtcol + lbound) % tabwidth) != 0) sane_vtputc( ' ') ; } else if( c < 0x20 || c == 0x7F) { sane_vtputc( '^') ; @@ -460,6 +459,8 @@ static void show_line( line_p lp) { i += utf8_to_unicode( lp->l_text, i, len, &c) ; vtputuc( c) ; } + + vteeol() ; } @@ -469,9 +470,10 @@ static void show_line( line_p lp) { * window_p wp; window to update current line in */ static void updone( window_p wp) { + line_p lp ; + /* search down the line we want */ int sline = wp->w_toprow ; /* physical screen line to update */ - line_p lp ; for( lp = wp->w_linep ; lp != wp->w_dotp ; lp = lforw( lp)) ++sline ; @@ -484,7 +486,6 @@ static void updone( window_p wp) { vscreen[ sline]->v_rfcolor = wp->w_fcolor ; vscreen[ sline]->v_rbcolor = wp->w_bcolor ; #endif - vteeol() ; } @@ -506,14 +507,14 @@ static void updall( window_p wp) { /* if we are not at the end */ show_line( lp) ; lp = lforw( lp) ; - } + } else + vteeol() ; /* on to the next one */ #if COLOR vscreen[ sline]->v_rfcolor = wp->w_fcolor ; vscreen[ sline]->v_rbcolor = wp->w_bcolor ; #endif - vteeol() ; ++sline ; } } @@ -524,13 +525,12 @@ static void updall( window_p wp) { This is the only update for simple moves. */ static void updpos( void) { + line_p lp ; + /* find the current row */ - line_p lp = curwp->w_linep ; currow = curwp->w_toprow ; - while( lp != curwp->w_dotp) { + for( lp = curwp->w_linep ; lp != curwp->w_dotp ; lp = lforw( lp)) ++currow ; - lp = lforw( lp) ; - } /* find the current column */ curcol = 0 ; @@ -571,7 +571,6 @@ static void upddex( void) { || (curcol < term.t_ncol - 1)) { vtmove( i, 0) ; show_line( lp) ; - vteeol() ; /* this line no longer is extended */ vscreen[ i]->v_flag &= ~VFEXT ; @@ -798,30 +797,20 @@ static int endofline( unicode_t *s, int n) { /* updext: - * update the extended line which the cursor is currently - * on at a column greater than the terminal width. The line - * will be scrolled right or left to let the user see where - * the cursor is + update the extended line which the cursor is currently on at a column + greater than the terminal width. The line will be scrolled right or + left to let the user see where the cursor is. */ static void updext( void) { - int rcursor ; /* real cursor location */ - line_p lp ; /* pointer to current line */ - /* calculate what column the real cursor will end up in */ - rcursor = ((curcol - term.t_ncol) % term.t_scrsiz) + term.t_margin ; - taboff = lbound = curcol - rcursor + 1 ; + lbound = curcol - ((curcol - term.t_ncol) % term.t_scrsiz + term.t_margin) ; /* scan through the line outputing characters to the virtual screen */ /* once we reach the left edge */ vtmove( currow, -lbound) ; /* start scanning offscreen */ - lp = curwp->w_dotp ; /* line to output */ - show_line( lp) ; + show_line( curwp->w_dotp) ; - /* truncate the virtual line, restore tab offset */ - vteeol() ; - taboff = 0 ; - - /* and put a '$' in column 1 */ + /* put a '$' in column 1 */ vscreen[ currow]->v_text[ 0] = '$' ; } diff --git a/names.c b/names.c index 6e4979c..132c98d 100644 --- a/names.c +++ b/names.c @@ -51,7 +51,7 @@ const name_bind names[] = { {"!case-word-upper", upperword, META | 'U'} , {" change-file-name", filename, CTLX | 'N'} , {" change-screen-size", newsize, META | CTL_ | 'D'} , /* M^S */ - {" change-screen-width", newwidth, META | CTL_ | 'T'} , + {" change-screen-width", (fnp_t) newwidth, META | CTL_ | 'T'} , {" clear-and-redraw", (fnp_t) redraw, CTL_ | 'L'} , {" clear-message-line", (fnp_t) clrmes, 0} , {" copy-region", copyregion, META | 'W'} , diff --git a/window.c b/window.c index d51bc0b..70173dc 100644 --- a/window.c +++ b/window.c @@ -652,31 +652,29 @@ BINDABLE( newsize) { * int f; default flag * int n; numeric argument */ -BINDABLE( newwidth) { - window_p wp; - +BBINDABLE( newwidth) { /* if the command defaults, assume the largest */ - if (f == FALSE) - n = term.t_mcol; + if( f == FALSE) + n = term.t_mcol ; /* make sure it's in range */ - if (n < 10 || n > term.t_mcol) + if( n < 10 || n > term.t_mcol) return mloutfail( "%%Screen width out of range") ; /* otherwise, just re-width it (no big deal) */ - term.t_ncol = n; - term.t_margin = n / 10; - term.t_scrsiz = n - (term.t_margin * 2); + term.t_ncol = n ; + term.t_margin = n / 10 ; + if( term.t_margin < 3) /* t_margin -1 enough for $ + prev before current */ + term.t_margin = 3 ; - /* florce all windows to redraw */ - wp = wheadp; - while (wp) { - wp->w_flag |= WFHARD | WFMOVE | WFMODE; - wp = wp->w_wndp; - } - sgarbf = TRUE; + term.t_scrsiz = n - (term.t_margin * 2) ; - return TRUE; + /* force all windows to redraw */ + for( window_p wp = wheadp ; wp; wp = wp->w_wndp) + wp->w_flag |= WFHARD | WFMOVE | WFMODE ; + + sgarbf = TRUE ; + return TRUE ; } int getwpos(void) diff --git a/window.h b/window.h index a139562..ec684f4 100644 --- a/window.h +++ b/window.h @@ -56,7 +56,7 @@ extern window_p wheadp ; /* Head of list of windows */ BINDABLE( mvdnwind) ; BINDABLE( mvupwind) ; BINDABLE( newsize) ; - BINDABLE( newwidth) ; +BBINDABLE( newwidth) ; BINDABLE( nextwind) ; BINDABLE( onlywind) ; BINDABLE( prevwind) ;