12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #pragma once
- /*
- * Functions to handle the terminal and its properties
- */
- #include "bzbterm/termcolor.h"
- #include "bzbstring/stringutils.h"
- namespace bzbterm {
- /*
- * Prints the specified escape sequence
- */
- inline void set_esc_seq(EscSeq e) {
- std::cout << e;
- }
- /*
- * Changes the shell's font color
- */
- inline void set_fg_color(unsigned int r, unsigned int g, unsigned int b) {
- std::cout << bzbstring::concat("\033[38;2;", r, ";", g, ";", b, "m");
- }
- /*
- * Changes the shell's font color
- */
- inline void set_bg_color(unsigned int r, unsigned int g, unsigned int b) {
- std::cout << bzbstring::concat("\033[48;2;", r, ";", g, ";", b, "m");
- }
- /*
- * Clears the screen and resets the cursor to the top left corner
- */
- inline void clear_screen() {
- std::cout << "\033[1;1H" << "\033[2J";
- }
- /*
- * Saves the screen's content for later restoring it
- */
- inline void save_screen() {
- std::cout << "\033[?47h";
- }
- /*
- * Restore the screen's content as saved before
- */
- inline void restore_screen() {
- std::cout << "\033[?47l";
- }
- /*
- * Clears the current line
- */
- inline void clear_line() noexcept {
- std::cout << "\033[2K";
- }
- /*
- * Hide the cursor
- */
- inline void show_cursor() noexcept {
- std::cout << "\033[?25h";
- }
- /*
- * Hide the cursor
- */
- inline void hide_cursor() noexcept {
- std::cout << "\033[?25l";
- }
- }
|