183
183
184
184
#include " vtlog.h"
185
185
186
- enum AnsiMouseExpectation
186
+ enum AnsiMouseModes
187
187
{
188
- AMEX_X10_MOUSE = 9 ,
189
- AMEX_VT200_MOUSE = 1000 ,
190
- AMEX_VT200_HIGHLIGHT_MOUSE = 1001 ,
191
- AMEX_BTN_EVENT_MOUSE = 1002 ,
192
- AMEX_ANY_EVENT_MOUSE = 1003 ,
193
- AMEX_SGR_EXT_MOUSE = 1006
188
+ SET_X10_MOUSE = 9 ,
189
+ SET_VT200_MOUSE = 1000 ,
190
+ SET_VT200_HIGHLIGHT_MOUSE = 1001 ,
191
+ SET_BTN_EVENT_MOUSE = 1002 ,
192
+ SET_ANY_EVENT_MOUSE = 1003 ,
193
+ SET_SGR_EXT_MODE_MOUSE = 1006
194
194
};
195
195
196
196
struct VTAnsiState
@@ -207,7 +207,7 @@ struct VTAnsiState
207
207
memset (&csbi, 0 , sizeof (csbi));
208
208
memset (&cci, 0 , sizeof (cci));
209
209
}
210
-
210
+
211
211
void InitFromConsole (HANDLE con)
212
212
{
213
213
WINPORT (GetConsoleScreenBufferInfo)( con, &csbi );
@@ -405,7 +405,7 @@ struct VTAnsiContext
405
405
} while (++b, --chars_in_buffer);
406
406
} else {
407
407
fprintf(stderr, "TODODODODO\n");
408
-
408
+
409
409
410
410
// To detect wrapping of multiple characters, create a new buffer, write
411
411
// to the top of it and see if the cursor changes line. This doesn't
@@ -780,21 +780,21 @@ struct VTAnsiContext
780
780
if (prefix2 == ' ?' && (suffix == ' h' || suffix == ' l' )) {
781
781
for (i = 0 ; i < es_argc; ++i) {
782
782
switch (es_argv[i]) {
783
- case AMEX_X10_MOUSE :
784
- vt_shell->OnMouseExpectation (MEX_X10_MOUSE , suffix == ' h' );
783
+ case SET_X10_MOUSE :
784
+ vt_shell->OnMouseExpectation (MODE_X10_MOUSE , suffix == ' h' );
785
785
break ;
786
- case AMEX_VT200_MOUSE :
787
- case AMEX_VT200_HIGHLIGHT_MOUSE :
788
- vt_shell->OnMouseExpectation (MEX_VT200_MOUSE , suffix == ' h' );
786
+ case SET_VT200_MOUSE :
787
+ case SET_VT200_HIGHLIGHT_MOUSE :
788
+ vt_shell->OnMouseExpectation (MODE_VT200_MOUSE , suffix == ' h' );
789
789
break ;
790
- case AMEX_BTN_EVENT_MOUSE :
791
- vt_shell->OnMouseExpectation (MEX_BTN_EVENT_MOUSE , suffix == ' h' );
790
+ case SET_BTN_EVENT_MOUSE :
791
+ vt_shell->OnMouseExpectation (MODE_BTN_EVENT_MOUSE , suffix == ' h' );
792
792
break ;
793
- case AMEX_ANY_EVENT_MOUSE :
794
- vt_shell->OnMouseExpectation (MEX_ANY_EVENT_MOUSE , suffix == ' h' );
793
+ case SET_ANY_EVENT_MOUSE :
794
+ vt_shell->OnMouseExpectation (MODE_ANY_EVENT_MOUSE , suffix == ' h' );
795
795
break ;
796
- case AMEX_SGR_EXT_MOUSE :
797
- vt_shell->OnMouseExpectation (MEX_SGR_EXT_MOUSE , suffix == ' h' );
796
+ case SET_SGR_EXT_MODE_MOUSE :
797
+ vt_shell->OnMouseExpectation (MODE_SGR_EXT_MOUSE , suffix == ' h' );
798
798
break ;
799
799
800
800
// case 47: case 1047:
@@ -870,7 +870,7 @@ struct VTAnsiContext
870
870
// Ignore any other private sequences.
871
871
if (prefix2 != 0 ) {
872
872
LogFailedEscSeq (StrPrintf (" bad prefix2 %c" , prefix2));
873
- return ;
873
+ return ;
874
874
}
875
875
876
876
WINPORT (GetConsoleScreenBufferInfo)( con_hnd, &Info );
@@ -974,7 +974,7 @@ struct VTAnsiContext
974
974
WINPORT (ScrollConsoleScreenBuffer)( con_hnd, &Rect, &Info.srWindow , Pos, &CharInfo );
975
975
}
976
976
return ;
977
-
977
+
978
978
case ' T' : // ESC[#T Scroll down
979
979
if (es_argc == 0 ) es_argv[es_argc++] = 1 ; // ESC[T == ESC[1T
980
980
if (es_argc != 1 ) return ;
@@ -985,16 +985,16 @@ struct VTAnsiContext
985
985
Rect.Right = Info.srWindow .Right = (Info.dwSize .X - 1 );
986
986
Rect.Top = Info.srWindow .Top ;
987
987
Rect.Bottom = Info.srWindow .Bottom - es_argv[0 ];
988
-
988
+
989
989
Pos.X = 0 ;
990
990
Pos.Y = Rect.Top + es_argv[0 ];
991
991
992
992
CI_SET_WCATTR (CharInfo, blank_character, Info.wAttributes );
993
993
WINPORT (ScrollConsoleScreenBuffer)( con_hnd, &Rect, &Info.srWindow , Pos, &CharInfo );
994
994
}
995
995
return ;
996
-
997
-
996
+
997
+
998
998
case ' M' : // ESC[#M Delete # lines.
999
999
if (es_argc == 0 ) es_argv[es_argc++] = 1 ; // ESC[M == ESC[1M
1000
1000
if (es_argc != 1 ) return ;
@@ -1227,14 +1227,14 @@ struct VTAnsiContext
1227
1227
case ' r' :
1228
1228
if (es_argc < 2 ) {
1229
1229
es_argv[1 ] = MAXSHORT;
1230
- if (es_argc < 1 )
1230
+ if (es_argc < 1 )
1231
1231
es_argv[0 ] = 1 ;
1232
1232
}
1233
- fprintf (stderr, " VTAnsi: SET SCROLL REGION: %d %d (limits %d %d)\n " ,
1233
+ fprintf (stderr, " VTAnsi: SET SCROLL REGION: %d %d (limits %d %d)\n " ,
1234
1234
es_argv[0 ] - 1 , es_argv[1 ] - 1 , Info.srWindow .Top , Info.srWindow .Bottom );
1235
1235
WINPORT (SetConsoleScrollRegion)(con_hnd, es_argv[0 ] - 1 , es_argv[1 ] - 1 );
1236
1236
return ;
1237
-
1237
+
1238
1238
case ' c' : // CSI P s c Send Device Attributes (Primary DA)
1239
1239
if (prefix2 == 0 && (es_argc < 1 || es_argv[0 ] == 0 )) {
1240
1240
SendSequence (" \e[?1;2c" ); // → CSI ? 1 ; 2 c (‘‘VT100 with Advanced Video Option’’)
@@ -1336,32 +1336,32 @@ struct VTAnsiContext
1336
1336
void ForwardIndex ()
1337
1337
{
1338
1338
fprintf (stderr, " ANSI: ForwardIndex\n " );
1339
- FlushBuffer ();
1339
+ FlushBuffer ();
1340
1340
}
1341
1341
1342
1342
void ReverseIndex ()
1343
1343
{
1344
1344
fprintf (stderr, " ANSI: ReverseIndex\n " );
1345
1345
FlushBuffer ();
1346
- HANDLE con_hnd = vt_shell->ConsoleHandle ();
1346
+ HANDLE con_hnd = vt_shell->ConsoleHandle ();
1347
1347
CONSOLE_SCREEN_BUFFER_INFO info;
1348
1348
WINPORT (GetConsoleScreenBufferInfo)( con_hnd, &info );
1349
1349
SHORT scroll_top = 0 , scroll_bottom = 0x7fff ;
1350
1350
WINPORT (GetConsoleScrollRegion)(con_hnd, &scroll_top, &scroll_bottom);
1351
-
1351
+
1352
1352
if (scroll_top < info.srWindow .Top ) scroll_top = info.srWindow .Top ;
1353
1353
if (scroll_bottom < info.srWindow .Top ) scroll_bottom = info.srWindow .Top ;
1354
-
1354
+
1355
1355
if (scroll_top > info.srWindow .Bottom ) scroll_top = info.srWindow .Bottom ;
1356
-
1356
+
1357
1357
if (scroll_bottom > info.srWindow .Bottom ) scroll_bottom = info.srWindow .Bottom ;
1358
-
1359
- if (info.dwCursorPosition .Y != scroll_top) {
1358
+
1359
+ if (info.dwCursorPosition .Y != scroll_top) {
1360
1360
info.dwCursorPosition .Y --;
1361
1361
WINPORT (SetConsoleCursorPosition)(con_hnd, info.dwCursorPosition );
1362
1362
return ;
1363
1363
}
1364
-
1364
+
1365
1365
if (scroll_top>=scroll_bottom)
1366
1366
return ;
1367
1367
@@ -1547,8 +1547,8 @@ struct VTAnsiContext
1547
1547
}
1548
1548
1549
1549
if (done) {
1550
- if (state == 6 )
1551
- InterpretControlString ();
1550
+ if (state == 6 )
1551
+ InterpretControlString ();
1552
1552
else
1553
1553
InterpretEscSeq ();
1554
1554
state = 1 ;
@@ -1595,7 +1595,7 @@ struct VTAnsiContext
1595
1595
VTAnsiContext ()
1596
1596
: alternative_screen_buffer(*this )
1597
1597
{
1598
- }
1598
+ }
1599
1599
};
1600
1600
1601
1601
@@ -1606,9 +1606,9 @@ VTAnsi::VTAnsi(IVTShell *vtsh)
1606
1606
_ctx->ResetTerminal ();
1607
1607
_ctx->saved_state .InitFromConsole (_ctx->vt_shell ->ConsoleHandle ());
1608
1608
_ctx->ansi_state .font_state .FromConsoleAttributes (_ctx->saved_state .csbi .wAttributes );
1609
-
1609
+
1610
1610
VTLog::Start ();
1611
-
1611
+
1612
1612
// get_state();
1613
1613
}
1614
1614
0 commit comments