1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Cleanup virtual terminal allocation code.

This commit is contained in:
Renaud 2017-06-01 13:02:47 +08:00
parent 57363dcb19
commit b6c89d6eca
3 changed files with 21 additions and 23 deletions

View File

@ -39,7 +39,7 @@ struct video {
int v_rfcolor; /* requested forground color */ int v_rfcolor; /* requested forground color */
int v_rbcolor; /* requested background color */ int v_rbcolor; /* requested background color */
#endif #endif
unicode_t v_text[1]; /* Screen data. */ unicode_t v_text[] ; /* Screen data. */
}; };
#define VFCHG 0x0001 /* Changed flag */ #define VFCHG 0x0001 /* Changed flag */
@ -109,13 +109,13 @@ void vtinit(void)
TTopen(); /* open the screen */ TTopen(); /* open the screen */
TTkopen(); /* open the keyboard */ TTkopen(); /* open the keyboard */
TTrev(FALSE); TTrev(FALSE);
vscreen = xmalloc( MAXROW * sizeof( struct video *)) ; vscreen = xmalloc( term.t_maxrow * sizeof( struct video *)) ;
#if MEMMAP == 0 || SCROLLCODE #if MEMMAP == 0 || SCROLLCODE
pscreen = xmalloc( MAXROW * sizeof( struct video *)) ; pscreen = xmalloc( term.t_maxrow * sizeof( struct video *)) ;
#endif #endif
for( i = 0 ; i < MAXROW ; ++i) { for( i = 0 ; i < term.t_maxrow ; ++i) {
vp = xmalloc( sizeof( struct video) + MAXCOL * 4) ; vp = xmalloc( sizeof( struct video) + term.t_maxcol * sizeof( unicode_t)) ;
vp->v_flag = 0; vp->v_flag = 0;
#if COLOR #if COLOR
vp->v_rfcolor = 7; vp->v_rfcolor = 7;
@ -123,7 +123,7 @@ void vtinit(void)
#endif #endif
vscreen[i] = vp; vscreen[i] = vp;
#if MEMMAP == 0 || SCROLLCODE #if MEMMAP == 0 || SCROLLCODE
vp = xmalloc( sizeof( struct video) + MAXCOL * 4 ) ; vp = xmalloc( sizeof( struct video) + term.t_maxcol * sizeof( unicode_t)) ;
vp->v_flag = 0; vp->v_flag = 0;
pscreen[i] = vp; pscreen[i] = vp;
#endif #endif
@ -136,7 +136,7 @@ void vtinit(void)
void vtfree(void) void vtfree(void)
{ {
int i; int i;
for( i = 0 ; i < MAXROW; ++i ) { for( i = 0 ; i < term.t_maxrow; ++i ) {
free(vscreen[i]); free(vscreen[i]);
#if MEMMAP == 0 || SCROLLCODE #if MEMMAP == 0 || SCROLLCODE
free(pscreen[i]); free(pscreen[i]);
@ -1521,8 +1521,8 @@ void sizesignal(int signr)
getscreensize(&w, &h); getscreensize(&w, &h);
if( h > 0 && w > 0) { if( h > 0 && w > 0) {
term.t_mrow = h = h < MAXROW ? h : MAXROW ; term.t_mrow = h = h < term.t_maxrow ? h : term.t_maxrow ;
term.t_mcol = w = w < MAXCOL ? w : MAXCOL ; term.t_mcol = w = w < term.t_maxcol ? w : term.t_maxcol ;
if( h - 1 != term.t_nrow || w != term.t_ncol) if( h - 1 != term.t_nrow || w != term.t_ncol)
newscreensize( h, w) ; newscreensize( h, w) ;
} }

6
tcap.c
View File

@ -88,6 +88,8 @@ static char *CS, *DL, *AL, *SF, *SR;
#endif #endif
struct terminal term = { struct terminal term = {
210, /* actual 204 on 1920x1080 landscape terminal window */
500, /* actual 475 */
0, /* These four values are set dynamically at open time. */ 0, /* These four values are set dynamically at open time. */
0, 0,
0, 0,
@ -157,9 +159,9 @@ static void tcapopen(void)
exit( EXIT_FAILURE) ; exit( EXIT_FAILURE) ;
} }
term.t_mrow = int_row < MAXROW ? int_row : MAXROW ; term.t_mrow = int_row < term.t_maxrow ? int_row : term.t_maxrow ;
term.t_nrow = term.t_mrow - 1 ; term.t_nrow = term.t_mrow - 1 ;
term.t_mcol = int_col < MAXCOL ? int_col : MAXCOL ; term.t_mcol = int_col < term.t_maxcol ? int_col : term.t_maxcol ;
term.t_ncol = term.t_mcol ; term.t_ncol = term.t_mcol ;
p = tcapbuf; p = tcapbuf;

View File

@ -7,12 +7,6 @@
#include "utf8.h" #include "utf8.h"
/* Actual 471x175 on a 1920x1080 screen in landscape,
if smaller font or portrait orientation limit to 500x200 */
#define MAXCOL 500
#define MAXROW 200
/* /*
* The editor communicates with the display using a high level interface. A * The editor communicates with the display using a high level interface. A
* "TERM" structure holds useful variables, and indirect pointers to routines * "TERM" structure holds useful variables, and indirect pointers to routines
@ -23,10 +17,12 @@
* one terminal type. * one terminal type.
*/ */
struct terminal { struct terminal {
short t_mrow; /* max number of rows allowable */ const short t_maxrow ; /* max number of rows allowable */
short t_nrow; /* current number of rows used */ const short t_maxcol ; /* max number of columns allowable */
short t_mcol; /* max Number of columns. */ short t_mrow ; /* max number of rows displayable */
short t_ncol; /* current Number of columns. */ short t_nrow ; /* current number of rows displayed */
short t_mcol ; /* max number of rows displayable */
short t_ncol ; /* current number of columns displayed */
short t_margin; /* min margin for extended lines */ short t_margin; /* min margin for extended lines */
short t_scrsiz; /* size of scroll region " */ short t_scrsiz; /* size of scroll region " */
int t_pause; /* # times thru update to pause */ int t_pause; /* # times thru update to pause */