Revise refresh of extended lines.

This commit is contained in:
Renaud 2021-08-30 12:30:29 +08:00
parent 0a8c28bc07
commit 0cb1799786
4 changed files with 33 additions and 46 deletions

View File

@ -63,7 +63,6 @@ static int curcol ; /* Cursor column */
static int vtrow = 0 ; /* Row location of SW cursor */ static int vtrow = 0 ; /* Row location of SW cursor */
static int vtcol = 0 ; /* Column 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 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 mpresf = FALSE ; /* TRUE if message in last line */
int scrollcount = 1 ; /* number of lines to scroll */ int scrollcount = 1 ; /* number of lines to scroll */
@ -218,7 +217,7 @@ static void vtputuc( unicode_t c) {
if( c == '\t') { if( c == '\t') {
sane_vtputc( viewtab ? 0xBB : ' ') ; /* 0xBB: '»' */ sane_vtputc( viewtab ? 0xBB : ' ') ; /* 0xBB: '»' */
while( ((vtcol + taboff) % tabwidth) != 0) while( ((vtcol + lbound) % tabwidth) != 0)
sane_vtputc( ' ') ; sane_vtputc( ' ') ;
} else if( c < 0x20 || c == 0x7F) { } else if( c < 0x20 || c == 0x7F) {
sane_vtputc( '^') ; sane_vtputc( '^') ;
@ -460,6 +459,8 @@ static void show_line( line_p lp) {
i += utf8_to_unicode( lp->l_text, i, len, &c) ; i += utf8_to_unicode( lp->l_text, i, len, &c) ;
vtputuc( c) ; vtputuc( c) ;
} }
vteeol() ;
} }
@ -469,9 +470,10 @@ static void show_line( line_p lp) {
* window_p wp; window to update current line in * window_p wp; window to update current line in
*/ */
static void updone( window_p wp) { static void updone( window_p wp) {
line_p lp ;
/* search down the line we want */ /* search down the line we want */
int sline = wp->w_toprow ; /* physical screen line to update */ 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)) for( lp = wp->w_linep ; lp != wp->w_dotp ; lp = lforw( lp))
++sline ; ++sline ;
@ -484,7 +486,6 @@ static void updone( window_p wp) {
vscreen[ sline]->v_rfcolor = wp->w_fcolor ; vscreen[ sline]->v_rfcolor = wp->w_fcolor ;
vscreen[ sline]->v_rbcolor = wp->w_bcolor ; vscreen[ sline]->v_rbcolor = wp->w_bcolor ;
#endif #endif
vteeol() ;
} }
@ -506,14 +507,14 @@ static void updall( window_p wp) {
/* if we are not at the end */ /* if we are not at the end */
show_line( lp) ; show_line( lp) ;
lp = lforw( lp) ; lp = lforw( lp) ;
} } else
vteeol() ;
/* on to the next one */ /* on to the next one */
#if COLOR #if COLOR
vscreen[ sline]->v_rfcolor = wp->w_fcolor ; vscreen[ sline]->v_rfcolor = wp->w_fcolor ;
vscreen[ sline]->v_rbcolor = wp->w_bcolor ; vscreen[ sline]->v_rbcolor = wp->w_bcolor ;
#endif #endif
vteeol() ;
++sline ; ++sline ;
} }
} }
@ -524,13 +525,12 @@ static void updall( window_p wp) {
This is the only update for simple moves. This is the only update for simple moves.
*/ */
static void updpos( void) { static void updpos( void) {
line_p lp ;
/* find the current row */ /* find the current row */
line_p lp = curwp->w_linep ;
currow = curwp->w_toprow ; currow = curwp->w_toprow ;
while( lp != curwp->w_dotp) { for( lp = curwp->w_linep ; lp != curwp->w_dotp ; lp = lforw( lp))
++currow ; ++currow ;
lp = lforw( lp) ;
}
/* find the current column */ /* find the current column */
curcol = 0 ; curcol = 0 ;
@ -571,7 +571,6 @@ static void upddex( void) {
|| (curcol < term.t_ncol - 1)) { || (curcol < term.t_ncol - 1)) {
vtmove( i, 0) ; vtmove( i, 0) ;
show_line( lp) ; show_line( lp) ;
vteeol() ;
/* this line no longer is extended */ /* this line no longer is extended */
vscreen[ i]->v_flag &= ~VFEXT ; vscreen[ i]->v_flag &= ~VFEXT ;
@ -798,30 +797,20 @@ static int endofline( unicode_t *s, int n) {
/* updext: /* updext:
* update the extended line which the cursor is currently update the extended line which the cursor is currently on at a column
* on at a column greater than the terminal width. The line greater than the terminal width. The line will be scrolled right or
* will be scrolled right or left to let the user see where left to let the user see where the cursor is.
* the cursor is
*/ */
static void updext( void) { 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 */ /* calculate what column the real cursor will end up in */
rcursor = ((curcol - term.t_ncol) % term.t_scrsiz) + term.t_margin ; lbound = curcol - ((curcol - term.t_ncol) % term.t_scrsiz + term.t_margin) ;
taboff = lbound = curcol - rcursor + 1 ;
/* scan through the line outputing characters to the virtual screen */ /* scan through the line outputing characters to the virtual screen */
/* once we reach the left edge */ /* once we reach the left edge */
vtmove( currow, -lbound) ; /* start scanning offscreen */ vtmove( currow, -lbound) ; /* start scanning offscreen */
lp = curwp->w_dotp ; /* line to output */ show_line( curwp->w_dotp) ;
show_line( lp) ;
/* truncate the virtual line, restore tab offset */ /* put a '$' in column 1 */
vteeol() ;
taboff = 0 ;
/* and put a '$' in column 1 */
vscreen[ currow]->v_text[ 0] = '$' ; vscreen[ currow]->v_text[ 0] = '$' ;
} }

View File

@ -51,7 +51,7 @@ const name_bind names[] = {
{"!case-word-upper", upperword, META | 'U'} , {"!case-word-upper", upperword, META | 'U'} ,
{" change-file-name", filename, CTLX | 'N'} , {" change-file-name", filename, CTLX | 'N'} ,
{" change-screen-size", newsize, META | CTL_ | 'D'} , /* M^S */ {" 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-and-redraw", (fnp_t) redraw, CTL_ | 'L'} ,
{" clear-message-line", (fnp_t) clrmes, 0} , {" clear-message-line", (fnp_t) clrmes, 0} ,
{" copy-region", copyregion, META | 'W'} , {" copy-region", copyregion, META | 'W'} ,

View File

@ -652,31 +652,29 @@ BINDABLE( newsize) {
* int f; default flag * int f; default flag
* int n; numeric argument * int n; numeric argument
*/ */
BINDABLE( newwidth) { BBINDABLE( newwidth) {
window_p wp;
/* if the command defaults, assume the largest */ /* if the command defaults, assume the largest */
if (f == FALSE) if( f == FALSE)
n = term.t_mcol; n = term.t_mcol ;
/* make sure it's in range */ /* 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") ; return mloutfail( "%%Screen width out of range") ;
/* otherwise, just re-width it (no big deal) */ /* otherwise, just re-width it (no big deal) */
term.t_ncol = n; term.t_ncol = n ;
term.t_margin = n / 10; term.t_margin = n / 10 ;
term.t_scrsiz = n - (term.t_margin * 2); if( term.t_margin < 3) /* t_margin -1 enough for $ + prev before current */
term.t_margin = 3 ;
/* florce all windows to redraw */ term.t_scrsiz = n - (term.t_margin * 2) ;
wp = wheadp;
while (wp) {
wp->w_flag |= WFHARD | WFMOVE | WFMODE;
wp = wp->w_wndp;
}
sgarbf = TRUE;
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) int getwpos(void)

View File

@ -56,7 +56,7 @@ extern window_p wheadp ; /* Head of list of windows */
BINDABLE( mvdnwind) ; BINDABLE( mvdnwind) ;
BINDABLE( mvupwind) ; BINDABLE( mvupwind) ;
BINDABLE( newsize) ; BINDABLE( newsize) ;
BINDABLE( newwidth) ; BBINDABLE( newwidth) ;
BINDABLE( nextwind) ; BINDABLE( nextwind) ;
BINDABLE( onlywind) ; BINDABLE( onlywind) ;
BINDABLE( prevwind) ; BINDABLE( prevwind) ;