console control
This commit is contained in:
@@ -7,71 +7,27 @@
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include <format>
|
||||
|
||||
namespace Mutil::Console::Sequences {
|
||||
const char ESC = 0x1b;
|
||||
const char CSI = 0x9b;
|
||||
const char DCS = 0x90;
|
||||
const char OSC = 0x9d;
|
||||
}
|
||||
#include <initializer_list>
|
||||
|
||||
namespace Mutil::Console::General {
|
||||
const char BEL = 0x07;
|
||||
const char BS = 0x08;
|
||||
const char HT = 0x09;
|
||||
const char LF = 0x0A;
|
||||
const char VT = 0x0B;
|
||||
const char FF = 0x0C;
|
||||
const char CR = 0x0D;
|
||||
using Mutil::Console::Sequences::ESC;
|
||||
const char DEL = 0x7f;
|
||||
}
|
||||
|
||||
namespace Mutil::Console::Cursor {
|
||||
class Movement {
|
||||
public:
|
||||
void Home() {};
|
||||
void LnCol(uint64_t line, uint64_t column) {};
|
||||
void Up(uint64_t lines) {};
|
||||
void Down(uint64_t lines) {};
|
||||
void Right(uint64_t columns) {};
|
||||
void Left(uint64_t columns) {};
|
||||
void NextLn(uint64_t lines) {};
|
||||
void PrevLn(uint64_t lines) {};
|
||||
void JmpCol(uint64_t column) {};
|
||||
std::pair<uint64_t, uint64_t> Pos() {};
|
||||
void Save() {};
|
||||
void Restore() {};
|
||||
enum class Codes : char {
|
||||
BEL = 0x07,
|
||||
BS,
|
||||
HT,
|
||||
LF,
|
||||
VT,
|
||||
FF,
|
||||
CR,
|
||||
ESC = 0x1b,
|
||||
DEL = 0x7f,
|
||||
};
|
||||
}
|
||||
|
||||
namespace Mutil::Console::Erase {
|
||||
|
||||
}
|
||||
|
||||
namespace Mutil::Console::Graphics {
|
||||
/*class Format {
|
||||
void Reset() {};
|
||||
void Bold() {};
|
||||
void ResetBold() {};
|
||||
void Dim() {};
|
||||
void ResetDim() {};
|
||||
void Italic() {};
|
||||
void ResetItalic() {};
|
||||
void Underline() {};
|
||||
void ResetUnderline() {};
|
||||
void Blink() {};
|
||||
void ResetBlink() {};
|
||||
void Inverse() {};
|
||||
void ResetInverse() {};
|
||||
void Hidden() {};
|
||||
void ResetHidden() {};
|
||||
void Strikethrough() {};
|
||||
void ResetStrikethrough() {};
|
||||
};*/
|
||||
typedef uint8_t SGARG;
|
||||
|
||||
// Text styling
|
||||
enum class TextStyle : uint8_t {
|
||||
enum class TextStyle : SGARG {
|
||||
Reset = 0,
|
||||
Bold,
|
||||
Dim,
|
||||
@@ -89,10 +45,14 @@ namespace Mutil::Console::Graphics {
|
||||
ResetInverse = 27,
|
||||
ResetHidden,
|
||||
ResetStrikethrough,
|
||||
SetForegroundColor = 38,
|
||||
DefaultForegroundColor = 39,
|
||||
SetBackgroundColor = 48,
|
||||
DefaultBackgroundColor = 49,
|
||||
};
|
||||
|
||||
// Color 16
|
||||
enum class Color16 : uint8_t {
|
||||
enum class Color16 : SGARG {
|
||||
Black = 30,
|
||||
Red,
|
||||
Green,
|
||||
@@ -101,8 +61,7 @@ namespace Mutil::Console::Graphics {
|
||||
Magenta,
|
||||
Cyan,
|
||||
White,
|
||||
Default = 39,
|
||||
BlackBG,
|
||||
BlackBG = 40,
|
||||
RedBG,
|
||||
GreenBG,
|
||||
YellowBG,
|
||||
@@ -110,8 +69,46 @@ namespace Mutil::Console::Graphics {
|
||||
MagentaBG,
|
||||
CyanBG,
|
||||
WhiteBG,
|
||||
DefaultBG = 49,
|
||||
};
|
||||
|
||||
enum class ColorFormats : SGARG {
|
||||
ColorRGB = 2,
|
||||
Color256 = 5,
|
||||
};
|
||||
}
|
||||
|
||||
namespace Mutil::Console::Functions {
|
||||
void CursorUp(uint 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) {};
|
||||
void RequestCursorPosition() {};
|
||||
void EraseInDisplay(uint n) {};
|
||||
void EraseInLine(uint n) {};
|
||||
void ScrollUp(uint n) {};
|
||||
void ScrollDown(uint n) {};
|
||||
void SaveCursorPosition() {};
|
||||
void RestoreCursorPosition() {};
|
||||
void SelectGraphicsRendition(std::initializer_list<Mutil::Console::Graphics::SGARG> args) {
|
||||
if (empty(args)) { return; };
|
||||
|
||||
std::stringstream s;
|
||||
s << (char)Mutil::Console::General::Codes::ESC << '[';
|
||||
|
||||
for (Mutil::Console::Graphics::SGARG a : args) {
|
||||
//std::cout << (uint16_t)a << std::endl;
|
||||
if (a == *std::prev(args.end())) {
|
||||
s << (uint16_t)a;
|
||||
break;
|
||||
}
|
||||
s << (uint16_t)a << ';';
|
||||
}
|
||||
s << 'm';
|
||||
|
||||
std::cout << s.str();
|
||||
};
|
||||
}
|
12
main.cpp
12
main.cpp
@@ -1,5 +1,6 @@
|
||||
#include <Logging.hpp>
|
||||
#include <Desktop.hpp>
|
||||
#include <Console.hpp>
|
||||
|
||||
int main() {
|
||||
Mutil::Logging::LoggerObj lo;
|
||||
@@ -12,7 +13,14 @@ int main() {
|
||||
E("Something...");
|
||||
V("Something...");
|
||||
D("Something...");
|
||||
std::cout << (char)0x1b << (char)0x5b << "33m" << "BULLOCKS" << '\n';
|
||||
//std::cout << 0x1b5b << "33m" << "BALLS" << '\n';
|
||||
//std::cout << (char)0x1b << (char)0x5b << "33m" << "BULLOCKS" << '\n';
|
||||
Mutil::Console::Functions::SelectGraphicsRendition({
|
||||
(uint8_t)Mutil::Console::Graphics::TextStyle::Underline,
|
||||
(uint8_t)Mutil::Console::Graphics::TextStyle::SetForegroundColor,
|
||||
(uint8_t)Mutil::Console::Graphics::ColorFormats::ColorRGB, 252, 186, 3,
|
||||
});
|
||||
std::cout << uint16_t(69) << std::endl;
|
||||
Mutil::Console::Functions::SelectGraphicsRendition({(uint8_t)Mutil::Console::Graphics::TextStyle::Reset});
|
||||
std::cout << uint16_t(70) << std::endl;
|
||||
Desktop::Browser::OpenURL("https://git.redacted.cc/maxine/mutil");
|
||||
}
|
||||
|
Reference in New Issue
Block a user