diff --git a/ansi_parser.cpp b/ansi_parser.cpp index 77fd971..9cf9d21 100644 --- a/ansi_parser.cpp +++ b/ansi_parser.cpp @@ -63,10 +63,10 @@ static const char _foo_trans_targs[] = { static const char _foo_trans_actions[] = { 0, 7, 0, 0, 9, 9, 0, 0, - 0, 0, 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 13, 0, 0, 1, 0, 16, 0, 0, 1, 0, 22, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 5, 0, 0, 7, 11, 19, 0 }; @@ -88,11 +88,11 @@ static const int foo_en_main = 18; bool parse_ansi(std::string_view codes) { const char *start = NULL; int cs = 0; - uint8_t value = 0; + unsigned int value = 0; const char *p = codes.data(); const char *pe = p + codes.size(); const char *eof = pe; - bool fgcolor = false; + bool is_fg = false; sf::Color color; @@ -198,11 +198,11 @@ _match: break; case 3: #line 26 ".\\ansi_parser.rl" - { fgcolor = false; } + { is_fg = true; } break; case 4: #line 27 ".\\ansi_parser.rl" - { fgcolor = true; } + { is_fg = false; } break; case 5: #line 29 ".\\ansi_parser.rl" @@ -229,7 +229,7 @@ _match: case 10: #line 39 ".\\ansi_parser.rl" { - println("fg? {}, sf:Color: {},{},{},{}", fgcolor, color.r, color.g, color.b, color.a); + println("fg? {}, sf:Color: {},{},{},{}", is_fg, color.r, color.g, color.b, color.a); } break; #line 211 ".\\ansi_parser.cpp" @@ -251,7 +251,7 @@ _again: case 10: #line 39 ".\\ansi_parser.rl" { - println("fg? {}, sf:Color: {},{},{},{}", fgcolor, color.r, color.g, color.b, color.a); + println("fg? {}, sf:Color: {},{},{},{}", is_fg, color.r, color.g, color.b, color.a); } break; #line 231 ".\\ansi_parser.cpp" diff --git a/ansi_parser.rl b/ansi_parser.rl index 6300f6d..e6a2484 100644 --- a/ansi_parser.rl +++ b/ansi_parser.rl @@ -23,8 +23,8 @@ using namespace fmt; println("color24b"); } - action bg { fgcolor = false; } - action fg { fgcolor = true; } + action is_fg { is_fg = true; } + action is_bg { is_fg = false; } action any { println("ANY: {}:{}", int(fc), fc); @@ -37,12 +37,12 @@ using namespace fmt; action start { value = 0; } action end { - println("fg? {}, sf:Color: {},{},{},{}", fgcolor, color.r, color.g, color.b, color.a); + println("fg? {}, sf:Color: {},{},{},{}", is_fg, color.r, color.g, color.b, color.a); } start = 0x1B "["; - fg = "38;" %fg; - bg = "48;" %bg; + fg = "38;" %is_fg; + bg = "48;" %is_bg; reset = ("39" | "49"); num = digit+ >tstart %number; color256 = "5;"; @@ -66,11 +66,11 @@ using namespace fmt; bool parse_ansi(std::string_view codes) { const char *start = NULL; int cs = 0; - uint8_t value = 0; + unsigned int value = 0; const char *p = codes.data(); const char *pe = p + codes.size(); const char *eof = pe; - bool fgcolor = false; + bool is_fg = false; sf::Color color; %% write init;