Insure that virtual terminal is always initialized with maximum size (MAXROW X MAXCOL) while current maximum size is inherited from actual terminal.

This commit is contained in:
Renaud 2017-05-29 16:27:46 +08:00
parent 5d46ffc3dc
commit 35f2184253
2 changed files with 16 additions and 21 deletions

View File

@ -109,13 +109,13 @@ void vtinit(void)
TTopen(); /* open the screen */
TTkopen(); /* open the keyboard */
TTrev(FALSE);
vscreen = xmalloc(term.t_mrow * sizeof(struct video *));
vscreen = xmalloc( MAXROW * sizeof( struct video *)) ;
#if MEMMAP == 0 || SCROLLCODE
pscreen = xmalloc(term.t_mrow * sizeof(struct video *));
pscreen = xmalloc( MAXROW * sizeof( struct video *)) ;
#endif
for (i = 0; i < term.t_mrow; ++i) {
vp = xmalloc(sizeof(struct video) + term.t_mcol*4);
for( i = 0 ; i < MAXROW ; ++i) {
vp = xmalloc( sizeof( struct video) + MAXCOL * 4) ;
vp->v_flag = 0;
#if COLOR
vp->v_rfcolor = 7;
@ -123,7 +123,7 @@ void vtinit(void)
#endif
vscreen[i] = vp;
#if MEMMAP == 0 || SCROLLCODE
vp = xmalloc(sizeof(struct video) + term.t_mcol*4);
vp = xmalloc( sizeof( struct video) + MAXCOL * 4 ) ;
vp->v_flag = 0;
pscreen[i] = vp;
#endif
@ -136,7 +136,7 @@ void vtinit(void)
void vtfree(void)
{
int i;
for (i = 0; i < term.t_mrow; ++i) {
for( i = 0 ; i < MAXROW; ++i ) {
free(vscreen[i]);
#if MEMMAP == 0 || SCROLLCODE
free(pscreen[i]);

25
tcap.c
View File

@ -144,30 +144,25 @@ static void tcapopen(void)
}
/* Get screen size from system, or else from termcap. */
getscreensize(&int_col, &int_row);
term.t_nrow = int_row - 1;
term.t_ncol = int_col;
if ((term.t_nrow <= 0)
&& (term.t_nrow = (short) tgetnum("li") - 1) == -1) {
getscreensize( &int_col, &int_row) ;
if( (int_row <= 0)
&& ((int_row = tgetnum("li")) == -1)) {
fputs( "termcap entry incomplete (lines)\n", stderr) ;
exit( EXIT_FAILURE) ;
}
if ((term.t_ncol <= 0)
&& (term.t_ncol = (short) tgetnum("co")) == -1) {
if( (int_col <= 0)
&& ((int_col = tgetnum("co")) == -1)) {
fputs( "Termcap entry incomplete (columns)\n", stderr) ;
exit( EXIT_FAILURE) ;
}
#ifdef SIGWINCH
/* At initialization we use maximum size even if current OS window is smaller */
term.t_mrow = MAXROW ;
term.t_mcol = MAXCOL ;
if( term.t_nrow >= term.t_mrow)
term.t_nrow = term.t_mrow - 1 ;
if( term.t_ncol > term.t_mcol)
term.t_ncol = term.t_mcol ;
term.t_mrow = int_row < MAXROW ? int_row : MAXROW ;
term.t_nrow = term.t_mrow - 1 ;
term.t_mcol = int_col < MAXCOL ? int_col : MAXCOL ;
term.t_ncol = term.t_mcol ;
#else
term.t_mrow = term.t_nrow > MAXROW ? MAXROW : term.t_nrow;
term.t_mcol = term.t_ncol > MAXCOL ? MAXCOL : term.t_ncol;