module; export module Core.Terminal; export import Core.Vector; #define ESC "\33[" export namespace Core { namespace Terminal { inline constexpr const char RESET[] = ESC "0m"; inline constexpr const char BOLD[] = ESC "1m"; // foreground colors inline constexpr const char FG_BLACK[] = ESC "30m"; inline constexpr const char FG_RED[] = ESC "31m"; inline constexpr const char FG_GREEN[] = ESC "32m"; inline constexpr const char FG_YELLOW[] = ESC "33m"; inline constexpr const char FG_BLUE[] = ESC "34m"; inline constexpr const char FG_MAGENTA[] = ESC "35m"; inline constexpr const char FG_CYAN[] = ESC "36m"; inline constexpr const char FG_WHITE[] = ESC "37m"; inline constexpr const char FG_BRIGHT_BLACK[] = ESC "90m"; inline constexpr const char FG_BRIGHT_RED[] = ESC "91m"; inline constexpr const char FG_BRIGHT_GREEN[] = ESC "92m"; inline constexpr const char FG_BRIGHT_YELLOW[] = ESC "93m"; inline constexpr const char FG_BRIGHT_BLUE[] = ESC "94m"; inline constexpr const char FG_BRIGHT_MAGENTA[] = ESC "95m"; inline constexpr const char FG_BRIGHT_CYAN[] = ESC "96m"; inline constexpr const char FG_BRIGHT_WHITE[] = ESC "97m"; // background colors inline constexpr const char BG_BLACK[] = ESC "40m"; inline constexpr const char BG_RED[] = ESC "41m"; inline constexpr const char BG_GREEN[] = ESC "42m"; inline constexpr const char BG_YELLOW[] = ESC "43m"; inline constexpr const char BG_BLUE[] = ESC "44m"; inline constexpr const char BG_MAGENTA[] = ESC "45m"; inline constexpr const char BG_CYAN[] = ESC "46m"; inline constexpr const char BG_WHITE[] = ESC "47m"; inline constexpr const char BG_BRIGHT_BLACK[] = ESC "100m"; inline constexpr const char BG_BRIGHT_RED[] = ESC "101m"; inline constexpr const char BG_BRIGHT_GREEN[] = ESC "102m"; inline constexpr const char BG_BRIGHT_YELLOW[] = ESC "103m"; inline constexpr const char BG_BRIGHT_BLUE[] = ESC "104m"; inline constexpr const char BG_BRIGHT_MAGENTA[] = ESC "105m"; inline constexpr const char BG_BRIGHT_CYAN[] = ESC "106m"; inline constexpr const char BG_BRIGHT_WHITE[] = ESC "107m"; // keycodes inline constexpr const unsigned long KEY_UNKNOWN = 0x1'0000'0000lu; // default keycodes inline constexpr const unsigned long KEY_ARROW_LEFT = 0x1'0000'0001lu; inline constexpr const unsigned long KEY_ARROW_RIGHT = 0x1'0000'0002lu; inline constexpr const unsigned long KEY_ARROW_UP = 0x1'0000'0003lu; inline constexpr const unsigned long KEY_ARROW_DOWN = 0x1'0000'0004lu; inline constexpr const unsigned long KEY_DELETE = 0x1'0000'0005lu; inline constexpr const unsigned long KEY_F1 = 0x1'0000'0006lu; inline constexpr const unsigned long KEY_F2 = 0x1'0000'0007lu; inline constexpr const unsigned long KEY_F3 = 0x1'0000'0008lu; inline constexpr const unsigned long KEY_F4 = 0x1'0000'0009lu; inline constexpr const unsigned long KEY_F5 = 0x1'0000'000Alu; inline constexpr const unsigned long KEY_F6 = 0x1'0000'000Blu; inline constexpr const unsigned long KEY_F7 = 0x1'0000'000Clu; inline constexpr const unsigned long KEY_F8 = 0x1'0000'000Dlu; inline constexpr const unsigned long KEY_F9 = 0x1'0000'000Elu; inline constexpr const unsigned long KEY_F10 = 0x1'0000'000Flu; inline constexpr const unsigned long KEY_F11 = 0x1'0000'0010lu; inline constexpr const unsigned long KEY_F12 = 0x1'0000'0011lu; inline constexpr const unsigned long KEY_PAGE_UP = 0x1'0000'0012lu; inline constexpr const unsigned long KEY_PAGE_DOWN = 0x1'0000'0013lu; inline constexpr const unsigned long KEY_HOME = 0x1'0000'0014lu; inline constexpr const unsigned long KEY_END = 0x1'0000'0015lu; // key modifiers inline constexpr const unsigned long KEY_CTRL = 0x2'0000'0000lu; inline constexpr const unsigned long KEY_SHIFT = 0x4'0000'0000lu; inline constexpr const unsigned long KEY_ALT = 0x8'0000'0000lu; } void enterAlternativeTerminal(); void leaveAlternativeTerminal(); IntVector2 getTerminalSize(); void clearTerminal(); void clearTerminalLine(); void hideCursor(); void showCursor(); void resetCursor(); void moveCursorLeft(int i); void moveCursorRight(int i); void moveCursorUp(int i); void moveCursorDown(int i); bool enterRawTerminal(); bool leaveRawTerminal(); u64 getRawChar(); bool isSpecialChar(u64 u); struct SpecialChar { u64 key = 0; bool control = 0; bool shift = 0; bool alt = 0; }; SpecialChar convertToSpecialChar(u64 u); }