A bit better method of setting foreground vs. background.

This commit is contained in:
Zed A. Shaw 2024-11-01 04:15:37 -04:00
parent 2d550978b8
commit 6ca4614fcb
2 changed files with 15 additions and 15 deletions

View file

@ -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;