Now have a basic prototype lighting system.

This commit is contained in:
Zed A. Shaw 2024-11-25 02:32:16 -05:00
parent 1bb04b4562
commit a9217e8423
4 changed files with 65 additions and 48 deletions

View file

@ -41,18 +41,24 @@ using namespace fmt;
color_cb(color, bgcolor);
}
action is_fg {
target = color;
target = &color;
}
action is_bg {
target = bgcolor;
target = &bgcolor;
}
action out {
write_cb(fc);
}
action reset_fg { color = $default_fg; }
action reset_bg { bgcolor = $default_bg; }
action reset_fg {
color = $default_fg;
color_cb(color, bgcolor);
}
action reset_bg {
bgcolor = $default_bg;
color_cb(color, bgcolor);
}
action invert {
color = $default_bg;
bgcolor = $default_fg;
@ -72,9 +78,9 @@ using namespace fmt;
color_cb(color, bgcolor);
}
action red { target.r = value; }
action blue { target.g = value; }
action green { target.b = value; }
action red { target->r = value; }
action blue { target->g = value; }
action green { target->b = value; }
action start { value = 0; }
action end {}
action log { println("command {}", (char)fc); }
@ -137,7 +143,7 @@ bool ANSIParser::parse(std::wstring_view codes, ColorCB color_cb, WriteCB write_
const wchar_t *eof = pe;
sf::Color bgcolor($default_bg);
sf::Color color($default_fg);
sf::Color &target = color;
sf::Color* target = &color;
%% write init;
%% write exec;
@ -145,7 +151,6 @@ bool ANSIParser::parse(std::wstring_view codes, ColorCB color_cb, WriteCB write_
bool good = pe - p == 0;
if(!good) {
println("FAIL AT {}", pe - p);
p -= 10;
// dear cthuhlu, save me from the pain that is wstring
for(int i = 0; i < 100; i++) {