Console graphics string
This commit is contained in:
@@ -65,6 +65,8 @@ namespace Mutil::Console::Graphics {
|
||||
|
||||
this->color = (uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b << 0;
|
||||
}
|
||||
|
||||
|
||||
std::string Compile() {
|
||||
std::ostringstream s;
|
||||
s << Mutil::Console::General::Codes::ESC << '[';
|
||||
@@ -147,6 +149,21 @@ namespace Mutil::Console::Graphics {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class String {
|
||||
std::string str;
|
||||
Rendition rendition;
|
||||
public:
|
||||
String(std::string s) : str(s) {}
|
||||
String(std::string s, Rendition r) : str(s), rendition(r) {};
|
||||
void Style(Rendition r) { rendition = r;};
|
||||
std::string Render() { return rendition.Compile() + str + Rendition(RNormal).Compile(); };
|
||||
std::string Render(Rendition r) {
|
||||
Style(r);
|
||||
return Render();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Mutil::Console::Functions {
|
||||
|
17
main.cpp
17
main.cpp
@@ -6,12 +6,17 @@
|
||||
class Debug : public Mutil::Logging::LoggerObj {
|
||||
static std::string λMessage(std::string m) {
|
||||
return Mutil::Console::Graphics::Rendition(Mutil::Console::Graphics::RItalic, 135).Compile() + std::format("[D] {}", m) + Mutil::Console::Graphics::Rendition().Compile();
|
||||
//return Mutil::Console::Graphics::String(std::format("[D] {}", m), {Mutil::Console::Graphics::RItalic, 135}).Render();
|
||||
};
|
||||
public:
|
||||
Debug() : LoggerObj(std::cout, nullptr, λMessage, nullptr) {};
|
||||
void Trace(const std::source_location &location = std::source_location::current()) {
|
||||
Mutil::Console::Graphics::Rendition r(Mutil::Console::Graphics::RBold, 241);
|
||||
|
||||
this->operator()("{}{} @ {}:{}", r.Compile(), location.function_name(), location.file_name(), location.line());
|
||||
//this->operator()(Mutil::Console::Graphics::String(
|
||||
// std::format("{} @ {}:{}", location.function_name(), location.file_name(), location.line()),
|
||||
// {Mutil::Console::Graphics::RBold, 241}).Render());
|
||||
};
|
||||
};
|
||||
|
||||
@@ -40,6 +45,18 @@ int main() {
|
||||
d << "DEBUGGGGING";
|
||||
d.Trace();
|
||||
|
||||
Mutil::Console::Graphics::Rendition sr(
|
||||
Mutil::Console::Graphics::RStrikethrough |
|
||||
Mutil::Console::Graphics::RUnderline,
|
||||
28);
|
||||
|
||||
Mutil::Console::Graphics::String s("balls");
|
||||
//s.Style({Mutil::Console::Graphics::RBackgroundColor, 69});
|
||||
//s.Style();
|
||||
|
||||
//std::cout << s.Style(sr).Render() << s.Style({Mutil::Console::Graphics::RBackgroundColor, 69}).Render() << std::endl;
|
||||
std::cout << s.Render({Mutil::Console::Graphics::RItalic}) << std::endl;
|
||||
|
||||
|
||||
|
||||
//Desktop::Browser::OpenURL("https://git.redacted.cc/maxine/mutil");
|
||||
|
Reference in New Issue
Block a user