@ -10,96 +10,98 @@
using namespace fmt ;
# line 110 "ansi_parser.rl"
# line 115 "ansi_parser.rl"
# line 13 "ansi_parser.cpp"
static const char _foo _actions [ ] = {
static const char _ansi_parser _actions [ ] = {
0 , 1 , 0 , 1 , 3 , 1 , 4 , 1 ,
5 , 1 , 6 , 1 , 7 , 1 , 8 , 1 ,
9 , 1 , 10 , 1 , 14 , 1 , 15 , 2 ,
1 , 11 , 2 , 1 , 12 , 2 , 15 , 5 ,
3 , 1 , 13 , 2
9 , 1 , 10 , 1 , 11 , 1 , 15 , 1 ,
16 , 2 , 1 , 12 , 2 , 1 , 13 , 2 ,
16 , 5 , 3 , 1 , 14 , 2
} ;
static const char _foo _key_offsets [ ] = {
static const char _ansi_parser _key_offsets [ ] = {
0 , 0 , 1 , 2 , 10 , 11 , 13 , 16 ,
19 , 20 , 23 , 2 4 , 25 , 26 , 28 , 31 ,
33 , 36 , 38 , 41 , 42 , 45 , 46 , 47 ,
48 , 4 9 , 50
19 , 20 , 24 , 25 , 26 , 27 , 2 8 , 30 ,
33 , 35 , 38 , 40 , 43 , 44 , 47 , 48 ,
49 , 50 , 51 , 52
} ;
static const int _foo _trans_keys [ ] = {
static const int _ansi_parser _trans_keys [ ] = {
27 , 91 , 49 , 50 , 51 , 52 , 55 , 57 ,
48 , 54 , 109 , 48 , 109 , 34 , 48 , 55 ,
50 , 55 , 109 , 109 , 56 , 57 , 109 , 5 9 ,
50 , 59 , 48 , 57 , 59 , 48 , 57 , 48 ,
57 , 59 , 48 , 57 , 48 , 57 , 109 , 48 ,
57 , 109 , 56 , 57 , 109 , 59 , 50 , 10 9 ,
109 , 27 , 27 , 0
50 , 55 , 109 , 109 , 49 , 56 , 57 , 109 ,
109 , 59 , 50 , 59 , 48 , 57 , 59 , 48 ,
57 , 48 , 57 , 59 , 48 , 57 , 48 , 57 ,
109 , 48 , 57 , 109 , 56 , 57 , 109 , 59 ,
50 , 109 , 109 , 27 , 27 , 0
} ;
static const char _foo _single_lengths [ ] = {
static const char _ansi_parser _single_lengths [ ] = {
0 , 1 , 1 , 6 , 1 , 2 , 3 , 3 ,
1 , 3 , 1 , 1 , 1 , 0 , 1 , 0 ,
1 , 0 , 1 , 1 , 3 , 1 , 1 , 1 ,
1 , 1 , 1
1 , 4 , 1 , 1 , 1 , 1 , 0 , 1 ,
0 , 1 , 0 , 1 , 1 , 3 , 1 , 1 ,
1 , 1 , 1 , 1
} ;
static const char _foo _range_lengths [ ] = {
static const char _ansi_parser _range_lengths [ ] = {
0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 ,
1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0
0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 ,
1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0
} ;
static const char _foo _index_offsets [ ] = {
static const char _ansi_parser _index_offsets [ ] = {
0 , 0 , 2 , 4 , 12 , 14 , 17 , 21 ,
25 , 27 , 31 , 33 , 35 , 37 , 39 , 42 ,
44 , 47 , 49 , 52 , 54 , 58 , 60 , 62 ,
64 , 66 , 68
25 , 27 , 32 , 34 , 36 , 38 , 40 , 42 ,
45 , 47 , 50 , 52 , 55 , 57 , 61 , 63 ,
65 , 67 , 69 , 71
} ;
static const char _foo_trans_targs [ ] = {
2 , 1 , 3 , 0 , 5 , 7 , 9 , 20 ,
24 , 6 , 4 , 0 , 26 , 0 , 6 , 26 ,
0 , 4 , 4 , 4 , 0 , 4 , 8 , 26 ,
0 , 26 , 0 , 10 , 19 , 26 , 0 , 11 ,
0 , 12 , 0 , 13 , 0 , 14 , 0 , 15 ,
14 , 0 , 16 , 0 , 17 , 16 , 0 , 18 ,
0 , 26 , 18 , 0 , 26 , 0 , 21 , 23 ,
26 , 0 , 22 , 0 , 12 , 0 , 26 , 0 ,
26 , 0 , 2 , 1 , 2 , 1 , 0
static const char _ansi_parser_trans_targs [ ] = {
2 , 1 , 3 , 0 , 5 , 7 , 9 , 21 ,
25 , 6 , 4 , 0 , 27 , 0 , 6 , 27 ,
0 , 4 , 4 , 4 , 0 , 4 , 8 , 27 ,
0 , 27 , 0 , 10 , 11 , 20 , 27 , 0 ,
27 , 0 , 12 , 0 , 13 , 0 , 14 , 0 ,
15 , 0 , 16 , 15 , 0 , 17 , 0 , 18 ,
17 , 0 , 19 , 0 , 27 , 19 , 0 , 27 ,
0 , 22 , 24 , 27 , 0 , 23 , 0 , 13 ,
0 , 27 , 0 , 27 , 0 , 2 , 1 , 2 ,
1 , 0
} ;
static const char _foo _trans_actions [ ] = {
0 , 7 , 0 , 0 , 19 , 19 , 19 , 19 ,
19 , 19 , 19 , 0 , 0 , 0 , 0 , 0 ,
static const char _ansi_parser _trans_actions [ ] = {
0 , 7 , 0 , 0 , 2 1, 2 1, 2 1, 2 1,
2 1, 2 1, 2 1, 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 17 ,
0 , 15 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 3 , 0 , 0 , 0 , 1 , 0 , 23 ,
0 , 0 , 1 , 0 , 26 , 0 , 0 , 1 ,
0 , 32 , 0 , 0 , 9 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 5 , 0 , 11 , 0 ,
13 , 0 , 0 , 7 , 21 , 29 , 0
19 , 0 , 0 , 0 , 3 , 0 , 0 , 0 ,
1 , 0 , 25 , 0 , 0 , 1 , 0 , 28 ,
0 , 0 , 1 , 0 , 34 , 0 , 0 , 9 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 5 ,
0 , 11 , 0 , 13 , 0 , 0 , 7 , 23 ,
31 , 0
} ;
static const char _foo _eof_actions [ ] = {
static const char _ansi_parser _eof_actions [ ] = {
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 , 21
0 , 0 , 0 , 23
} ;
static const int foo_start = 25 ;
static const int foo_first_final = 25 ;
static const int foo _error = 0 ;
static const int ansi_parser_start = 26 ;
static const int ansi_parser_first_final = 26 ;
static const int ansi_parser _error = 0 ;
static const int foo_en_main = 25 ;
static const int ansi_parser_en_main = 26 ;
# line 113 "ansi_parser.rl"
# line 118 "ansi_parser.rl"
# include <ftxui/screen/terminal.hpp>
@ -125,14 +127,14 @@ bool ANSIParser::parse(std::wstring_view codes, ColorCB color_cb, WriteCB write_
sf : : Color & target = color ;
# line 120 "ansi_parser.cpp"
# line 122 "ansi_parser.cpp"
{
cs = foo _start;
cs = ansi_parser _start;
}
# line 138 "ansi_parser.rl"
# line 14 3 "ansi_parser.rl"
# line 123 "ansi_parser.cpp"
# line 125 "ansi_parser.cpp"
{
int _klen ;
unsigned int _trans ;
@ -145,10 +147,10 @@ bool ANSIParser::parse(std::wstring_view codes, ColorCB color_cb, WriteCB write_
if ( cs = = 0 )
goto _out ;
_resume :
_keys = _foo_trans_keys + _foo _key_offsets [ cs ] ;
_trans = _foo _index_offsets [ cs ] ;
_keys = _ansi_parser_trans_keys + _ansi_parser _key_offsets [ cs ] ;
_trans = _ansi_parser _index_offsets [ cs ] ;
_klen = _foo _single_lengths [ cs ] ;
_klen = _ansi_parser _single_lengths [ cs ] ;
if ( _klen > 0 ) {
const int * _lower = _keys ;
const int * _mid ;
@ -171,7 +173,7 @@ _resume:
_trans + = _klen ;
}
_klen = _foo _range_lengths [ cs ] ;
_klen = _ansi_parser _range_lengths [ cs ] ;
if ( _klen > 0 ) {
const int * _lower = _keys ;
const int * _mid ;
@ -194,12 +196,12 @@ _resume:
}
_match :
cs = _foo _trans_targs [ _trans ] ;
cs = _ansi_parser _trans_targs [ _trans ] ;
if ( _foo _trans_actions [ _trans ] = = 0 )
if ( _ansi_parser _trans_actions [ _trans ] = = 0 )
goto _again ;
_acts = _foo_actions + _foo _trans_actions [ _trans ] ;
_acts = _ansi_parser_actions + _ansi_parser _trans_actions [ _trans ] ;
_nacts = ( unsigned int ) * _acts + + ;
while ( _nacts - - > 0 )
{
@ -291,26 +293,33 @@ _match:
}
break ;
case 11 :
# line 71 "ansi_parser.rl"
{ target . r = value ; }
# line 70 "ansi_parser.rl"
{
color = sf : : Color : : Red ;
color_cb ( color , bgcolor ) ;
}
break ;
case 12 :
# line 72 "ansi_parser.rl"
{ target . g = value ; }
# line 75 "ansi_parser.rl"
{ target . r = value ; }
break ;
case 13 :
# line 73 "ansi_parser.rl"
{ target . b = value ; }
# line 76 "ansi_parser.rl"
{ target . g = value ; }
break ;
case 14 :
# line 74 "ansi_parser.rl"
{ value = 0 ; }
# line 77 "ansi_parser.rl"
{ target . b = value ; }
break ;
case 15 :
# line 75 "ansi_parser.rl"
# line 78 "ansi_parser.rl"
{ value = 0 ; }
break ;
case 16 :
# line 79 "ansi_parser.rl"
{ }
break ;
# line 284 "ansi_parser.cpp"
# line 292 "ansi_parser.cpp"
}
}
@ -322,15 +331,15 @@ _again:
_test_eof : { }
if ( p = = eof )
{
const char * __acts = _foo_actions + _foo _eof_actions [ cs ] ;
const char * __acts = _ansi_parser_actions + _ansi_parser _eof_actions [ cs ] ;
unsigned int __nacts = ( unsigned int ) * __acts + + ;
while ( __nacts - - > 0 ) {
switch ( * __acts + + ) {
case 15 :
# line 75 "ansi_parser.rl"
case 16 :
# line 79 "ansi_parser.rl"
{ }
break ;
# line 302 "ansi_parser.cpp"
# line 31 0 "ansi_parser.cpp"
}
}
}
@ -338,16 +347,20 @@ _again:
_out : { }
}
# line 139 "ansi_parser.rl"
# line 144 "ansi_parser.rl"
bool good = p - pe = = 0 ;
bool good = pe - p = = 0 ;
if ( ! good ) {
println ( " FAIL AT {} " , p - pe ) ;
println ( " FAIL AT {} " , pe - p ) ;
p - = 10 ;
// dear cthuhlu, save me from the pain that is wstring
for ( int i = 0 ; i < 100 ; i + + ) {
print ( " {} " , char ( p [ i ] ) ) ;
try {
print ( " {} " , p [ i ] = = 0x1B ? ' ^ ' : char ( p [ i ] ) ) ;
} catch ( . . . ) {
print ( " ?= " , int ( p [ i ] ) ) ;
}
}
}