Display, tinkering with console stuff in general
This commit is contained in:
@@ -31,23 +31,23 @@ namespace Mutil::Console::Graphics {
|
||||
const uint64_t RItalic = 1<<2;
|
||||
const uint64_t RUnderline = 1<<3;
|
||||
const uint64_t RBlink = 1<<4;
|
||||
const uint64_t RInverse = 1<<4;
|
||||
const uint64_t RHidden = 1<<5;
|
||||
const uint64_t RStrikethrough = 1<<6;
|
||||
const uint64_t RResetBold = 1<<7;
|
||||
const uint64_t RResetDim = 1<<8;
|
||||
const uint64_t RResetItalic = 1<<9;
|
||||
const uint64_t RResetUnderline = 1<<10;
|
||||
const uint64_t RResetBlink = 1<<11;
|
||||
const uint64_t RResetInverse = 1<<12;
|
||||
const uint64_t RResetHidden = 1<<13;
|
||||
const uint64_t RResetStrikethrough = 1<<14;
|
||||
const uint64_t RColor16 = 1<<15;
|
||||
const uint64_t RColor256 = 1<<16;
|
||||
const uint64_t RColorRGB = 1<<17;
|
||||
const uint64_t RForegroundColor = 1<<18;
|
||||
const uint64_t RBackgroundColor = 1<<19;
|
||||
const uint64_t RDefaultColor = 1<<20;
|
||||
const uint64_t RInverse = 1<<5;
|
||||
const uint64_t RHidden = 1<<6;
|
||||
const uint64_t RStrikethrough = 1<<7;
|
||||
const uint64_t RResetBold = 1<<8;
|
||||
const uint64_t RResetDim = 1<<9;
|
||||
const uint64_t RResetItalic = 1<<10;
|
||||
const uint64_t RResetUnderline = 1<<11;
|
||||
const uint64_t RResetBlink = 1<<12;
|
||||
const uint64_t RResetInverse = 1<<13;
|
||||
const uint64_t RResetHidden = 1<<14;
|
||||
const uint64_t RResetStrikethrough = 1<<15;
|
||||
const uint64_t RColor16 = 1<<16;
|
||||
const uint64_t RColor256 = 1<<17;
|
||||
const uint64_t RColorRGB = 1<<18;
|
||||
const uint64_t RForegroundColor = 1<<19;
|
||||
const uint64_t RBackgroundColor = 1<<20;
|
||||
const uint64_t RDefaultColor = 1<<21;
|
||||
|
||||
class Rendition {
|
||||
uint64_t flags = 0;
|
||||
@@ -167,14 +167,55 @@ namespace Mutil::Console::Graphics {
|
||||
}
|
||||
|
||||
namespace Mutil::Console::Functions {
|
||||
void CursorUp(uint n) {};
|
||||
void call(std::ostream &os, const std::string& arg, const char& func) {
|
||||
std::ostringstream s;
|
||||
s << General::Codes::ESC << '[' << arg << func;
|
||||
os << s.str();
|
||||
}
|
||||
|
||||
class Display {
|
||||
std::ostream &os = std::cout;
|
||||
public:
|
||||
Display() {};
|
||||
Display(std::ostream &os) : os(os) {};
|
||||
void A(uint n = 1) { call(os, std::to_string(n), 'A'); };
|
||||
void B(uint n = 1) { call(os, std::to_string(n), 'B'); };
|
||||
void C(uint n = 1) { call(os, std::to_string(n), 'C'); };
|
||||
void D(uint n = 1) { call(os, std::to_string(n), 'D'); };
|
||||
void E(uint n = 1) { call(os, std::to_string(n), 'E'); };
|
||||
void F(uint n = 1) { call(os, std::to_string(n), 'F'); };
|
||||
void G(uint n = 1) { call(os, std::to_string(n), 'G'); };
|
||||
void H(uint n = 0, uint m = 0) { call(os, std::format("{};{}",n,m), 'H'); };
|
||||
void J(uint n = 0) { call(os, std::to_string(n), 'J'); };
|
||||
void K(uint n = 0) { call(os, std::to_string(n), 'K'); };
|
||||
void S(uint n = 1) { call(os, std::to_string(n), 'S'); };
|
||||
void T(uint n = 1) { call(os, std::to_string(n), 'T'); };
|
||||
void s() { os << General::Codes::ESC << "7"; };
|
||||
void u() { os << General::Codes::ESC << "8"; };
|
||||
void m(Graphics::Rendition r) { os << r.Compile(); };
|
||||
//Display& Write(const char* in) {
|
||||
// os << in;
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
template<typename In>
|
||||
friend std::ostream& operator<<(Display& d, In in);
|
||||
};
|
||||
|
||||
template<typename In>
|
||||
std::ostream& operator<<(Display& d, In in) {
|
||||
return d.os << in;
|
||||
}
|
||||
|
||||
|
||||
std::string CursorUp(uint n) { return std::format("{}[{}A", "\x1b[", n); };
|
||||
void CursorDown(uint n) {};
|
||||
void CursorForward(uint n) {};
|
||||
void CursorBack(uint n) {};
|
||||
void CursorNextLine(uint n) {};
|
||||
void CursorPreviousLine(uint n) {};
|
||||
void CursorHorizontalAbsolute(uint n) {};
|
||||
void CursorPosition(uint n, uint m) {};
|
||||
std::string CursorPosition(uint n, uint m) { return std::format("\x1b[{};{}H", n, m); };
|
||||
void RequestCursorPosition() {};
|
||||
void EraseInDisplay(uint n) {};
|
||||
void EraseInLine(uint n) {};
|
||||
|
@@ -38,12 +38,20 @@ namespace Mutil::Logging {
|
||||
os << std::endl;
|
||||
};
|
||||
/// Send log messages using logger as a stream
|
||||
//template<typename In>
|
||||
//LoggerObj& operator<<(In message) {
|
||||
// λMessage ? os << λMessage(message) : os << message;
|
||||
// os << std::endl;
|
||||
// return *this;
|
||||
//};
|
||||
|
||||
template<typename In>
|
||||
LoggerObj& operator<<(In message) {
|
||||
λMessage ? os << λMessage(message) : os << message;
|
||||
os << std::endl;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
47
main.cpp
47
main.cpp
@@ -40,6 +40,53 @@ int main() {
|
||||
Mutil::Console::Graphics::String s("balls");
|
||||
std::cout << s.Render({Mutil::Console::Graphics::RItalic}) << std::endl;
|
||||
|
||||
//d << Mutil::Console::Functions::CursorUp(6);
|
||||
//d.Trace();
|
||||
|
||||
//std::cout << "\x1b[2J" << Mutil::Console::Functions::CursorPosition(1, 3) << "AAAAAAAAAAAAAAAAA" << std::endl;
|
||||
|
||||
//std::cout << "\x1b[2J";
|
||||
//std::cout << Mutil::Console::Functions::CursorPosition(1, 39
|
||||
//) << "AAAAAAAA";
|
||||
//std::cout << Mutil::Console::Functions::CursorPosition(2, 35) << "AAAA";
|
||||
//std::cout << Mutil::Console::Functions::CursorPosition(3, 31) << "AAAA";
|
||||
// std::cout << Mutil::Console::Functions::CursorPosition(4, 29) << "AA";
|
||||
// std::cout << std::endl;
|
||||
|
||||
Mutil::Console::Functions::Display display;
|
||||
display.J(2);
|
||||
display.H();
|
||||
display.m({Mutil::Console::Graphics::RUnderline,70});
|
||||
//const char* womp = "womp womp";
|
||||
//std::cout << womp << std::endl;
|
||||
|
||||
|
||||
display << "ASS" << std::endl;
|
||||
display << "DICK" << "FUCK" << std::endl;
|
||||
display.m({});
|
||||
|
||||
|
||||
//display << "\x1b[?47h";
|
||||
display.H();
|
||||
display.J(2);
|
||||
display.s();
|
||||
display.H(24,80);
|
||||
display.m({Mutil::Console::Graphics::RUnderline, 27});
|
||||
display << "SomethingSomethingAsshole" << std::endl;
|
||||
//display.H(3,3);
|
||||
display.m({});
|
||||
display.u();
|
||||
//display.s();
|
||||
//display.H(24,80);
|
||||
//display << "0" << std::endl;
|
||||
//display.u();
|
||||
//display << "\x1b[?47l";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Desktop::Browser::OpenURL("https://git.redacted.cc/maxine/mutil");
|
||||
|
Reference in New Issue
Block a user