void draw_frame(const std::string& title, int x, int y, int w, int h) { for (int _y = y; _y < y + h; _y++) { for (int _x = x; _x < x + w; _x++) { if (_y == y && _x == x) putchar(_x, _y, 218); else if (_y == y && _x == (x + w - 1)) putchar(_x, _y, 191); else if (_y == (y + h - 1) && _x == x) putchar(_x, _y, 192); else if (_y == (y + h - 1) && _x == (x + w - 1)) putchar(_x, _y, 217); else if (_x == x || (_x == x + w - 1)) putchar(_x, _y, 179); else if (_y == y || (_y == y + h - 1)) putchar(_x, _y, 196); else putchar(_x, _y, ' '); } } color_t current_fore = get_foreground_color(); color_t current_back = get_background_color(); set_foreground_color(color_black); set_background_color(color_white); io::printf(x + w / 2, y, CENTER, "%s", title.c_str()); set_foreground_color(current_fore); set_background_color(current_back); }
void set_background_color(const color_t& color) { color_t current_fore = get_foreground_color(); attron( color_to_curses_color(current_fore, color) ); _last_background = color; }
void set_background_color(const color_t& color) { HANDLE handle = sys::get_offscreen_buffer(); // Need both fg and bg color so we don't overwrite the old settings. WORD wColor = color_to_win32_color_bg(color); WORD fgColor = color_to_win32_color( get_foreground_color() ); SetConsoleTextAttribute( handle, wColor | fgColor ); }
void start_font(std::ostream& os, Font_spec font) { if (!supports_color(os)) return; char const* codes[3] { get_weight(font.weight), get_foreground_color(font.color), get_effects(font.effects) }; char const** last = std::remove(codes, codes + 3, nullptr); char const** first = codes; os << "\033["; while (first != last) { os << *first; if (first + 1 != last) os << ';'; ++first; } os << 'm'; }