diff options
| author | roy <[email protected]> | 2026-06-29 21:32:00 +0300 |
|---|---|---|
| committer | roy <[email protected]> | 2026-06-29 21:32:00 +0300 |
| commit | 0fdb0405b6567aed4cd00637f79410ceeafd2e3b (patch) | |
| tree | 816301b144f5fa95d52b44d343524ebf6710c026 /terminal-game-utils.hpp | |
| parent | 9bde54a7c3922c2e325748b8e5591a00bf439980 (diff) | |
Added background color options. Added README.md.
Diffstat (limited to 'terminal-game-utils.hpp')
| -rw-r--r-- | terminal-game-utils.hpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/terminal-game-utils.hpp b/terminal-game-utils.hpp index 0e41074..328ff63 100644 --- a/terminal-game-utils.hpp +++ b/terminal-game-utils.hpp @@ -6,7 +6,7 @@ #include <termios.h> #include <unistd.h> -namespace TGU { +namespace tgu { inline struct termios orig_termios; @@ -152,7 +152,7 @@ inline GameKey GetKeyPress() { return KeyMap[keypress_string]; } -// Terminal color printers: +// Text printers: inline void TextGreen() { std::cout << "\033[32m"; } @@ -160,12 +160,24 @@ inline void TextRed() { std::cout << "\033[31m"; } inline void TextBlue() { std::cout << "\033[34m"; } -inline void TextReset() { std::cout << "\033[0m"; } - inline void TextRGB(int r, int g, int b) { std::cout << std::format("\033[38;2;{};{};{}m", r, g, b); }; +// Background printers: + +inline void BGGreen() { std::cout << "\033[42m"; } + +inline void BGRed() { std::cout << "\033[41m"; } + +inline void BGBlue() { std::cout << "\033[44m"; } + +inline void BGRGB(int r, int g, int b) { + std::cout << std::format("\033[48;2;{};{};{}m", r, g, b); +} + +inline void TerminalColorReset() { std::cout << "\033[0m"; } + // Game buffer printers: inline void EnterGameBuffer() { std::cout << "\033[?1049h"; } @@ -175,4 +187,4 @@ inline void LeaveGameBuffer() { std::cout << "\033[?1049l"; } inline void MoveCursor(int row, int col) { std::cout << "\033[" << row << ";" << col << "H" << std::flush; } -}; // namespace TGU +}; // namespace tgu |
