Rendering with color is working now but still has problems with enabling/resetting the default colors.

This commit is contained in:
Zed A. Shaw 2024-11-02 06:02:13 -04:00
parent a36b187879
commit e864e14eab
8 changed files with 57 additions and 45 deletions

View file

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