|
|
@ -1,5 +1,5 @@ |
|
|
|
|
|
|
|
|
|
|
|
#line 1 ".\\ansi_parser.rl" |
|
|
|
#line 1 "ansi_parser.rl" |
|
|
|
#include <fmt/core.h> |
|
|
|
#include <fmt/core.h> |
|
|
|
#include <string_view> |
|
|
|
#include <string_view> |
|
|
|
#include <charconv> |
|
|
|
#include <charconv> |
|
|
@ -10,11 +10,11 @@ |
|
|
|
using namespace fmt; |
|
|
|
using namespace fmt; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#line 77 ".\\ansi_parser.rl" |
|
|
|
#line 81 "ansi_parser.rl" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#line 13 ".\\ansi_parser.cpp" |
|
|
|
#line 13 "ansi_parser.cpp" |
|
|
|
static const char _foo_actions[] = { |
|
|
|
static const char _foo_actions[] = { |
|
|
|
0, 1, 0, 1, 3, 1, 4, 1,
|
|
|
|
0, 1, 0, 1, 3, 1, 4, 1,
|
|
|
|
5, 1, 6, 1, 7, 1, 11, 1,
|
|
|
|
5, 1, 6, 1, 7, 1, 11, 1,
|
|
|
@ -85,7 +85,7 @@ static const int foo_error = 0; |
|
|
|
static const int foo_en_main = 19; |
|
|
|
static const int foo_en_main = 19; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#line 80 ".\\ansi_parser.rl" |
|
|
|
#line 84 "ansi_parser.rl" |
|
|
|
|
|
|
|
|
|
|
|
bool parse_ansi(std::wstring_view codes, sf::Color default_fg, sf::Color default_bg, WriteCB write) { |
|
|
|
bool parse_ansi(std::wstring_view codes, sf::Color default_fg, sf::Color default_bg, WriteCB write) { |
|
|
|
const wchar_t *start = NULL; |
|
|
|
const wchar_t *start = NULL; |
|
|
@ -96,17 +96,17 @@ bool parse_ansi(std::wstring_view codes, sf::Color default_fg, sf::Color default |
|
|
|
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 = bgcolor; |
|
|
|
sf::Color &target = color; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#line 94 ".\\ansi_parser.cpp" |
|
|
|
#line 94 "ansi_parser.cpp" |
|
|
|
{ |
|
|
|
{ |
|
|
|
cs = foo_start; |
|
|
|
cs = foo_start; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#line 93 ".\\ansi_parser.rl" |
|
|
|
#line 97 "ansi_parser.rl" |
|
|
|
|
|
|
|
|
|
|
|
#line 97 ".\\ansi_parser.cpp" |
|
|
|
#line 97 "ansi_parser.cpp" |
|
|
|
{ |
|
|
|
{ |
|
|
|
int _klen; |
|
|
|
int _klen; |
|
|
|
unsigned int _trans; |
|
|
|
unsigned int _trans; |
|
|
@ -180,13 +180,13 @@ _match: |
|
|
|
switch ( *_acts++ ) |
|
|
|
switch ( *_acts++ ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
case 0: |
|
|
|
#line 14 ".\\ansi_parser.rl" |
|
|
|
#line 14 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
start = p; |
|
|
|
start = p; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
#line 18 ".\\ansi_parser.rl" |
|
|
|
#line 18 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
value = 0; |
|
|
|
value = 0; |
|
|
|
size_t len = p - start; |
|
|
|
size_t len = p - start; |
|
|
@ -210,52 +210,56 @@ _match: |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
#line 40 ".\\ansi_parser.rl" |
|
|
|
#line 40 "ansi_parser.rl" |
|
|
|
{ } |
|
|
|
{ } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
#line 41 ".\\ansi_parser.rl" |
|
|
|
#line 41 "ansi_parser.rl" |
|
|
|
{ target = color; } |
|
|
|
{ |
|
|
|
|
|
|
|
target = color; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
case 4: |
|
|
|
#line 42 ".\\ansi_parser.rl" |
|
|
|
#line 44 "ansi_parser.rl" |
|
|
|
{ target = bgcolor; } |
|
|
|
{ |
|
|
|
|
|
|
|
target = bgcolor; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
case 5: |
|
|
|
#line 44 ".\\ansi_parser.rl" |
|
|
|
#line 48 "ansi_parser.rl" |
|
|
|
{ |
|
|
|
{ |
|
|
|
write(bgcolor, color, (*p)); |
|
|
|
write(bgcolor, color, (*p)); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
case 6: |
|
|
|
#line 48 ".\\ansi_parser.rl" |
|
|
|
#line 52 "ansi_parser.rl" |
|
|
|
{ color = default_fg; } |
|
|
|
{ color = default_fg; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 7: |
|
|
|
case 7: |
|
|
|
#line 49 ".\\ansi_parser.rl" |
|
|
|
#line 53 "ansi_parser.rl" |
|
|
|
{ bgcolor = default_bg; } |
|
|
|
{ bgcolor = default_bg; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 8: |
|
|
|
case 8: |
|
|
|
#line 51 ".\\ansi_parser.rl" |
|
|
|
#line 55 "ansi_parser.rl" |
|
|
|
{ target.r = value; } |
|
|
|
{ target.r = value; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 9: |
|
|
|
case 9: |
|
|
|
#line 52 ".\\ansi_parser.rl" |
|
|
|
#line 56 "ansi_parser.rl" |
|
|
|
{ target.g = value; } |
|
|
|
{ target.g = value; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 10: |
|
|
|
case 10: |
|
|
|
#line 53 ".\\ansi_parser.rl" |
|
|
|
#line 57 "ansi_parser.rl" |
|
|
|
{ target.b = value; } |
|
|
|
{ target.b = value; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 11: |
|
|
|
case 11: |
|
|
|
#line 54 ".\\ansi_parser.rl" |
|
|
|
#line 58 "ansi_parser.rl" |
|
|
|
{ value = 0; } |
|
|
|
{ value = 0; } |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 12: |
|
|
|
case 12: |
|
|
|
#line 55 ".\\ansi_parser.rl" |
|
|
|
#line 59 "ansi_parser.rl" |
|
|
|
{ } |
|
|
|
{ } |
|
|
|
break; |
|
|
|
break; |
|
|
|
#line 232 ".\\ansi_parser.cpp" |
|
|
|
#line 236 "ansi_parser.cpp" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -272,10 +276,10 @@ _again: |
|
|
|
while ( __nacts-- > 0 ) { |
|
|
|
while ( __nacts-- > 0 ) { |
|
|
|
switch ( *__acts++ ) { |
|
|
|
switch ( *__acts++ ) { |
|
|
|
case 12: |
|
|
|
case 12: |
|
|
|
#line 55 ".\\ansi_parser.rl" |
|
|
|
#line 59 "ansi_parser.rl" |
|
|
|
{ } |
|
|
|
{ } |
|
|
|
break; |
|
|
|
break; |
|
|
|
#line 250 ".\\ansi_parser.cpp" |
|
|
|
#line 254 "ansi_parser.cpp" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -283,7 +287,7 @@ _again: |
|
|
|
_out: {} |
|
|
|
_out: {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#line 94 ".\\ansi_parser.rl" |
|
|
|
#line 98 "ansi_parser.rl" |
|
|
|
|
|
|
|
|
|
|
|
return p - pe == 0; |
|
|
|
return p - pe == 0; |
|
|
|
} |
|
|
|
} |
|
|
|