From f010d63a95b013300909f6c89876fc33d92a9b72 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 30 Aug 2021 13:16:46 +0800 Subject: [PATCH] Fix initialization of screen margin and scroll size. --- display.c | 9 +++++++++ display.h | 1 + window.c | 6 +----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/display.c b/display.c index 419ae98..70b8758 100644 --- a/display.c +++ b/display.c @@ -135,6 +135,14 @@ static void vtalloc( int maxrow, int maxcol) { } } +void updmargin( void) { + term.t_margin = term.t_ncol / 10 ; + if( term.t_margin < 3) /* t_margin - 1 enough for $ + prev before current */ + term.t_margin = 3 ; + + term.t_scrsiz = term.t_ncol - 2 * term.t_margin ; +} + void vtinit( void) { #ifdef SIGWINCH signal( SIGWINCH, sizesignal) ; @@ -142,6 +150,7 @@ void vtinit( void) { setlocale( LC_CTYPE, "") ; /* expects $LANG like en_GB.UTF-8 */ TTopen() ; /* open the screen */ + updmargin() ; TTkopen() ; /* open the keyboard */ TTrev( FALSE) ; vtalloc( term.t_mrow, term.t_mcol) ; diff --git a/display.h b/display.h index cc30ea6..a65fb9b 100644 --- a/display.h +++ b/display.h @@ -25,6 +25,7 @@ void vtinit( void) ; void vtfree( void) ; void vttidy( void) ; void update( boolean force_f) ; +void updmargin( void) ; void upmode( void) ; void movecursor( int row, int col) ; void mlerase( void) ; diff --git a/window.c b/window.c index 70173dc..8236ae7 100644 --- a/window.c +++ b/window.c @@ -663,11 +663,7 @@ BBINDABLE( newwidth) { /* otherwise, just re-width it (no big deal) */ 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 ; - - term.t_scrsiz = n - (term.t_margin * 2) ; + updmargin() ; /* force all windows to redraw */ for( window_p wp = wheadp ; wp; wp = wp->w_wndp)