Skip to content

Commit

Permalink
Insure that virtual terminal is always initialized with maximum size …
Browse files Browse the repository at this point in the history
…(MAXROW X MAXCOL) while current maximum size is inherited from actual terminal.
  • Loading branch information
rfivet committed May 29, 2017
1 parent 5d46ffc commit 35f2184
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
12 changes: 6 additions & 6 deletions display.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,21 @@ 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;
vp->v_rbcolor = 0;
#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
Expand All @@ -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]);
Expand Down
25 changes: 10 additions & 15 deletions tcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 35f2184

Please sign in to comment.