From 913ede4e96dd20b85fadb35c9efbc780618d5171 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 16 Feb 2024 21:47:59 +1300 Subject: [PATCH] initial support for the alternate screen buffer Which works by adding an additional vscrn called VTERM_B which is semi-independent from VTERM (now called VTERM_A) - it has its own video buffer, but it shares its event queues with VTERM_A and any settings that are applied to VTERM_A also get applied to VTERM_B. I don't particularly like the scale of these changes but at this stage it seems like the simplest way to achieve this. Before merging its probably worthwhile exploring some other options just in case. There is also at least one outstanding bug related to the background colour not being applied properly to the main buffer when the window is resized on the alternate buffer. --- kermit/k95/ckcmai.c | 8 +- kermit/k95/ckctel.c | 13 ++- kermit/k95/ckoco2.c | 46 +++++--- kermit/k95/ckoco3.c | 279 ++++++++++++++++++++++++++++++-------------- kermit/k95/ckoco4.c | 8 +- kermit/k95/ckocon.c | 63 ++++++---- kermit/k95/ckocon.h | 17 ++- kermit/k95/ckokey.c | 51 +++++++- kermit/k95/ckosyn.c | 56 ++++++--- kermit/k95/ckotio.c | 5 +- kermit/k95/ckuus2.c | 5 + kermit/k95/ckuus3.c | 2 +- kermit/k95/ckuus5.c | 6 +- kermit/k95/ckuus7.c | 119 ++++++++++++++----- kermit/k95/ckuusr.c | 2 +- kermit/k95/ckuusr.h | 7 ++ 16 files changed, 491 insertions(+), 196 deletions(-) diff --git a/kermit/k95/ckcmai.c b/kermit/k95/ckcmai.c index ba484deb..e265a754 100644 --- a/kermit/k95/ckcmai.c +++ b/kermit/k95/ckcmai.c @@ -1226,12 +1226,12 @@ int os2pm = 0; /* OS/2 Presentation Manager flag */ #ifdef OS2 #include "ckocon.h" #ifdef KUI -int tt_rows[VNUM] = {24,24,25,1}; /* Rows (height) */ -int tt_cols[VNUM] = {80,80,80,80}; /* Columns (width) */ +int tt_rows[VNUM] = {24,24,24,25,1}; /* Rows (height) */ +int tt_cols[VNUM] = {80,80,80,80,80}; /* Columns (width) */ int cmd_rows = 24, cmd_cols = 80; /* Command/console screen dimensions */ #else /* KUI */ -int tt_rows[VNUM] = {-1,24,25,1}; /* Rows (height) */ -int tt_cols[VNUM] = {-1,80,80,80}; /* Columns (width) */ +int tt_rows[VNUM] = {-1,24,24,25,1}; /* Rows (height) */ +int tt_cols[VNUM] = {-1,80,80,80,80}; /* Columns (width) */ int cmd_rows = -1, cmd_cols = -1; /* Command/console screen dimensions */ #endif /* KUI */ int k95stdio = 0; /* Stdio threads */ diff --git a/kermit/k95/ckctel.c b/kermit/k95/ckctel.c index 8e354de4..543a7eb8 100644 --- a/kermit/k95/ckctel.c +++ b/kermit/k95/ckctel.c @@ -4808,10 +4808,15 @@ tn_xdoop(z, echo, fn) CHAR z; int echo; int (*fn)(); #ifndef NOLOCAL if (tcp_incoming) { #ifdef OS2 - tt_cols[VTERM] = w; - tt_rows[VTERM] = h; - VscrnSetWidth(VTERM, w); - VscrnSetHeight(VTERM, h+(tt_status[VTERM]?1:0)); + tt_cols[VTERM_A] = w; + tt_rows[VTERM_A] = h; + VscrnSetWidth(VTERM_A, w); + VscrnSetHeight(VTERM_A, h+(tt_status[VTERM_A]?1:0)); + + tt_cols[VTERM_B] = w; + tt_rows[VTERM_B] = h; + VscrnSetWidth(VTERM_B, w); + VscrnSetHeight(VTERM_B, h+(tt_status[VTERM_B]?1:0)); #else /* OS2 */ tt_cols = w; tt_rows = h; diff --git a/kermit/k95/ckoco2.c b/kermit/k95/ckoco2.c index 0e9510ea..5ecf9221 100644 --- a/kermit/k95/ckoco2.c +++ b/kermit/k95/ckoco2.c @@ -69,6 +69,7 @@ extern int OSVer; #include "ckokey.h" videobuffer vscrn[VNUM] = {{0,0,0,0,0,0,{0,0},0,-1,-1,-1,-1,{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0,0}, + {0,0,0,0,0,0,{0,0},0,-1,-1,-1,-1,{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0,0}, {0,0,0,0,0,0,{0,0},0,-1,-1,-1,-1,{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0,0}, {0,0,0,0,0,0,{0,0},0,-1,-1,-1,-1,{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0,0}, {0,0,0,0,0,0,{0,0},0,-1,-1,-1,-1,{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0,0}}; @@ -1482,8 +1483,11 @@ Set132Cols( int mode ) } - if (mode == VTERM) - VscrnSetWidth( VTERM, 132 ); + if (IS_VTERM(mode)) { + VscrnSetWidth(VTERM_A, 132); + VscrnSetWidth(VTERM_B, 132); + VscrnSetHeight( mode == VTERM_A ? VTERM_B : mode, mi.row ); + } else if ( tt_modechg == TVC_ENA ) VscrnSetWidth( mode, mi.col ); else if ( tt_modechg == TVC_W95 ) @@ -1556,9 +1560,11 @@ Set80Cols( int mode ) return 1; } - if ( mode == VTERM ) - VscrnSetWidth( VTERM, 80 ); - else if ( tt_modechg == TVC_ENA ) + if ( mode == VTERM_A || mode == VTERM_B ) { + VscrnSetWidth(VTERM_A, 80); + VscrnSetWidth(VTERM_B, 80); + VscrnSetHeight( mode == VTERM_A ? VTERM_B : mode, mi.row ) ; + } else if ( tt_modechg == TVC_ENA ) VscrnSetWidth( mode, mi.col ); else if ( tt_modechg == TVC_W95 ) VscrnSetWidth( mode, 80 ); @@ -1708,7 +1714,7 @@ SetCols( int mode ) } #ifdef OLDDIRTY -static int isdirty[VNUM] = {0,0,0,0} ; +static int isdirty[VNUM] = {0,0,0,0,0} ; #endif /*---------------------------------------------------------------------------*/ @@ -2834,9 +2840,9 @@ VscrnGetCurPos( BYTE vmode ) } -static viocell * cellmem[VNUM] = { NULL, NULL, NULL, NULL } ; -static unsigned short * attrmem[VNUM] = { NULL, NULL, NULL, NULL } ; -static unsigned short * hyperlinkmem[VNUM] = { NULL, NULL, NULL, NULL } ; +static viocell * cellmem[VNUM] = { NULL, NULL, NULL, NULL, NULL } ; +static unsigned short * attrmem[VNUM] = { NULL, NULL, NULL, NULL, NULL } ; +static unsigned short * hyperlinkmem[VNUM] = { NULL, NULL, NULL, NULL, NULL } ; /*---------------------------------------------------------------------------*/ /* VscrnSetBufferSize */ @@ -2844,7 +2850,7 @@ static unsigned short * hyperlinkmem[VNUM] = { NULL, NULL, NULL, NULL } ; ULONG VscrnSetBufferSize( BYTE vmode, ULONG newsize ) { - static ULONG oldsize[VNUM]={0,0,0,0} ; + static ULONG oldsize[VNUM]={0,0,0,0,0} ; int i ; videobuffer TmpScrn ; videoline * line ; @@ -3864,7 +3870,8 @@ TermScrnUpd( void * threadinfo) rc = CreateVscrnTimerSem( TRUE ); rc = CreateVscrnMuxWait(VCMD) ; - rc = CreateVscrnMuxWait(VTERM) ; + rc = CreateVscrnMuxWait(VTERM_A) ; + rc = CreateVscrnMuxWait(VTERM_B) ; rc = CreateVscrnMuxWait(VCS) ; rc = StartVscrnTimer( tt_update ); @@ -4524,7 +4531,8 @@ TermScrnUpd( void * threadinfo) #endif /* NT */ CloseVscrnMuxWait(VCMD) ; - CloseVscrnMuxWait(VTERM) ; + CloseVscrnMuxWait(VTERM_A) ; + CloseVscrnMuxWait(VTERM_B) ; CloseVscrnMuxWait(VCS) ; CloseVscrnTimerSem() ; free(thecells) ; @@ -4826,10 +4834,10 @@ VscrnInit( BYTE vmode ) #endif /* KUI */ } - if ( vmode == VTERM ) + if ( IS_VTERM(vmode) ) { - if (!scrninitialized[VTERM]) { - scrninitialized[VTERM] = 1; + if (!scrninitialized[vmode]) { + scrninitialized[vmode] = 1; attribute = defaultattribute = colornormal; underlineattribute = colorunderline ; reverseattribute = colorreverse ; @@ -4838,10 +4846,10 @@ VscrnInit( BYTE vmode ) borderattribute = colorborder ; updmode = tt_updmode ; /* Set screen update mode */ } - if ( marginbot == VscrnGetHeight(VTERM)-(tt_status[vmode]?1:0) || - VscrnGetHeight(VTERM) < 0 || - marginbot > tt_rows[VTERM] ) - marginbot = tt_rows[VTERM]; + if ( marginbot == VscrnGetHeight(vmode)-(tt_status[vmode]?1:0) || + VscrnGetHeight(vmode) < 0 || + marginbot > tt_rows[vmode] ) + marginbot = tt_rows[vmode]; } VscrnSetWidth( vmode, tt_cols[vmode] ) ; diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 528ea4ec..82d5d41f 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -219,6 +219,8 @@ extern int beepfreq, beeptime ; extern int pwidth, pheight; extern int win95lucida, win95hsl; +extern BOOL alternate_buffer_enabled; /* ckuus7.c */ + /* * =============================variables============================== */ @@ -261,7 +263,8 @@ int trueitalic = FALSE ; #endif /* KUI */ enum markmodes markmodeflag[VNUM] = {notmarking, notmarking, - notmarking, notmarking} ; + notmarking, notmarking, + notmarking} ; extern int tn_bold; /* TELNET negotiation bold */ extern int esc_exit; /* Escape back = exit */ @@ -297,8 +300,8 @@ extern char * keydefptr; extern int keymac; extern int keymacx ; -bool scrollstatus[VNUM] = {FALSE,FALSE,FALSE,FALSE} ; -bool escapestatus[VNUM] = {FALSE,FALSE,FALSE,FALSE} ; +bool scrollstatus[VNUM] = {FALSE,FALSE,FALSE,FALSE,FALSE} ; +bool escapestatus[VNUM] = {FALSE,FALSE,FALSE,FALSE,FALSE} ; extern int tt_idlelimit; /* Auto-exit Connect when idle */ extern int tt_timelimit; /* Auto-exit Connect after time */ extern bool flipscrnflag[] ; @@ -315,22 +318,25 @@ extern ascreen mousescreen; /* Screen during mouse actions */ extern unsigned char /* Video attribute bytes */ attribute=NUL, /* Current video attribute byte */ underlineattribute=NUL, - savedattribute[VNUM]={0,0,0,0}, /* Saved video attribute byte */ - saveddefaultattribute[VNUM]={0,0,0,0},/* Saved video attribute byte */ - savedunderlineattribute[VNUM]={0,0,0,0},/* Saved video attribute byte */ + savedattribute[VNUM]={0,0,0,0,0}, /* Saved video attribute byte */ + saveddefaultattribute[VNUM]={0,0,0,0,0},/* Saved video attribute byte */ + savedunderlineattribute[VNUM]={0,0,0,0,0},/* Saved video attribute byte */ defaultattribute=NUL, /* Default video attribute byte */ italicattribute=NUL, /* Default video attribute byte */ - saveditalicattribute[VNUM]={0,0,0,0}, + saveditalicattribute[VNUM]={0,0,0,0,0}, reverseattribute=NUL, - savedreverseattribute[VNUM]={0,0,0,0}, + savedreverseattribute[VNUM]={0,0,0,0,0}, graphicattribute=NUL, - savedgraphicattribute[VNUM]={0,0,0,0}, + savedgraphicattribute[VNUM]={0,0,0,0,0}, borderattribute=NUL, - savedborderattribute[VNUM]={0,0,0,0}; + savedborderattribute[VNUM]={0,0,0,0,0}; vtattrib attrib={0,0,0,0,0,0,0,0,0,0}, - savedattrib[VNUM]={{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}}, + savedattrib[VNUM]={{0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0}}, cmdattrib={0,0,0,0,0,0,0,0,0,0}; extern int wherex[]; /* Screen column, 1-based */ @@ -379,9 +385,9 @@ struct _vtG *GL = &G[0], *SSGL = NULL; /* GL and single shift GL */ struct _vtG *GR = &G[2]; /* GR */ struct _vtG *GNOW = &G[0]; struct _vtG savedG[VNUM][4]; -struct _vtG *savedGL[VNUM] = {NULL,NULL,NULL,NULL}, - *savedGR[VNUM] = {NULL,NULL,NULL,NULL}, - *savedSSGL[VNUM] = {NULL,NULL,NULL,NULL} ; +struct _vtG *savedGL[VNUM] = {NULL,NULL,NULL,NULL,NULL}, + *savedGR[VNUM] = {NULL,NULL,NULL,NULL,NULL}, + *savedSSGL[VNUM] = {NULL,NULL,NULL,NULL,NULL} ; static int Qsaved = FALSE; /* QANSI charset shifts */ struct _vtG QsavedG[4], *QsavedGL = NULL, @@ -406,11 +412,11 @@ bool relcursor = FALSE; bool keylock = FALSE; bool vt52graphics = FALSE; -bool saverelcursor[VNUM]={FALSE,FALSE,FALSE,FALSE}, - saved[VNUM]={FALSE,FALSE,FALSE,FALSE}; -int savedwrap[VNUM]={FALSE,FALSE,FALSE,FALSE} ; -int savedrow[VNUM] = {0,0,0,0}; -int savedcol[VNUM] = {0,0,0,0}; +bool saverelcursor[VNUM]={FALSE,FALSE,FALSE,FALSE,FALSE}, + saved[VNUM]={FALSE,FALSE,FALSE,FALSE,FALSE}; +int savedwrap[VNUM]={FALSE,FALSE,FALSE,FALSE,FALSE} ; +int savedrow[VNUM] = {0,0,0,0,0}; +int savedcol[VNUM] = {0,0,0,0,0}; bool deccolm = FALSE; /* 80/132-column mode */ bool decscnm = FALSE; /* Normal/reverse screen mode */ @@ -555,7 +561,7 @@ extern int tt_roll[]; /* Scrollback style */ extern int tt_rows[]; /* Screen rows */ extern int tt_cols[]; /* Screen columns */ int tt_cols_usr = 80; /* User default screen width */ -int tt_szchng[VNUM] = {1,1,1,0}; /* Screen Size Changed */ +int tt_szchng[VNUM] = {1,1,1,1,0}; /* Screen Size Changed */ extern int cmd_rows; /* Screen rows */ extern int cmd_cols; /* Screen columns */ extern int tt_ctstmo; /* CTS timeout */ @@ -3951,7 +3957,8 @@ geterasecolor( int vmode ) break; } /* else fall through and act as VTERM */ - case VTERM: + case VTERM_A: + case VTERM_B: if ( erasemode == 0 ) { erasecolor = attribute ; } @@ -6010,6 +6017,11 @@ doreset(int x) { /* x = 0 (soft), nonzero (hard) */ debug(F111,"doreset","x",x); + if (vmode == VTERM_B) { + vterm_buffer = VTERM_A; + vmode = VTERM_A; + } + tt_type_mode = tt_type ; attribute = defaultattribute = colornormal; /* Normal colors */ @@ -6269,6 +6281,29 @@ doreset(int x) { /* x = 0 (soft), nonzero (hard) */ VscrnIsDirty(VTERM) ; } +void setVTermBuffer(BOOL alternate) { + int nmode, omode; + + if (!IS_VTERM(vmode)) { + /* We're in VCMD or something else. Don't do anything */ + return; + } + + nmode = alternate && alternate_buffer_enabled ? VTERM_B : VTERM_A; + omode = vmode; + + if (omode == nmode) { + return; /* Already in the requested buffer - nothing to do */ + } + + vterm_buffer = nmode; + + vmode = VTERM ; /* VTERM is a #define for vterm_buffer */ + VscrnIsDirty(omode); + VscrnForceFullUpdate(); + VscrnIsDirty(VTERM); +} + /* The flow of characters from the communication device to the screen is: @@ -8251,12 +8286,13 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i switch (k) { /* Common Kermit actions first ... */ case K_EXIT: /* \Kexit: */ - if ( mode == VTERM ) { + if ( IS_VTERM(mode) ) { if ( markmodeflag[mode] != notmarking ) { markmode(mode,k); } - else if ( tt_escape ) - SetConnectMode(FALSE,CSX_ESCAPE);/* Exit from terminal emulator */ + else if ( tt_escape ) { + SetConnectMode(FALSE, CSX_ESCAPE);/* Exit from terminal emulator */ + } } else if ((mode == VCMD) && !(what & W_XFER)) { if ( @@ -8280,7 +8316,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i markmode(mode,k); /* return ; */ } - if ( mode == VTERM ) { + if ( IS_VTERM(mode) ) { quitnow = 1; strcpy(termessage, "Hangup and quit.\n"); SetConnectMode(0,CSX_USERDISC); @@ -8292,7 +8328,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i return; case K_BREAK: /* \Kbreak */ - if (mode == VTERM && !kbdlocked()) { + if (( IS_VTERM(mode) ) && !kbdlocked()) { int iosav = term_io; term_io = FALSE; msleep(750); /* Allow term thread to notice */ @@ -8304,7 +8340,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i os2push(); return; /* Push to system */ case K_RESET: /* \Kreset */ - if ( mode == VTERM ) + if ( IS_VTERM(mode) ) doreset(1); return; /* Reset terminal emulator */ case K_HELP: { /* \Khelp */ @@ -8343,7 +8379,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i return; /* Pop-up help message */ } case K_PRTCTRL: /* \Kprtscn,\Kprtctrl */ - if ( mode == VTERM ) + if ( IS_VTERM(mode) ) if ( xprint ) { /* Toggle Printer Ctrl mode on/off */ xprint = FALSE; /* It's on, turn it off */ if ( !cprint && !aprint ) @@ -8356,7 +8392,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i } return; case K_PRTAUTO: /* \Kprtauto */ - if ( mode == VTERM ) + if ( IS_VTERM(mode) ) if ( aprint ) { /* Toggle printer auto mode on/off */ setaprint(FALSE); /* It's on, turn it off */ if ( !cprint && !xprint ) @@ -8369,7 +8405,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i } return; case K_PRTCOPY: /* \Kprtcopy */ - if ( mode == VTERM ) + if ( IS_VTERM(mode) ) if ( cprint ) { /* Toggle printer copy mode on/off */ cprint = FALSE; /* It's on, turn it off */ if ( !aprint && !xprint ) @@ -8408,13 +8444,13 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i } return; case K_NULL: /* \Knull */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) sendcharduplex('\0',TRUE); return; /* Send a NUL */ case K_LBREAK: /* \Klbreak: */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) ttsndlb(); @@ -8443,7 +8479,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i } return; case K_ANSWERBACK: - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) sendcharsduplex(answerback,strlen(answerback), FALSE) ; return ; @@ -8452,49 +8488,49 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i #ifdef NETCONN #ifdef TCPSOCKET case K_TN_SAK: - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) do_tn_cmd((CHAR) TN_SAK); return; case K_TN_GA: /* TELNET Go Ahead */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) do_tn_cmd((CHAR) TN_GA); return; case K_TN_AO: /* TELNET Abort Output */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) do_tn_cmd((CHAR) TN_AO); return; case K_TN_EL: /* TELNET Erase Line */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) do_tn_cmd((CHAR) TN_EL); return; case K_TN_EC: /* TELNET Erase Character */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) do_tn_cmd((CHAR) TN_EC); return; case K_TN_AYT: /* TELNET Are You There */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) do_tn_cmd((CHAR) TN_AYT); return; case K_TN_IP: /* TELNET Interrupt Process */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) do_tn_cmd((CHAR) TN_IP); return; case K_TN_LOGOUT: /* TELNET LOGOUT */ - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) { tn_sopt(DO,TELOPT_LOGOUT); @@ -8503,7 +8539,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i return; case K_TN_NAWS: /* TELNET NAWS - Send Window Size */ #ifdef CK_NAWS - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) if ( !kbdlocked() ) { TELOPT_SB(TELOPT_NAWS).naws.x = 0; @@ -8615,12 +8651,12 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i return ; case K_TERMTYPE: /* Toggle Terminal Type */ - if ( mode == VTERM ) + if ( IS_VTERM(mode) ) settermtype((tt_type+1)%(TT_MAX+1), 0); return ; case K_STATUS: /* Toggle Status-Line Type */ - if ( mode == VTERM ) + if ( IS_VTERM(mode) ) setdecssdt((decssdt+1)%3); return ; @@ -8659,7 +8695,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i return ; case K_FNKEYS: /* Display Function Key Labels */ - if ( mode == VTERM ) { + if ( IS_VTERM(mode) ) { fkeypopup(mode); } return; @@ -8744,7 +8780,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i #endif /* OS2MOUSE */ if ( !kbdlocked() ) { - if ( mode == VTERM || + if ( IS_VTERM(mode) || mode == VCMD && activecmd == XXOUT ) { if (k >= K_ARR_MIN && k <= K_ARR_MAX) { if ( ISDG200( tt_type_mode ) ) { @@ -9266,7 +9302,7 @@ dokverb(int mode, int k) { /* 'k' is the kverbs[] table i return; } - if ( mode == VTERM ) { + if ( IS_VTERM(mode) ) { if (k == K_KB_HEB) { /* Hebrew keyboard support... */ if ( tt_kb_mode == KBM_HE ) set_kb_mode(KBM_EN) ; @@ -9514,8 +9550,8 @@ void markmode( BYTE vmode, int k ) { #ifndef NOKVERBS - static int rollstate[VNUM]={0,0,0,0}, - scrollstate[VNUM]={0,0,0,0}; + static int rollstate[VNUM]={0,0,0,0,0}, + scrollstate[VNUM]={0,0,0,0,0}; static KEY savekeys[8]={0,0,0,0,0,0,0,0}; static MACRO savemacros[8]={0,0,0,0,0,0,0,0}; con_event evt ; @@ -12022,7 +12058,8 @@ line25(int vmode) { } switch ( vmode ) { - case VTERM: { + case VTERM_A: + case VTERM_B: { /* Default Status line field sizes * Range Field Length * ------ ----------- --------------------- @@ -12196,20 +12233,25 @@ esc25(int h) { void settermstatus( int y ) { - if ( y != tt_status[VTERM] ) { + if ( y != tt_status[VTERM_A] ) { /* might need to fixup the margins */ - if ( marginbot == VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0) ) + if ( marginbot == VscrnGetHeight(VTERM_A)-(tt_status[VTERM_A]?1:0) ) if ( y ) { marginbot-- ; } else { marginbot++ ; } - tt_status[VTERM] = y; + tt_status[VTERM_A] = y; + tt_status[VTERM_B] = y; if ( y ){ - tt_szchng[VTERM] = 2 ; - tt_rows[VTERM]--; - VscrnInit( VTERM ) ; /* Height set here */ + tt_szchng[VTERM_A] = 2 ; + tt_rows[VTERM_A]--; + VscrnInit( VTERM_A ) ; /* Height set here */ + + tt_szchng[VTERM_B] = 2 ; + tt_rows[VTERM_B]--; + VscrnInit( VTERM_B ) ; /* Height set here */ #ifdef TCPSOCKET #ifdef CK_NAWS if (TELOPT_ME(TELOPT_NAWS) && ttmdm < 0) { @@ -12225,9 +12267,13 @@ settermstatus( int y ) #endif /* TCPSOCKET */ } else { - tt_szchng[VTERM] = 1 ; - tt_rows[VTERM]++; - VscrnInit( VTERM ) ; /* Height set here */ + tt_szchng[VTERM_A] = 1 ; + tt_rows[VTERM_A]++; + VscrnInit( VTERM_A ) ; /* Height set here */ + + tt_szchng[VTERM_B] = 1 ; + tt_rows[VTERM_B]++; + VscrnInit( VTERM_B ) ; /* Height set here */ #ifdef TCPSOCKET #ifdef CK_NAWS if (TELOPT_ME(TELOPT_NAWS) && ttmdm < 0){ @@ -12307,7 +12353,7 @@ settermtype( int x, int prompts ) static int savrvatt = 0; /* Reverse attribute */ static int savblatt = 0; /* Blink attribute */ static int savcmask = 0; /* For saving terminal bytesize */ - static int savedGset[VNUM] = {FALSE,FALSE,FALSE,FALSE}; + static int savedGset[VNUM] = {FALSE,FALSE,FALSE,FALSE,FALSE}; #ifndef KUI static int savstatus = TRUE ; #else @@ -12331,9 +12377,13 @@ settermtype( int x, int prompts ) savcolor = 0; savgrcol = 0 ; savulcol = 0 ; - scrninitialized[VTERM] = 0; - tt_status_usr[VTERM] = savstatus ; - settermstatus(tt_status_usr[VTERM]) ; + scrninitialized[VTERM_A] = 0; + tt_status_usr[VTERM_A] = savstatus ; + settermstatus(tt_status_usr[VTERM_A]) ; + + scrninitialized[VTERM_B] = 0; + tt_status_usr[VTERM_B] = savstatus ; + settermstatus(tt_status_usr[VTERM_B]) ; } if (savcmask) { /* Restore terminal bytesize */ @@ -12346,10 +12396,10 @@ settermtype( int x, int prompts ) fcharset = savfcs; savtcsl = -1; } - if ( savedGset[VTERM] ) { + if ( savedGset[VTERM_A] ) { for ( i = 0 ; i < 4 ; i++ ) - G[i] = savedG[VTERM][i] ; - savedGset[VTERM] = FALSE ; + G[i] = savedG[VTERM_A][i] ; + savedGset[VTERM_A] = FALSE ; } #ifdef COMMENT if (savcp > 0) { /* Restore code page */ @@ -12386,15 +12436,19 @@ settermtype( int x, int prompts ) colorreset = FALSE ; else colorreset = TRUE ; /* Turn Reset color mode on */ - scrninitialized[VTERM] = 0; /* To make it take effect */ + scrninitialized[VTERM_A] = 0; /* To make it take effect */ + scrninitialized[VTERM_B] = 0; /* To make it take effect */ savstatus = tt_status_usr[VTERM] ; if ( ISUNIXCON(tt_type) ) { - tt_status_usr[VTERM] = FALSE ; - settermstatus( tt_status_usr[VTERM] ) ; + tt_status_usr[VTERM_A] = FALSE ; + tt_status_usr[VTERM_B] = FALSE ; + settermstatus( tt_status_usr[VTERM_A] ) ; + settermstatus( tt_status_usr[VTERM_B] ) ; } - VscrnInit(VTERM); /* Reinit the screen buffer */ + VscrnInit(VTERM_A); /* Reinit the screen buffer */ + VscrnInit(VTERM_B); /* Reinit the screen buffer */ savcmask = cmask; /* Go to 8 bits */ cmask = 0xFF; @@ -12489,7 +12543,7 @@ settermtype( int x, int prompts ) for ( i = 0 ; i < 4 ; i++ ) { savedG[VTERM][i] = G[i] ; } - savedGset[VTERM] = TRUE ; + savedGset[VTERM_A] = TRUE ; G[0].def_designation = G[0].designation = TX_ASCII; G[0].init = TRUE; @@ -12533,7 +12587,7 @@ settermtype( int x, int prompts ) G[i].c1 = G[i].def_c1 = TRUE ; G[i].init = TRUE ; } - savedGset[VTERM] = TRUE ; + savedGset[VTERM_A] = TRUE ; } else if ( ISQNX(tt_type) ) { savcmask = cmask; /* Go to 8 bits */ @@ -12545,7 +12599,7 @@ settermtype( int x, int prompts ) /* Default Character-set is CP437 */ for ( i = 0 ; i < 4 ; i++ ) { - savedG[VTERM][i] = G[i] ; + savedG[VTERM_A][i] = G[i] ; } G[0].designation = G[0].def_designation = TX_ASCII ; G[0].size = G[0].def_size = cs94 ; @@ -12559,7 +12613,7 @@ settermtype( int x, int prompts ) G[i].c1 = G[i].def_c1 = TRUE ; G[i].init = TRUE ; } - savedGset[VTERM] = TRUE ; + savedGset[VTERM_A] = TRUE ; } else if ( ISQANSI(tt_type) ) { if ( !savcolor ) { @@ -12582,9 +12636,10 @@ settermtype( int x, int prompts ) savresetcol = colorreset; /* Save Reset Color mode */ colorreset = FALSE ; - scrninitialized[VTERM] = 0; /* To make it take effect */ + scrninitialized[VTERM_A] = 0; /* To make it take effect */ + scrninitialized[VTERM_B] = 0; - savstatus = tt_status_usr[VTERM] ; + savstatus = tt_status_usr[VTERM_A] ; } savcmask = cmask; /* Go to 8 bits */ @@ -12596,7 +12651,7 @@ settermtype( int x, int prompts ) /* Default Character-set is ASCII/CP437 */ for ( i = 0 ; i < 4 ; i++ ) { - savedG[VTERM][i] = G[i] ; + savedG[VTERM_A][i] = G[i] ; } /* Set G0 */ G[0].designation = G[0].def_designation = TX_ASCII ; @@ -12625,7 +12680,7 @@ settermtype( int x, int prompts ) G[3].c1 = G[3].def_c1 = FALSE ; G[3].national = CSisNRC(G[3].designation) ; G[3].init = TRUE ; - savedGset[VTERM] = TRUE ; + savedGset[VTERM_A] = TRUE ; } GNOW = GL = &G[0] ; @@ -12653,7 +12708,8 @@ settermtype( int x, int prompts ) updanswerbk() ; - VscrnInit(VTERM); + VscrnInit(VTERM_A); + VscrnInit(VTERM_B); initvik = TRUE; /* Tell doreset() to initialize the vik table */ doreset(1); /* Clear screen and home the cursor */ @@ -12663,7 +12719,8 @@ settermtype( int x, int prompts ) KuiSetProperty( KUI_TERM_TYPE, (intptr_t) tt_type, (intptr_t) 0 ) ; #endif /* KUI */ ipadl25() ; - VscrnIsDirty(VTERM); + VscrnIsDirty(VTERM_A); + VscrnIsDirty(VTERM_B); msleep(10); } @@ -14612,12 +14669,33 @@ vtcsi(void) /* RXVT - Scroll to bottom on key press */ break; case 1015: - /* URXVT - Enable URXVT Mosue Mode */ + /* URXVT - Enable URXVT Mouse Mode */ #ifdef OS2MOUSE debug(F100, "URXVT mouse tracking now OFF", "", 0); mouse_reporting_mode |= MOUSEREPORTING_URXVT; #endif break; + case 1046: + /* Disable switching to/from Alternate Screen Buffer, xterm */ + alternate_buffer_enabled = FALSE; + + /* Switch to VTERM_A if we're on VTERM_B currently */ + setVTermBuffer(FALSE); + break; + case 1047: + /* Use normal screen buffer, xterm */ + setVTermBuffer(TRUE); + break; + case 1048: + /* Restore cursor as in DECSC, xterm */ + break; + case 1049: + /* save cursor as in DECSC, xterm. After saving, switch + * to the Normal Screen Buffer. + * + * Combination of 1047 and 1048 */ + setVTermBuffer(TRUE); + break; default: break; } @@ -15200,6 +15278,25 @@ vtcsi(void) mouse_reporting_mode &= ~MOUSEREPORTING_URXVT; #endif break; + case 1046: + /* xterm: Enable switching to/from Alternate Screen Buffer, xterm */ + alternate_buffer_enabled = TRUE; + break; + case 1047: + /* Use alternate screen buffer, xterm */ + setVTermBuffer(FALSE); + break; + case 1048: + /* TODO: Save cursor as in DECSC, xterm */ + break; + case 1049: + /* TODO: save cursor as in DECSC, xterm. After saving, switch + * to the Alternate Screen Buffer, clearing it first. + * + * Combination of 1047 and 1048 */ + + setVTermBuffer(FALSE); + break; default: break; } @@ -18010,14 +18107,20 @@ vtcsi(void) if ( k < 3 ) pn[3] = 0 ; if ( pn[2] == 0 ) - pn[2] = tt_rows[VTERM] ; + pn[2] = tt_rows[VTERM_A] ; if ( pn[3] == 0 ) - pn[3] = tt_cols[VTERM] ; + pn[3] = tt_cols[VTERM_A] ; if ( tt_modechg == TVC_ENA ) { - tt_szchng[VTERM] = 1 ; - tt_rows[VTERM] = pn[2] ; - tt_cols[VTERM] = pn[3]%2 ? pn[3]+1 : pn[3] ; - VscrnInit( VTERM ) ; /* Size is set here */ + tt_szchng[VTERM_A] = 1 ; + tt_rows[VTERM_A] = pn[2] ; + tt_cols[VTERM_A] = pn[3]%2 ? pn[3]+1 : pn[3] ; + VscrnInit( VTERM_A ) ; /* Size is set here */ + + tt_szchng[VTERM_B] = 1 ; + tt_rows[VTERM_B] = pn[2] ; + tt_cols[VTERM_B] = pn[3]%2 ? pn[3]+1 : pn[3] ; + VscrnInit( VTERM_B ) ; /* Size is set here */ + msleep(50); #ifdef TCPSOCKET #ifdef CK_NAWS diff --git a/kermit/k95/ckoco4.c b/kermit/k95/ckoco4.c index d0b45049..4d0c0fdb 100644 --- a/kermit/k95/ckoco4.c +++ b/kermit/k95/ckoco4.c @@ -499,7 +499,7 @@ CopyVscrnToKbdBuffer( BYTE vmode, int select_mode ) { /* lcs for keyboard and rcs for sending. Do not allow */ /* sendcharsduplex() to translate. */ - if ( vmode == VTERM ) { + if ( IS_VTERM(vmode) ) { unsigned char * bytes; int nbytes; @@ -539,7 +539,7 @@ CopyVscrnToKbdBuffer( BYTE vmode, int select_mode ) { pData[j++] = selection[i] ; pData[j] = '\0'; - if ( vmode == VTERM ) + if ( IS_VTERM(vmode) ) sendcharsduplex(pData,j,FALSE); else putkeystr( vmode, pData ); @@ -618,7 +618,7 @@ CopyClipboardToKbdBuffer( BYTE vmode ) len = wcslen(pUClipbrdData); debug(F111,"Clipboard","pUClipbrdData length",len); - if ( vmode == VTERM ) { + if ( IS_VTERM(vmode) ) { unsigned char * bytes, * buf; int nbytes, bytecount=0; @@ -686,7 +686,7 @@ CopyClipboardToKbdBuffer( BYTE vmode ) pData[j] = '\0'; debug(F111,"Clipboard","pData length",j); - if ( vmode == VTERM ) + if ( IS_VTERM(vmode) ) sendcharsduplex(pData,j,FALSE); else putkeystr( vmode, pData ); diff --git a/kermit/k95/ckocon.c b/kermit/k95/ckocon.c index 7ba9e5c6..64c670cb 100644 --- a/kermit/k95/ckocon.c +++ b/kermit/k95/ckocon.c @@ -161,8 +161,8 @@ extern enum markmodes markmodeflag[VNUM] ; extern unsigned char colorhelp; extern unsigned char colorcmd; -int scrninitialized[VNUM] = {0,0,0} ; -bool scrollflag[VNUM] = {0,0,0}, flipscrnflag[VNUM] = {0,0,0}; +int scrninitialized[VNUM] = {0,0,0,0,0} ; +bool scrollflag[VNUM] = {0,0,0,0,0}, flipscrnflag[VNUM] = {0,0,0,0,0}; extern bool scrollstatus[] ; bool viewonly = FALSE ; /* View only terminal mode */ int updmode = TTU_FAST ; /* Fast/Smooth scrolling */ @@ -203,8 +203,8 @@ extern unsigned char /* Video attribute bytes */ savedattribute, /* Saved video attribute byte */ defaultattribute; /* Default video attribute byte */ -int wherex[VNUM]={1,1,1}; /* Screen column, 1-based */ -int wherey[VNUM]={1,1,1}; /* Screen row, 1-based */ +int wherex[VNUM]={1,1,1,1,1}; /* Screen column, 1-based */ +int wherey[VNUM]={1,1,1,1,1}; /* Screen row, 1-based */ int ConnectMode ; int quitnow, hangnow, outshift, tcs, langsv; @@ -231,8 +231,8 @@ CK_CURSORINFO crsr_command={88,0,8,1}; CK_CURSORINFO crsr_command={-88,0,8,1}; #endif /* NT */ -extern bool cursoron[VNUM] = {TRUE,TRUE,TRUE}; /* For speed, turn off when busy */ -extern bool cursorena[VNUM] = {TRUE,TRUE,TRUE}; /* Cursor enabled / disabled */ +extern bool cursoron[VNUM] = {TRUE,TRUE,TRUE,TRUE}; /* For speed, turn off when busy */ +extern bool cursorena[VNUM] = {TRUE,TRUE,TRUE,TRUE}; /* Cursor enabled / disabled */ extern bool printon; /* Printer is on */ extern bool xprint; /* Controller print in progress */ @@ -705,12 +705,12 @@ cleartermscreen( BYTE vmode ) { line->vt_line_attr = VT_LINE_ATTR_NORMAL ; for ( x = 0 ; x < MAXTERMCOL ; x++ ) { line->cells[x].c = ' ' ; - line->cells[x].a = vmode == VTERM ? attribute : colorcmd ; + line->cells[x].a = IS_VTERM(vmode) ? attribute : colorcmd ; line->vt_char_attrs[x] = VT_CHAR_ATTR_NORMAL ; } } lgotoxy(vmode,1, 1); - if ( IsConnectMode() || vmode != VTERM ) + if ( IsConnectMode() || !IS_VTERM(vmode)) VscrnIsDirty(vmode); else { vt100screen.ox = vt100screen.oy = 1 ; @@ -3404,7 +3404,7 @@ SetConnectMode( BOOL mode, int ExitCode ) { evt.type = error; switch ( mode ) { - case VTERM: + case TRUE: /* was: VTERM */ putevent(VTERM,evt); PostTerminalModeSem(); ResetCommandModeSem(); @@ -3421,7 +3421,7 @@ SetConnectMode( BOOL mode, int ExitCode ) { KuiSetTerminalStatusText(STATUS_HW, buf); #endif /* KUI */ break; - case VCMD: + case FALSE: /* was: VCMD */ /* putevent(VCMD,evt); */ unconect1(); if ( tt_async ) { @@ -3635,12 +3635,26 @@ void term_dimensions_changed(int x, int y) { int kui_setheightwidth(int x, int y) { - tt_szchng[VTERM] = (tt_status[VTERM]?2:1); - tt_rows[VTERM] = y - (tt_status[VTERM]?1:0); - tt_cols[VTERM] = x; + tt_szchng[VTERM_A] = (tt_status[VTERM_A]?2:1); + tt_rows[VTERM_A] = y - (tt_status[VTERM_A]?1:0); + tt_cols[VTERM_A] = x; + tt_cols_usr = x; + VscrnSetWidth( VTERM_A, x); + VscrnInit( VTERM_A ); /* Height set here */ + + /* Resize the alternate buffer too */ + tt_szchng[VTERM_B] = (tt_status[VTERM_B]?2:1); + tt_rows[VTERM_B] = y - (tt_status[VTERM_B]?1:0); + tt_cols[VTERM_B] = x; tt_cols_usr = x; - VscrnSetWidth( VTERM, x); - VscrnInit( VTERM ); /* Height set here */ + VscrnSetWidth( VTERM_B, x); + + /* The alternate buffer doesn't have scrollback, so set its + * scrollback size to the terminal height */ + tt_scrsize[VTERM_B] = tt_rows[VTERM_B]; + + VscrnInit( VTERM_B ); /* Height set here */ + term_dimensions_changed(x, y - (tt_status[VTERM]?1:0)); tt_szchng[VCMD] = (tt_status[VCMD]?2:1); @@ -3717,16 +3731,25 @@ os2_settermheight(int x) #ifdef KUI return(kui_setheightwidth(tt_cols[VTERM],x+(tt_status[VTERM]?1:0))); #else /* KUI */ - if (x > 8192/(tt_cols[VTERM])) { + if (x > 8192/(tt_cols[VTERM_A])) { printf("\n?The max screen area is 8192 cells: %d(rows) x %d(cols) = %d cells.\n", - x,tt_cols[VTERM],x*(tt_cols[VTERM])); + x,tt_cols[VTERM_A],x*(tt_cols[VTERM_A])); return(0); } - tt_szchng[VTERM] = (tt_status[VTERM]?2:1); - tt_rows[VTERM] = x; + tt_szchng[VTERM_A] = (tt_status[VTERM_A]?2:1); + tt_rows[VTERM_A] = x; + + tt_szchng[VTERM_B] = (tt_status[VTERM_B]?2:1); + tt_rows[VTERM_B] = x; + + /* The alternate buffer doesn't have scrollback, so set its + * scrollback size to the terminal height */ + tt_scrsize[VTERM_B] = tt_rows[VTERM_B]; + if (SysInited) { - VscrnInit( VTERM ); /* Height set here */ + VscrnInit( VTERM_A ); /* Height set here */ + VscrnInit( VTERM_B ); /* Height set here */ term_dimensions_changed(tt_cols[VTERM], x); } return(1); diff --git a/kermit/k95/ckocon.h b/kermit/k95/ckocon.h index 4c0b1c19..20aad81f 100644 --- a/kermit/k95/ckocon.h +++ b/kermit/k95/ckocon.h @@ -311,10 +311,16 @@ typedef struct videobuffer_struct { /* Video Buffer IDs */ #define VCMD 0 /* command mode */ -#define VTERM 1 /* terminal mode */ -#define VCS 2 /* client-server mode */ -#define VSTATUS 3 /* Terminal Mode Status Line */ -#define VNUM 4 /* number of video modes */ +#define VTERM_A 1 /* terminal mode - normal */ +#define VTERM_B 2 /* terminal mode - alternate buffer */ +#define VCS 3 /* client-server mode */ +#define VSTATUS 4 /* Terminal Mode Status Line */ +#define VNUM 5 /* number of video modes */ + +#define VTERM vterm_buffer +extern int vterm_buffer; /* ckuus7.c */ + +#define IS_VTERM(m) (m == VTERM_A || m == VTERM_B) /* Escape-sequence parser state definitions. */ /* For explanation, see ckucon.c, where this code is copied from. */ @@ -450,7 +456,7 @@ _PROTOTYP( BOOL IsOS2FullScreen, (void) ) ; _PROTOTYP( void SmoothScroll, (void) ) ; _PROTOTYP( void JumpScroll, (void ) ) ; - +_PROTOTYP( void setVTermBuffer, ( BOOL ) ); _PROTOTYP( APIRET VscrnSelect, ( BYTE, int ) ) ; _PROTOTYP( APIRET VscrnURL, ( BYTE, USHORT, USHORT ) ) ; _PROTOTYP( APIRET CopyVscrnToKbdBuffer, ( BYTE, int ) ) ; @@ -466,6 +472,7 @@ _PROTOTYP( bool VscrnIsPopup, ( BYTE) ) ; _PROTOTYP( void VscrnMark, ( BYTE, LONG, SHORT, SHORT ) ) ; _PROTOTYP( void VscrnUnmark, ( BYTE, LONG, SHORT, SHORT ) ) ; _PROTOTYP( void VscrnUnmarkAll, ( BYTE ) ) ; +_PROTOTYP( void VscrnForceFullUpdate, ( void )); _PROTOTYP( void shovscrn, ( void ) ) ; _PROTOTYP( void markdownone, ( BYTE ) ) ; _PROTOTYP( void markupone, ( BYTE ) ) ; diff --git a/kermit/k95/ckokey.c b/kermit/k95/ckokey.c index f192d6d5..947a3398 100644 --- a/kermit/k95/ckokey.c +++ b/kermit/k95/ckokey.c @@ -946,7 +946,7 @@ getshiftstate( void ) { #define KEY_BUF_SIZE (65536 / sizeof(con_event)) con_event Keystroke[VNUM][KEY_BUF_SIZE] ; -int start[VNUM]={0,0,0}, end[VNUM]={0,0,0} ; +int start[VNUM]={0,0,0,0,0}, end[VNUM]={0,0,0,0,0} ; void keybufinit( void ) { @@ -1086,6 +1086,10 @@ putkey( int kmode, int k ) { evt.key.scancode = k ; debug(F111,"putkey()","evt.key.scancode",k); } + + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + RequestKeyStrokeMutex( kmode, SEM_INDEFINITE_WAIT ) ; while ( (start[kmode] - end[kmode] == 1) || ( start[kmode] == 0 && end[kmode] == KEY_BUF_SIZE - 1 ) ) @@ -1192,6 +1196,9 @@ putkverb( int kmode, int k ) { } } + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + RequestKeyStrokeMutex( kmode, SEM_INDEFINITE_WAIT ) ; while ( (start[kmode] - end[kmode] == 1) || ( start[kmode] == 0 && end[kmode] == KEY_BUF_SIZE - 1 ) ) @@ -1220,6 +1227,9 @@ puterror( int kmode ) { int rc = 0, count = 0 ; con_event evt ; + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + evt.type = error ; RequestKeyStrokeMutex( kmode, SEM_INDEFINITE_WAIT ) ; @@ -1249,6 +1259,9 @@ putesc( int kmode, int k ) { int rc = 0, count = 0 ; con_event evt ; + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + evt.type = esc ; evt.esc.key = k & ~F_ESC ; @@ -1279,6 +1292,9 @@ putcsi( int kmode, int k ) { int rc = 0, count = 0 ; con_event evt ; + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + evt.type = csi ; evt.csi.key = k & ~F_CSI ; @@ -1309,6 +1325,9 @@ putmacro( int kmode, char * s ) { int rc = 0, count = 0 ; con_event evt ; + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + evt.type = macro ; evt.macro.string = strdup(s) ; @@ -1338,6 +1357,9 @@ putliteral( int kmode, char * s ) { int rc = 0, count = 0 ; con_event evt ; + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + evt.type = literal ; evt.literal.string = strdup(s) ; @@ -1367,6 +1389,9 @@ putclick( int kmode, char but, char alt, char ctrl, char shift, char dbl, char d int rc = 0, count = 0 ; con_event evt ; + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + evt.type = mouse ; evt.mouse.button = but; evt.mouse.alt = (alt != 0); @@ -1402,6 +1427,9 @@ putevent( int kmode, con_event e ) { int rc = 0; con_event evt ; + /* VTERM_B events go to the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + switch ( e.type ) { case key: rc = putkey( kmode, e.key.scancode ) ; @@ -1442,6 +1470,9 @@ getevent( int kmode, con_event * evt ) { int rc = 0, fc = 0 ; ULONG PostCount ; + /* VTERM_B events come from the VTERM_A queue */ + kmode = kmode == VTERM_B ? VTERM_A : kmode; + fc = RequestKeyStrokeMutex( kmode, SEM_INDEFINITE_WAIT ) ; debug(F111,"getevent","RequestKeyStrokeMutex()",fc); if ( start[kmode] != end[kmode] ) { @@ -1518,6 +1549,7 @@ KbdHandlerCleanup( void ) { resizing events */ #ifndef NOLOCAL +void win32WindowEvent( int mode, WINDOW_BUFFER_SIZE_RECORD r ) { LONG sz ; @@ -1540,6 +1572,16 @@ _PROTOTYP( int rlog_naws, (void) ) ; VscrnSetHeight( mode, r.dwSize.Y ) ; VscrnScroll( mode, UPWARD, 1, sz, sz, TRUE, SP ) ; cleartermscreen(mode); + + if (IS_VTERM(mode)) { + int otherMode = mode == VTERM_A ? VTERM_B : VTERM_A; + sz = (VscrnGetEnd(otherMode) - VscrnGetTop(otherMode) + + VscrnGetBufferSize(otherMode) + 1)%VscrnGetBufferSize(otherMode) ; + VscrnSetWidth( otherMode, r.dwSize.X ) ; + VscrnSetHeight( otherMode, r.dwSize.Y ) ; + VscrnScroll( otherMode, UPWARD, 1, sz, sz, TRUE, SP ) ; + cleartermscreen(otherMode); + } #ifdef TCPSOCKET if (ttmdm < 0 && TELOPT_ME(TELOPT_NAWS)) { tn_snaws() ; @@ -1994,8 +2036,11 @@ win32KeyEvent( int mode, KEY_EVENT_RECORD keyrec ) printf("\n"); #endif /* COMMENT */ + + debug(F111, "win32KeyEvent", "mode", mode); + #ifdef PCTERM - if ( mode == VTERM ) { + if ( IS_VTERM(mode) ) { /* Ctrl-CAPSLOCK is the toggle for PCTERM */ static int pcterm_ctrl_down = 0, pcterm_ctrl_up = 0, pcterm_caps_down = 0, pcterm_caps_up = 0; @@ -2069,6 +2114,8 @@ win32KeyEvent( int mode, KEY_EVENT_RECORD keyrec ) c = getKeycodeFromKeyRec(&keyrec, (WORD *)buf, CHCOUNT); + debug(F111, "win32KeyEvent", "c", c); + if ( c >= 0 ) { #ifdef NOSETKEY con_event evt; diff --git a/kermit/k95/ckosyn.c b/kermit/k95/ckosyn.c index ef199454..431688fb 100644 --- a/kermit/k95/ckosyn.c +++ b/kermit/k95/ckosyn.c @@ -28,7 +28,7 @@ #include "ckocon.h" -HANDLE hmtxKeyStroke[VNUM] = {(HANDLE) 0,(HANDLE) 0,(HANDLE) 0} ; +HANDLE hmtxKeyStroke[VNUM] = {(HANDLE) 0,(HANDLE) 0,(HANDLE) 0,(HANDLE) 0} ; HANDLE hmtxLocalEcho = (HANDLE) 0 ; HANDLE hmtxTCPIP = (HANDLE) 0 ; HANDLE hmtxComm = (HANDLE) 0; @@ -38,8 +38,8 @@ HANDLE hmtxNetCmd = (HANDLE) 0 ; HANDLE hmtxKeyboard = (HANDLE) 0 ; HANDLE hmtxAlarm = (HANDLE) 0 ; HANDLE hmtxScreen = (HANDLE) 0 ; -HANDLE hmtxVscrn[VNUM] = { (HANDLE) 0,(HANDLE) 0, (HANDLE) 0} ; -HANDLE hmtxVscrnDirty[VNUM] = { (HANDLE) 0, (HANDLE) 0, (HANDLE) 0 } ; +HANDLE hmtxVscrn[VNUM] = { (HANDLE) 0,(HANDLE) 0, (HANDLE) 0,(HANDLE) 0} ; +HANDLE hmtxVscrnDirty[VNUM] = { (HANDLE) 0, (HANDLE) 0, (HANDLE) 0,(HANDLE) 0 } ; HANDLE hmtxConnectMode = (HANDLE) 0 ; HANDLE hmtxDebug = (HANDLE) 0; HANDLE hmtxTelnet = (HANDLE) 0; @@ -49,7 +49,7 @@ HANDLE hmtxThreadMgmt = (HANDLE) 0 ; HANDLE hmtxSSL = (HANDLE) 0; #endif /* CK_SSL */ -HANDLE hevEventAvail[VNUM] = {(HANDLE) 0,(HANDLE) 0,(HANDLE) 0} ; +HANDLE hevEventAvail[VNUM] = {(HANDLE) 0,(HANDLE) 0,(HANDLE) 0,(HANDLE) 0} ; HANDLE hevLocalEchoAvail = (HANDLE) 0 ; #ifdef NETCMD HANDLE hevNetCmdAvail = (HANDLE) 0 ; @@ -69,12 +69,13 @@ HANDLE hevCtrlC[4] = {(HANDLE) 0,(HANDLE) 0,(HANDLE) 0,(HANDLE) 0} ; HANDLE hevAlarmSig[4] = {(HANDLE) 0,(HANDLE) 0,(HANDLE) 0,(HANDLE) 0} ; UINT htimAlarm = (UINT) 0 ; -UINT htimVscrn[VNUM] = {(UINT) 0, (UINT) 0, (UINT) 0} ; +UINT htimVscrn[VNUM] = {(UINT) 0, (UINT) 0,(UINT)0, (UINT) 0} ; -HANDLE hevVscrnTimer[VNUM] = { (HANDLE) 0, (HANDLE) 0,(HANDLE) 0 } ; -HANDLE hevVscrnDirty[VNUM] = { (HANDLE) 0, (HANDLE) 0,(HANDLE) 0 } ; +HANDLE hevVscrnTimer[VNUM] = { (HANDLE) 0, (HANDLE) 0,(HANDLE) 0,(HANDLE) 0 } ; +HANDLE hevVscrnDirty[VNUM] = { (HANDLE) 0, (HANDLE) 0,(HANDLE) 0,(HANDLE) 0 } ; HANDLE hevVscrnUpdate[VNUM][2] = {{(HANDLE) NULL, (HANDLE) NULL}, + {(HANDLE) NULL, (HANDLE) NULL}, {(HANDLE) NULL, (HANDLE) NULL}, {(HANDLE) NULL, (HANDLE) NULL}}; HANDLE hmuxCtrlC[4][2] = { { (HANDLE) NULL, (HANDLE) NULL }, @@ -114,7 +115,7 @@ HANDLE hmtxRichEdit = (HANDLE) 0 ; #include "ckocon.h" -HMTX hmtxKeyStroke[VNUM] = {(HMTX) 0,(HMTX) 0,(HMTX) 0} ; +HMTX hmtxKeyStroke[VNUM] = {(HMTX) 0,(HMTX) 0,(HMTX) 0,(HMTX) 0} ; #ifdef NETCMD HMTX hmtxNetCmd = (HMTX) 0 ; #endif @@ -124,8 +125,8 @@ HMTX hmtxComm = (HMTX) 0 ; HMTX hmtxKeyboard = (HMTX) 0 ; HMTX hmtxAlarm = (HMTX) 0 ; HMTX hmtxScreen = (HMTX) 0 ; -HMTX hmtxVscrn[VNUM] = { (HMTX) 0, (HMTX) 0, (HMTX) 0} ; -HMTX hmtxVscrnDirty[VNUM] = { (HMTX) 0, (HMTX) 0, (HMTX) 0} ; +HMTX hmtxVscrn[VNUM] = { (HMTX) 0, (HMTX) 0, (HMTX) 0, (HMTX) 0} ; +HMTX hmtxVscrnDirty[VNUM] = { (HMTX) 0, (HMTX) 0, (HMTX) 0, (HMTX) 0} ; HMTX hmtxConnectMode = (HMTX) 0 ; HMTX hmtxDebug = (HMTX) 0 ; HMTX hmtxTelnet = (HMTX) 0 ; @@ -134,7 +135,7 @@ HMTX hmtxThreadMgmt = (HMTX) 0 ; HMTX hmtxSSL = (HMTX) 0; #endif /* CK_SSL */ -HEV hevEventAvail[VNUM] = {(HEV) 0,(HEV) 0,(HEV) 0} ; +HEV hevEventAvail[VNUM] = {(HEV) 0,(HEV) 0,(HEV) 0,(HEV) 0} ; HEV hevLocalEchoAvail = (HEV) 0 ; #ifdef NETCMD HEV hevNetCmdAvail = (HEV) 0 ; @@ -150,15 +151,15 @@ HEV hevConKbdHandlerThreadDown = (HEV) 0 ; HEV hevTermScrnUpdThreadDown = (HEV) 0 ; HEV hevKeyMapInit = (HEV) 0 ; HEV hevKbdThread = (HEV) 0 ; -HEV hevVscrnTimer[VNUM] = { (HEV) 0, (HEV) 0, (HEV) 0 } ; -HEV hevVscrnDirty[VNUM] = { (HEV) 0, (HEV) 0, (HEV) 0 } ; +HEV hevVscrnTimer[VNUM] = { (HEV) 0, (HEV) 0, (HEV) 0, (HEV) 0 } ; +HEV hevVscrnDirty[VNUM] = { (HEV) 0, (HEV) 0, (HEV) 0, (HEV) 0 } ; HEV hevCtrlC[4] = { (HEV) 0,(HEV) 0,(HEV) 0,(HEV) 0 } ; HEV hevAlarmSig[4] = { (HEV) 0,(HEV) 0,(HEV) 0,(HEV) 0 } ; HTIMER htimAlarm = (HTIMER) 0 ; -HTIMER htimVscrn[VNUM] = {(HTIMER) 0,(HTIMER) 0,(HTIMER) 0} ; +HTIMER htimVscrn[VNUM] = {(HTIMER) 0,(HTIMER) 0,(HTIMER) 0,(HTIMER) 0} ; -HMUX hmuxVscrnUpdate[VNUM] = {(HMUX) 0,(HMUX) 0,(HMUX) 0} ; +HMUX hmuxVscrnUpdate[VNUM] = {(HMUX) 0,(HMUX) 0,(HMUX) 0,(HMUX) 0} ; HMUX hmuxCtrlC[4] = { (HMUX) 0,(HMUX) 0,(HMUX) 0,(HMUX) 0 } ; HMUX hmuxAlarmSig[4] = { (HMUX) 0,(HMUX) 0,(HMUX) 0,(HMUX) 0 } ; HMUX hmuxCtrlCAlarmSig = (HMUX) 0 ; @@ -750,9 +751,15 @@ PostEventAvailSem( int vmode ) #ifdef NT BOOL rc = 0 ; + /* VTERM_B events come from the VTERM_A queue */ + vmode = vmode == VTERM_B ? VTERM_A : vmode; + rc = SetEvent( hevEventAvail[vmode] ) ; return rc == TRUE ? 0 : GetLastError() ; #else /* not NT */ + /* VTERM_B events come from the VTERM_A queue */ + vmode = vmode == VTERM_B ? VTERM_A : vmode; + return DosPostEventSem( hevEventAvail[vmode] ) ; #endif /* NT */ } @@ -763,10 +770,17 @@ WaitEventAvailSem( int vmode, ULONG timo ) #ifdef NT DWORD rc = 0 ; + /* VTERM_B events come from the VTERM_A queue */ + vmode = vmode == VTERM_B ? VTERM_A : vmode; + rc = WaitForSingleObjectEx( hevEventAvail[vmode], timo, TRUE ) ; return rc == WAIT_OBJECT_0 ? 0 : rc ; #else /* not NT */ APIRET rc = 0 ; + + /* VTERM_B events come from the VTERM_A queue */ + vmode = vmode == VTERM_B ? VTERM_A : vmode; + rc = DosWaitEventSem( hevEventAvail[vmode], timo ) ; return rc ; #endif /* NT */ @@ -778,6 +792,9 @@ WaitAndResetEventAvailSem( int vmode, ULONG timo ) #ifdef NT DWORD rc = 0 ; + /* VTERM_B events come from the VTERM_A queue */ + vmode = vmode == VTERM_B ? VTERM_A : vmode; + rc = WaitForSingleObjectEx( hevEventAvail[vmode], timo, TRUE ) ; if ( rc == WAIT_OBJECT_0 ) ResetEvent( hevEventAvail[vmode] ) ; @@ -786,6 +803,9 @@ WaitAndResetEventAvailSem( int vmode, ULONG timo ) APIRET rc = 0 ; ULONG semcount = 0 ; + /* VTERM_B events come from the VTERM_A queue */ + vmode = vmode == VTERM_B ? VTERM_A : vmode; + rc = DosWaitEventSem( hevEventAvail[vmode], timo ) ; if ( !rc ) DosResetEventSem( hevEventAvail[vmode], &semcount ) ; @@ -799,12 +819,18 @@ ResetEventAvailSem( int vmode ) #ifdef NT BOOL rc = 0 ; + /* VTERM_B events come from the VTERM_A queue */ + vmode = vmode == VTERM_B ? VTERM_A : vmode; + rc = ResetEvent( hevEventAvail[vmode] ) ; return rc ; #else /* not NT */ APIRET rc = 0 ; ULONG semcount = 0 ; + /* VTERM_B events come from the VTERM_A queue */ + vmode = vmode == VTERM_B ? VTERM_A : vmode; + rc = DosResetEventSem( hevEventAvail[vmode], &semcount ) ; return semcount ; #endif /* NT */ diff --git a/kermit/k95/ckotio.c b/kermit/k95/ckotio.c index 9ed79da2..513a18aa 100644 --- a/kermit/k95/ckotio.c +++ b/kermit/k95/ckotio.c @@ -2079,7 +2079,8 @@ sysinit() { debug(F100,"about to VscrnInit()","",0); /* Setup the Virtual Screens */ VscrnInit( VCMD ) ; - VscrnInit( VTERM ) ; + VscrnInit( VTERM_A ) ; + VscrnInit( VTERM_B ) ; /* VscrnInit( VCS ) ; */ VscrnInit( VSTATUS ) ; settermtype(tt_type,1); @@ -7702,6 +7703,8 @@ congev( int vmode, int timo ) { con_event evt ; int tt,tr,interval,i ; + debug(F111, "congev", "vmode", vmode); + #ifdef IKSD if ( inserver ) { int ch; diff --git a/kermit/k95/ckuus2.c b/kermit/k95/ckuus2.c index 8fc69533..112601d4 100644 --- a/kermit/k95/ckuus2.c +++ b/kermit/k95/ckuus2.c @@ -8085,6 +8085,11 @@ static char *hxyterm[] = { " Selects type type of terminal to emulate. Type SET TERMINAL TYPE ? to", " see a complete list.", " ", +"SET TERMINAL ALTERNATE-BUFFER { ENABLED, DISABLED }", +" Enables or disables the escape sequence for switching to the alternate", +" terminal screen buffer. This setting can also be changed via an escape", +" sequence so setting it to disabled may not prevent its use entirely.", +" ", "SET TERMINAL ANSWERBACK { OFF, ON }", " Disables/enables the ENQ/Answerback sequence (Kermit version term-type).", " ", diff --git a/kermit/k95/ckuus3.c b/kermit/k95/ckuus3.c index 678c38fe..093b7768 100644 --- a/kermit/k95/ckuus3.c +++ b/kermit/k95/ckuus3.c @@ -2552,7 +2552,7 @@ getyesno(msg, flags) char * msg; int flags; ) return(popup_readyesno(vmode,NULL,msg,flags)); #endif /* COMMENT */ - if (vmode == VTERM) { + if (IS_VTERM(vmode)) { vmode = VCMD; VscrnIsDirty(VTERM); VscrnIsDirty(VCMD); diff --git a/kermit/k95/ckuus5.c b/kermit/k95/ckuus5.c index acbca794..1150d4cb 100644 --- a/kermit/k95/ckuus5.c +++ b/kermit/k95/ckuus5.c @@ -6035,6 +6035,7 @@ shotrm() { extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode, decscnm, decscnm_usr, tt_diff_upd, tt_senddata, wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix; + extern BOOL alternate_buffer_enabled; int lines = 0; #ifdef KUI extern CKFLOAT tt_linespacing[]; @@ -6255,7 +6256,10 @@ shotrm() { printf(" %19s: %-13s %13s: %-15s\n","Debug", showoff(debses),"Session log", seslog? sesfil : "(none)" ); if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; } - + printf(" %19s: %-13s\n","Alternate Buffer", + alternate_buffer_enabled ? ( VTERM == VTERM_B ? "enabled, active" : "enabled") + : (VTERM == VTERM_B ? "disabled, active" : "disabled")); + if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; } /* Display colors (should become SHOW COLORS) */ { USHORT row, col; diff --git a/kermit/k95/ckuus7.c b/kermit/k95/ckuus7.c index 4dfcd4ce..f27c1a57 100644 --- a/kermit/k95/ckuus7.c +++ b/kermit/k95/ckuus7.c @@ -921,6 +921,7 @@ int nfntab = (sizeof(fntab) / sizeof(struct keytab)); /* Terminal parameters table */ static struct keytab trmtab[] = { #ifdef OS2 + { "alternate-buffer", XYTALTBUF, 0 }, { "answerback", XYTANS, 0 }, #endif /* OS2 */ #ifdef CK_APC @@ -1141,6 +1142,14 @@ struct keytab graphsettab[] = { /* DEC VT Graphic Sets */ { "keyboard", TT_GR_KBD, 0 } }; int ngraphset = (sizeof(graphsettab) / sizeof(struct keytab)); + +struct keytab altbufktab[] = { /* Set TERM ALTERNATE-BUFFER */ + { "active", AB_ACTIVE, CM_INV}, + { "disabled", AB_DISABLED, 0 }, + { "enabled", AB_ENABLED, 0 }, + { "inactive", AB_INACTIVE, CM_INV } +}; +int naltbuf = (sizeof(altbufktab) / sizeof(struct keytab)); #endif /* OS2 */ struct keytab adltab[] = { /* Autodownload Options */ @@ -1358,9 +1367,9 @@ int tt_cursor_usr = 0; /* Users Terminal cursor type */ int tt_cursorena_usr = 1; /* Users Terminal cursor enabled */ int tt_cursor_blink = 1; /* Terminal Cursor Blink */ int tt_answer = 0; /* Terminal answerback (disabled) */ -int tt_scrsize[VNUM] = {512,512,512,1}; /* Terminal scrollback buffer size */ -int tt_roll[VNUM] = {1,1,1,1}; /* Terminal roll (on) */ -int tt_rkeys[VNUM] = {1,1,1,1}; /* Terminal roll keys (send) */ +int tt_scrsize[VNUM] = {512,512,24,512,1}; /* Terminal scrollback buffer size */ +int tt_roll[VNUM] = {1,1,1,1,1}; /* Terminal roll (on) */ +int tt_rkeys[VNUM] = {1,1,1,1,1}; /* Terminal roll keys (send) */ int tt_pacing = 0; /* Terminal output-pacing (none) */ int tt_ctstmo = 15; /* Terminal transmit-timeout */ int tt_codepage = -1; /* Terminal code-page */ @@ -1368,22 +1377,24 @@ int tt_update = 100; /* Terminal screen-update interval */ int tt_updmode = TTU_FAST; /* Terminal screen-update mode FAST */ extern int updmode; #ifndef KUI -int tt_status[VNUM] = {1,1,0,0}; /* Terminal status line displayed */ -int tt_status_usr[VNUM] = {1,1,0,0}; +int tt_status[VNUM] = {1,1,1,0,0}; /* Terminal status line displayed */ +int tt_status_usr[VNUM] = {1,1,1,0,0}; #else /* KUI */ extern CKFLOAT floatval; -CKFLOAT tt_linespacing[VNUM] = {1.0,1.0,1.0,1.0}; +CKFLOAT tt_linespacing[VNUM] = {1.0,1.0,1.0,1.0,1.0}; #ifdef K95G -int tt_status[VNUM] = {1,1,0,0}; /* Terminal status line displayed */ -int tt_status_usr[VNUM] = {1,1,0,0}; +int tt_status[VNUM] = {1,1,1,0,0}; /* Terminal status line displayed */ +int tt_status_usr[VNUM] = {1,1,1,0,0}; #else /* K95G */ -int tt_status[VNUM] = {0,0,0,0}; /* Terminal status line displayed */ -int tt_status_usr[VNUM] = {0,0,0,0}; +int tt_status[VNUM] = {0,0,0,0,0}; /* Terminal status line displayed */ +int tt_status_usr[VNUM] = {0,0,0,0,0}; #endif /* K95G */ #endif /* KUI */ int tt_senddata = 0; /* Let host read terminal data */ extern int wy_blockend; /* Terminal Send Data EOB type */ int tt_hidattr = 1; /* Attributes are hidden */ +int vterm_buffer = VTERM_A; /* Which buffer VTERM is right now (normal or alternate) */ +BOOL alternate_buffer_enabled = TRUE; /* If the alternate screen buffer is enabled */ extern unsigned char colornormal, colorselect, colorunderline, colorstatus, colorhelp, colorborder, @@ -4422,8 +4433,10 @@ settrm() { return(-9); break; } - scrninitialized[VTERM] = 0; - VscrnInit(VTERM); + scrninitialized[VTERM_A] = 0; + VscrnInit(VTERM_A); + scrninitialized[VTERM_B] = 0; + VscrnInit(VTERM_B); } return(success = 1); @@ -4500,8 +4513,9 @@ settrm() { return(success = 0); } if ((y = cmcfm()) < 0) return(y); - tt_scrsize[VTERM] = x; - VscrnInit(VTERM); + /* The alternate buffer (VTERM_B) doesn't get scrollback */ + tt_scrsize[VTERM_A] = x; + VscrnInit(VTERM_A); return(success = 1); #endif /* OS2 */ @@ -4731,6 +4745,30 @@ settrm() { return(success = 1); #ifdef OS2 + case XYTALTBUF: { /* SET TERMINAL ALTERNATE-BUFFER */ + if ((x = cmkey(altbufktab,naltbuf,"Alternate Buffer setting","", + xxstring)) < 0) { + return (x); + } + switch(x) { + case AB_DISABLED: + alternate_buffer_enabled = FALSE; + break; + case AB_ENABLED: + alternate_buffer_enabled = TRUE; + break; + case AB_INACTIVE: { + vterm_buffer = VTERM_A; + } + break; + case AB_ACTIVE: { + vterm_buffer = VTERM_B; + } + break; + } + } + return(success = 1); + break; case XYTANS: { /* SET TERMINAL ANSWERBACK */ /* NOTE: We let them enable and disable the answerback sequence, but we @@ -5217,9 +5255,13 @@ settrm() { SetCols(VCMD); cmd_rows = y; - tt_szchng[VTERM] = 2 ; - tt_rows[VTERM] = pheight - (tt_status[VTERM]?1:0); - VscrnInit(VTERM); + tt_szchng[VTERM_A] = 2 ; + tt_rows[VTERM_A] = pheight - (tt_status[VTERM_A]?1:0); + VscrnInit(VTERM_A); + + tt_szchng[VTERM_B] = 2 ; + tt_rows[VTERM_B] = pheight - (tt_status[VTERM_B]?1:0); + VscrnInit(VTERM_B); break; @@ -5255,11 +5297,17 @@ settrm() { cmd_rows = y; cmd_cols = 80; - marginbot = y-(tt_status[VTERM]?1:0); - tt_szchng[VTERM] = 2; - tt_rows[VTERM] = y - (tt_status[VTERM]?1:0); - tt_cols[VTERM] = 80; - VscrnInit(VTERM); + marginbot = y-(tt_status[VTERM_A]?1:0); + tt_szchng[VTERM_A] = 2; + tt_rows[VTERM_A] = y - (tt_status[VTERM_A]?1:0); + tt_cols[VTERM_A] = 80; + VscrnInit(VTERM_A); + + marginbot = y-(tt_status[VTERM_B]?1:0); + tt_szchng[VTERM_B] = 2; + tt_rows[VTERM_B] = y - (tt_status[VTERM_B]?1:0); + tt_cols[VTERM_B] = 80; + VscrnInit(VTERM_B); break; } tt_modechg = x; @@ -5273,19 +5321,24 @@ settrm() { extern int marginbot; if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y); if ((x = cmcfm()) < 0) return(x); - if (y != tt_status[VTERM] || y != tt_status_usr[VTERM]) { + if (y != tt_status[VTERM_A] || y != tt_status_usr[VTERM_A]) { /* Might need to fixup the margins */ - if ( marginbot == VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0) ) + if ( marginbot == VscrnGetHeight(VTERM_A)-(tt_status[VTERM_A]?1:0) ) if (y) { marginbot--; } else { marginbot++; } - tt_status_usr[VTERM] = tt_status[VTERM] = y; + tt_status_usr[VTERM_A] = tt_status[VTERM_A] = y; + tt_status_usr[VTERM_B] = tt_status[VTERM_B] = y; if (y) { - tt_szchng[VTERM] = 2; - tt_rows[VTERM]--; - VscrnInit(VTERM); /* Height set here */ + tt_szchng[VTERM_A] = 2; + tt_rows[VTERM_A]--; + VscrnInit(VTERM_A); /* Height set here */ + + tt_szchng[VTERM_B] = 2; + tt_rows[VTERM_B]--; + VscrnInit(VTERM_B); /* Height set here */ #ifdef TNCODE if (TELOPT_ME(TELOPT_NAWS)) tn_snaws(); @@ -5299,9 +5352,13 @@ settrm() { ssh_snaws(); #endif /* SSHBUILTIN */ } else { - tt_szchng[VTERM] = 1; - tt_rows[VTERM]++; - VscrnInit(VTERM); /* Height set here */ + tt_szchng[VTERM_A] = 1; + tt_rows[VTERM_A]++; + VscrnInit(VTERM_A); /* Height set here */ + + tt_szchng[VTERM_B] = 1; + tt_rows[VTERM_B]++; + VscrnInit(VTERM_B); /* Height set here */ #ifdef TNCODE if (TELOPT_ME(TELOPT_NAWS)) tn_snaws(); diff --git a/kermit/k95/ckuusr.c b/kermit/k95/ckuusr.c index 1e7bcd65..d7837eb2 100644 --- a/kermit/k95/ckuusr.c +++ b/kermit/k95/ckuusr.c @@ -141,7 +141,7 @@ extern bool viewonly; extern int k95stdout; extern int tt_scroll; #ifndef NOTERM -extern tt_status[VNUM]; +extern int tt_status[VNUM]; #endif /* NOTERM */ #include "ckossh.h" #ifdef KUI diff --git a/kermit/k95/ckuusr.h b/kermit/k95/ckuusr.h index e4233acf..212d8c0e 100644 --- a/kermit/k95/ckuusr.h +++ b/kermit/k95/ckuusr.h @@ -1331,6 +1331,13 @@ struct stringint { /* String and (wide) integer */ #define XYTIACT 63 /* SET TERM IDLE-ACTION */ #define XYTLSP 64 /* SET TERM LINE-SPACING */ #define XYTLFD 65 /* SET TERM LF-DISPLAY */ +#ifdef OS2 +#define XYTALTBUF 66 /* SET TERM ALTERNATE-BUFFER */ +#define AB_ENABLED 0 +#define AB_DISABLED 1 +#define AB_INACTIVE 2 /* Force the terminal out of the alternate screen buffer */ +#define AB_ACTIVE 3 /* Force the terminal into the alternate screen buffer */ +#endif /* OS2 */ #define XYATTR 34 /* Attribute packets */ #define XYSERV 35 /* Server parameters */