|
|
@ -10,7 +10,7 @@ |
|
|
|
using namespace fmt; |
|
|
|
using namespace fmt; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#line 115 "ansi_parser.rl" |
|
|
|
#line 121 "ansi_parser.rl" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -101,7 +101,7 @@ static const int ansi_parser_error = 0; |
|
|
|
static const int ansi_parser_en_main = 26; |
|
|
|
static const int ansi_parser_en_main = 26; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#line 118 "ansi_parser.rl" |
|
|
|
#line 124 "ansi_parser.rl" |
|
|
|
|
|
|
|
|
|
|
|
#include <ftxui/screen/terminal.hpp> |
|
|
|
#include <ftxui/screen/terminal.hpp> |
|
|
|
|
|
|
|
|
|
|
@ -124,7 +124,7 @@ bool ANSIParser::parse(std::wstring_view codes, ColorCB color_cb, WriteCB write_ |
|
|
|
const wchar_t *eof = pe; |
|
|
|
const wchar_t *eof = pe; |
|
|
|
sf::Color bgcolor($default_bg); |
|
|
|
sf::Color bgcolor($default_bg); |
|
|
|
sf::Color color($default_fg); |
|
|
|
sf::Color color($default_fg); |
|
|
|
sf::Color &target = color; |
|
|
|
sf::Color* target = &color; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#line 122 "ansi_parser.cpp" |
|
|
|
#line 122 "ansi_parser.cpp" |
|
|
@ -132,7 +132,7 @@ bool ANSIParser::parse(std::wstring_view codes, ColorCB color_cb, WriteCB write_ |
|
|
|
cs = ansi_parser_start; |
|
|
|
cs = ansi_parser_start; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#line 143 "ansi_parser.rl" |
|
|
|
#line 149 "ansi_parser.rl" |
|
|
|
|
|
|
|
|
|
|
|
#line 125 "ansi_parser.cpp" |
|
|
|
#line 125 "ansi_parser.cpp" |
|
|
|
{ |
|
|
|
{ |
|
|
@ -246,13 +246,13 @@ _match: |
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
#line 43 "ansi_parser.rl" |
|
|
|
#line 43 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
target = color; |
|
|
|
target = &color; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
case 4: |
|
|
|
#line 46 "ansi_parser.rl" |
|
|
|
#line 46 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
target = bgcolor; |
|
|
|
target = &bgcolor; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
case 5: |
|
|
@ -263,14 +263,20 @@ _match: |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
case 6: |
|
|
|
#line 54 "ansi_parser.rl" |
|
|
|
#line 54 "ansi_parser.rl" |
|
|
|
{ color = $default_fg; } |
|
|
|
{ |
|
|
|
|
|
|
|
color = $default_fg; |
|
|
|
|
|
|
|
color_cb(color, bgcolor); |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 7: |
|
|
|
case 7: |
|
|
|
#line 55 "ansi_parser.rl" |
|
|
|
#line 58 "ansi_parser.rl" |
|
|
|
{ bgcolor = $default_bg; } |
|
|
|
{ |
|
|
|
|
|
|
|
bgcolor = $default_bg; |
|
|
|
|
|
|
|
color_cb(color, bgcolor); |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 8: |
|
|
|
case 8: |
|
|
|
#line 56 "ansi_parser.rl" |
|
|
|
#line 62 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
color = $default_bg; |
|
|
|
color = $default_bg; |
|
|
|
bgcolor = $default_fg; |
|
|
|
bgcolor = $default_fg; |
|
|
@ -278,7 +284,7 @@ _match: |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 9: |
|
|
|
case 9: |
|
|
|
#line 61 "ansi_parser.rl" |
|
|
|
#line 67 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
color = $default_fg; |
|
|
|
color = $default_fg; |
|
|
|
bgcolor = $default_bg; |
|
|
|
bgcolor = $default_bg; |
|
|
@ -286,40 +292,40 @@ _match: |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 10: |
|
|
|
case 10: |
|
|
|
#line 66 "ansi_parser.rl" |
|
|
|
#line 72 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
color = sf::Color(100,100,100); |
|
|
|
color = sf::Color(100,100,100); |
|
|
|
color_cb(color, bgcolor); |
|
|
|
color_cb(color, bgcolor); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 11: |
|
|
|
case 11: |
|
|
|
#line 70 "ansi_parser.rl" |
|
|
|
#line 76 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
color = sf::Color::Red; |
|
|
|
color = sf::Color::Red; |
|
|
|
color_cb(color, bgcolor); |
|
|
|
color_cb(color, bgcolor); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 12: |
|
|
|
case 12: |
|
|
|
#line 75 "ansi_parser.rl" |
|
|
|
#line 81 "ansi_parser.rl" |
|
|
|
{ target.r = value; } |
|
|
|
{ target->r = value; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 13: |
|
|
|
case 13: |
|
|
|
#line 76 "ansi_parser.rl" |
|
|
|
#line 82 "ansi_parser.rl" |
|
|
|
{ target.g = value; } |
|
|
|
{ target->g = value; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 14: |
|
|
|
case 14: |
|
|
|
#line 77 "ansi_parser.rl" |
|
|
|
#line 83 "ansi_parser.rl" |
|
|
|
{ target.b = value; } |
|
|
|
{ target->b = value; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 15: |
|
|
|
case 15: |
|
|
|
#line 78 "ansi_parser.rl" |
|
|
|
#line 84 "ansi_parser.rl" |
|
|
|
{ value = 0; } |
|
|
|
{ value = 0; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 16: |
|
|
|
case 16: |
|
|
|
#line 79 "ansi_parser.rl" |
|
|
|
#line 85 "ansi_parser.rl" |
|
|
|
{} |
|
|
|
{} |
|
|
|
break; |
|
|
|
break; |
|
|
|
#line 292 "ansi_parser.cpp" |
|
|
|
#line 298 "ansi_parser.cpp" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -336,10 +342,10 @@ _again: |
|
|
|
while ( __nacts-- > 0 ) { |
|
|
|
while ( __nacts-- > 0 ) { |
|
|
|
switch ( *__acts++ ) { |
|
|
|
switch ( *__acts++ ) { |
|
|
|
case 16: |
|
|
|
case 16: |
|
|
|
#line 79 "ansi_parser.rl" |
|
|
|
#line 85 "ansi_parser.rl" |
|
|
|
{} |
|
|
|
{} |
|
|
|
break; |
|
|
|
break; |
|
|
|
#line 310 "ansi_parser.cpp" |
|
|
|
#line 316 "ansi_parser.cpp" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -347,12 +353,11 @@ _again: |
|
|
|
_out: {} |
|
|
|
_out: {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#line 144 "ansi_parser.rl" |
|
|
|
#line 150 "ansi_parser.rl" |
|
|
|
|
|
|
|
|
|
|
|
bool good = pe - p == 0; |
|
|
|
bool good = pe - p == 0; |
|
|
|
|
|
|
|
|
|
|
|
if(!good) { |
|
|
|
if(!good) { |
|
|
|
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++) { |
|
|
|