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