Added long list of attributes

This commit is contained in:
Bob Polis
2021-12-12 13:14:57 +01:00
parent a93b5d7b0e
commit 97a5cd5873
2 changed files with 181 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include <iostream>
#include <iomanip>
#include <string>
#include <stdexcept>
using namespace sc;
@ -53,6 +54,146 @@ void term::show_cursor() const {
*_out << "\x1b[?25h";
}
void term::reset() const {
*_out << "\x1b[m";
}
void term::bold() const {
*_out << "\x1b[1m";
}
void term::italic() const {
*_out << "\x1b[3m";
}
void term::underline() const {
*_out << "\x1b[4m";
}
void term::overline() const {
*_out << "\x1b[53m";
}
void term::strikethru() const {
*_out << "\x1b[9m";
}
void term::blinkslow() const {
*_out << "\x1b[5m";
}
void term::blinkfast() const {
*_out << "\x1b[6m";
}
void term::reverse() const {
*_out << "\x1b[7m";
}
void term::blackf() const {
*_out << "\x1b[30m";
}
void term::redf() const {
*_out << "\x1b[31m";
}
void term::greenf() const {
*_out << "\x1b[32m";
}
void term::yellowf() const {
*_out << "\x1b[33m";
}
void term::bluef() const {
*_out << "\x1b[34m";
}
void term::magentaf() const {
*_out << "\x1b[35m";
}
void term::cyanf() const {
*_out << "\x1b[36m";
}
void term::whitef() const {
*_out << "\x1b[37m";
}
void term::defaultf() const {
*_out << "\x1b[39m";
}
void term::grayf(int val) const {
gray(val, 38);
}
void term::rgbf(int r, int g, int b) const {
rgb(r, g, b, 38);
}
void term::blackb() const {
*_out << "\x1b[40m";
}
void term::redb() const {
*_out << "\x1b[41m";
}
void term::greenb() const {
*_out << "\x1b[42m";
}
void term::yellowb() const {
*_out << "\x1b[43m";
}
void term::blueb() const {
*_out << "\x1b[44m";
}
void term::magentab() const {
*_out << "\x1b[45m";
}
void term::cyanb() const {
*_out << "\x1b[46m";
}
void term::whiteb() const {
*_out << "\x1b[47m";
}
void term::defaultb() const {
*_out << "\x1b[49m";
}
void term::grayb(int val) const {
gray(val, 48);
}
void term::rgbb(int r, int g, int b) const {
rgb(r, g, b, 48);
}
void term::gray(int val, int code) const {
if (val < 0 || val > 24) {
throw std::invalid_argument("gray value out of range");
}
*_out << "\x1b[" << code << ";5;" << 232 + val << "m";
}
void term::rgb(int r, int g, int b, int code) const {
if (r < 0 || r > 5 || g < 0 || g > 5 || b < 0 || b > 5) {
throw std::invalid_argument("rgb color component out of range");
}
*_out << "\x1b[" << code << ";5;" << (16 + 36 * r + 7 * g + b) << "m";
}
// ------------------------------------------------------------------------
cursor_hider::cursor_hider(int fd) : _t {fd} {
_t.hide_cursor();
}