82 if(new_h ==
m_size.rows()) {
return; }
85 const std::size_t dc = (new_h -
m_size.rows()) *
m_size.columns();
89 m_fg.insert(
m_fg.end(), dc, {0, 0, 0});
90 m_bg.insert(
m_bg.end(), dc, {0, 0, 0});
97void Term::Window::print_str(
const std::size_t& x,
const std::size_t& y,
const std::string& s,
const std::size_t& indent,
bool move_cursor)
100 std::size_t xpos = x;
101 std::size_t ypos = y;
110 for(std::size_t j = 0; j < indent; ++j) {
set_char(x + j, ypos,
'.'); }
126 for(std::size_t j = y1; j <= y2; ++j)
128 for(std::size_t i = x1; i <= x2; ++i) {
set_fg(i, j, rgb); }
134 for(std::size_t j = y1; j <= y2; ++j)
136 for(std::size_t i = x1; i <= x2; ++i) {
set_bg(i, j, rgb); }
142 for(std::size_t j = y1; j <= y2; ++j)
144 for(std::size_t i = x1; i <= x2; ++i) {
set_style(i, j, color); }
155 for(std::size_t j = y1 + 1; j <= (y2 - 1); ++j)
160 for(std::size_t i = x1 + 1; i <= (x2 - 1); ++i)
172 for(std::size_t j = y1 + 1; j <= (y2 - 1); ++j)
177 for(std::size_t i = x1 + 1; i <= (x2 - 1); ++i)
205 bool current_fg_reset =
true;
206 bool current_bg_reset =
true;
208 for(std::size_t j = 1; j <=
m_size.rows(); ++j)
210 if(term) { out.append(
cursor_move(y0 + j - 1, x0)); }
211 for(std::size_t i = 1; i <=
m_size.columns(); ++i)
213 bool update_fg =
false;
214 bool update_bg =
false;
215 bool update_fg_reset =
false;
216 bool update_bg_reset =
false;
217 bool update_style =
false;
223 update_fg_reset =
true;
224 current_fg = {255, 255, 255};
233 update_bg_reset =
true;
234 current_bg = {255, 255, 255};
238 if(!current_fg_reset)
240 if(!(current_fg ==
get_fg(i, j)))
242 current_fg =
get_fg(i, j);
247 if(!current_fg_reset)
249 if(!(current_bg ==
get_bg(i, j)))
251 current_bg =
get_bg(i, j);
265 update_fg = !current_fg_reset;
266 update_bg = !current_bg_reset;
286 if(j <
m_size.rows()) { out.append(
"\n"); }
302 return ((row - 1) *
m_size.columns()) + (column - 1);
@ Default
Use the default terminal color, FG: 39, BG: 49.
const Columns & columns() const noexcept
const Rows & rows() const noexcept
static bool get(const Term::Terminfo::Bool &key)
@ UTF8
terminal has UTF-8 activated.
std::vector< Term::Color > m_bg
void set_h(const std::size_t &)
std::vector< bool > m_fg_reset
const Rows & rows() const noexcept
void print_str(const std::size_t &column, const std::size_t &, const std::string &, const std::size_t &=0, bool=false)
void set_char(const std::size_t &column, const std::size_t &row, const char32_t &character)
void print_rect(const std::size_t &column, const std::size_t &, const std::size_t &, const std::size_t &)
Term::Color get_fg(const std::size_t &column, const std::size_t &row)
void fill_bg(const std::size_t &column, const std::size_t &, const std::size_t &, const std::size_t &, const Color &)
const Columns & columns() const noexcept
void set_fg(const std::size_t &column, const std::size_t &row, const Color &color)
void fill_style(const std::size_t &column, const std::size_t &, const std::size_t &, const std::size_t &, const Style &)
void set_bg_reset(const std::size_t &column, const std::size_t &row)
std::string render(const std::size_t &, const std::size_t &, bool)
Term::Color get_bg(const std::size_t &column, const std::size_t &row)
std::vector< Term::Color > m_fg
void set_cursor_pos(const std::size_t &column, const std::size_t &row)
char32_t get_char(const std::size_t &column, const std::size_t &row)
bool get_bg_reset(const std::size_t &column, const std::size_t &row)
void set_fg_reset(const std::size_t &column, const std::size_t &row)
void fill_fg(const std::size_t &column, const std::size_t &, const std::size_t &, const std::size_t &, const Color &)
bool insideWindow(const std::size_t &column, const std::size_t &row) const
std::vector< bool > m_bg_reset
void set_bg(const std::size_t &column, const std::size_t &row, const Color &color)
std::vector< Style > m_style
bool get_fg_reset(const std::size_t &column, const std::size_t &row)
void set_style(const std::size_t &column, const std::size_t &row, const Style &style)
std::vector< char32_t > m_chars
std::size_t index(const std::size_t &column, const std::size_t &row) const
Term::Style get_style(const std::size_t &column, const std::size_t &row)
std::string utf32_to_utf8(const char32_t &codepoint, const bool &exception=false)
Encode a codepoint using UTF-8 std::string .
std::u32string utf8_to_utf32(const std::string &str)
std::string color_bg(const Term::Color::Name &name)
std::string style(const Term::Style &style)
@ Reset
resets all attributes (styles and colors)
std::string cursor_move(const std::size_t &row, const std::size_t &column)
std::string color_fg(const Term::Color::Name &name)