Rewrote the ansi parser to exactly callback on color setting, so now just need to clean this all up and fix a few little bugs.

This commit is contained in:
Zed A. Shaw 2024-11-16 12:10:14 -05:00
parent 96ee16e598
commit 89a70f398a
9 changed files with 274 additions and 126 deletions

View file

@ -3,7 +3,9 @@
#include <SFML/Graphics.hpp>
#include <codecvt>
typedef std::function<void(sf::Color bgcolor, sf::Color color, wchar_t ch)> WriteCB;
typedef std::function<void(sf::Color bgcolor, sf::Color color)> ColorCB;
typedef std::function<void(wchar_t ch)> WriteCB;
class ANSIParser {
sf::Color $default_fg;
@ -16,5 +18,5 @@ public:
// disable copying
ANSIParser(ANSIParser& ap) = delete;
bool parse(std::wstring_view codes, WriteCB write);
bool parse(std::wstring_view codes, ColorCB color_cb, WriteCB write_cb);
};