@@ -2146,6 +2146,49 @@ describe('InputHandler', () => {
21462146 } ) ;
21472147 } ) ;
21482148 } ) ;
2149+
2150+ describe ( 'DECSCA and DECSED/DECSEL' , ( ) => {
2151+ it ( 'default is unprotected' , async ( ) => {
2152+ await inputHandler . parseP ( 'some text' ) ;
2153+ await inputHandler . parseP ( '\x1b[?2K' ) ;
2154+ assert . deepEqual ( getLines ( bufferService , 2 ) , [ '' , '' ] ) ;
2155+ await inputHandler . parseP ( 'some text' ) ;
2156+ await inputHandler . parseP ( '\x1b[?2J' ) ;
2157+ assert . deepEqual ( getLines ( bufferService , 2 ) , [ '' , '' ] ) ;
2158+ } ) ;
2159+ it ( 'DECSCA 1 with DECSEL' , async ( ) => {
2160+ await inputHandler . parseP ( '###\x1b[1"qlineerase\x1b[0"q***' ) ;
2161+ await inputHandler . parseP ( '\x1b[?2K' ) ;
2162+ assert . deepEqual ( getLines ( bufferService , 2 ) , [ ' lineerase' , '' ] ) ;
2163+ // normal EL works as before
2164+ await inputHandler . parseP ( '\x1b[2K' ) ;
2165+ assert . deepEqual ( getLines ( bufferService , 2 ) , [ '' , '' ] ) ;
2166+ } ) ;
2167+ it ( 'DECSCA 1 with DECSED' , async ( ) => {
2168+ await inputHandler . parseP ( '###\x1b[1"qdisplayerase\x1b[0"q***' ) ;
2169+ await inputHandler . parseP ( '\x1b[?2J' ) ;
2170+ assert . deepEqual ( getLines ( bufferService , 2 ) , [ ' displayerase' , '' ] ) ;
2171+ // normal ED works as before
2172+ await inputHandler . parseP ( '\x1b[2J' ) ;
2173+ assert . deepEqual ( getLines ( bufferService , 2 ) , [ '' , '' ] ) ;
2174+ } ) ;
2175+ it ( 'DECRQSS reports correct DECSCA state' , async ( ) => {
2176+ const sendStack : string [ ] = [ ] ;
2177+ coreService . onData ( d => sendStack . push ( d ) ) ;
2178+ // DCS $ q " q ST
2179+ await inputHandler . parseP ( '\x1bP$q"q\x1b\\' ) ;
2180+ // default - DECSCA unset (0 or 2)
2181+ assert . deepEqual ( sendStack . pop ( ) , '\x1bP1$r0"q\x1b\\' ) ;
2182+ // DECSCA 1 - protected set
2183+ await inputHandler . parseP ( '###\x1b[1"q' ) ;
2184+ await inputHandler . parseP ( '\x1bP$q"q\x1b\\' ) ;
2185+ assert . deepEqual ( sendStack . pop ( ) , '\x1bP1$r1"q\x1b\\' ) ;
2186+ // DECSCA 2 - protected reset (same as 0)
2187+ await inputHandler . parseP ( '###\x1b[2"q' ) ;
2188+ await inputHandler . parseP ( '\x1bP$q"q\x1b\\' ) ;
2189+ assert . deepEqual ( sendStack . pop ( ) , '\x1bP1$r0"q\x1b\\' ) ; // reported as DECSCA 0
2190+ } ) ;
2191+ } ) ;
21492192 describe ( 'DECRQM' , ( ) => {
21502193 const reportStack : string [ ] = [ ] ;
21512194 beforeEach ( ( ) => {
0 commit comments