cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
|
Represents a rectangular window, as a 2D array of characters and their attributes. More...
#include <cpp-terminal/window.hpp>
Public Member Functions | |
Window (const Size &size) | |
Window (const Screen &screen) | |
const Columns & | columns () const noexcept |
const Rows & | rows () const noexcept |
void | set_char (const std::size_t &column, const std::size_t &row, const char32_t &character) |
void | set_fg_reset (const std::size_t &column, const std::size_t &row) |
void | set_bg_reset (const std::size_t &column, const std::size_t &row) |
void | set_fg (const std::size_t &column, const std::size_t &row, const Color &color) |
void | set_bg (const std::size_t &column, const std::size_t &row, const Color &color) |
void | set_style (const std::size_t &column, const std::size_t &row, const Style &style) |
void | set_cursor_pos (const std::size_t &column, const std::size_t &row) |
void | set_h (const std::size_t &) |
void | print_str (const std::size_t &column, const std::size_t &, const std::string &, const std::size_t &=0, bool=false) |
void | fill_fg (const std::size_t &column, const std::size_t &, const std::size_t &, const std::size_t &, const Color &) |
void | fill_bg (const std::size_t &column, const std::size_t &, const std::size_t &, const std::size_t &, const Color &) |
void | fill_style (const std::size_t &column, const std::size_t &, const std::size_t &, const std::size_t &, const Style &) |
void | print_border () |
void | print_rect (const std::size_t &column, const std::size_t &, const std::size_t &, const std::size_t &) |
void | clear () |
bool | insideWindow (const std::size_t &column, const std::size_t &row) const |
std::string | render (const std::size_t &, const std::size_t &, bool) |
Private Member Functions | |
std::size_t | index (const std::size_t &column, const std::size_t &row) const |
char32_t | get_char (const std::size_t &column, const std::size_t &row) |
bool | get_fg_reset (const std::size_t &column, const std::size_t &row) |
bool | get_bg_reset (const std::size_t &column, const std::size_t &row) |
Term::Color | get_fg (const std::size_t &column, const std::size_t &row) |
Term::Color | get_bg (const std::size_t &column, const std::size_t &row) |
Term::Style | get_style (const std::size_t &column, const std::size_t &row) |
Private Attributes | |
Term::Size | m_size |
Term::Cursor | m_cursor {1, 1} |
std::vector< char32_t > | m_chars |
std::vector< Term::Color > | m_fg |
std::vector< Term::Color > | m_bg |
std::vector< bool > | m_fg_reset |
std::vector< bool > | m_bg_reset |
std::vector< Style > | m_style |
Represents a rectangular window, as a 2D array of characters and their attributes.
Represents a rectangular window, as a 2D array of characters and their attributes. The render method can convert this internal representation to a string that when printed will show the Window on the screen. The natural way to represent a character in a terminal would be a "unicode grapheme cluster", but due to a lack of a good library for C++ that could handle those, we simply use a Unicode code point as a character.
Definition at line 33 of file window.hpp.
|
explicit |
Definition at line 26 of file window.cpp.
|
explicit |
Definition at line 28 of file window.cpp.
void Term::Window::clear | ( | ) |
Definition at line 189 of file window.cpp.
|
noexcept |
Definition at line 42 of file window.cpp.
void Term::Window::fill_bg | ( | const std::size_t & | column, |
const std::size_t & | y1, | ||
const std::size_t & | x2, | ||
const std::size_t & | y2, | ||
const Color & | rgb ) |
Definition at line 132 of file window.cpp.
void Term::Window::fill_fg | ( | const std::size_t & | column, |
const std::size_t & | y1, | ||
const std::size_t & | x2, | ||
const std::size_t & | y2, | ||
const Color & | rgb ) |
Definition at line 124 of file window.cpp.
void Term::Window::fill_style | ( | const std::size_t & | column, |
const std::size_t & | y1, | ||
const std::size_t & | x2, | ||
const std::size_t & | y2, | ||
const Style & | color ) |
Definition at line 140 of file window.cpp.
|
private |
Definition at line 38 of file window.cpp.
|
private |
Definition at line 34 of file window.cpp.
|
private |
Definition at line 30 of file window.cpp.
|
private |
Definition at line 36 of file window.cpp.
|
private |
Definition at line 32 of file window.cpp.
|
private |
Definition at line 40 of file window.cpp.
|
private |
Definition at line 299 of file window.cpp.
bool Term::Window::insideWindow | ( | const std::size_t & | column, |
const std::size_t & | row ) const |
void Term::Window::print_border | ( | ) |
Definition at line 148 of file window.cpp.
void Term::Window::print_rect | ( | const std::size_t & | column, |
const std::size_t & | y1, | ||
const std::size_t & | x2, | ||
const std::size_t & | y2 ) |
Definition at line 150 of file window.cpp.
void Term::Window::print_str | ( | const std::size_t & | column, |
const std::size_t & | y, | ||
const std::string & | s, | ||
const std::size_t & | indent = 0, | ||
bool | move_cursor = false ) |
Definition at line 97 of file window.cpp.
std::string Term::Window::render | ( | const std::size_t & | x0, |
const std::size_t & | y0, | ||
bool | term ) |
Definition at line 199 of file window.cpp.
|
noexcept |
Definition at line 44 of file window.cpp.
void Term::Window::set_bg | ( | const std::size_t & | column, |
const std::size_t & | row, | ||
const Color & | color ) |
Definition at line 70 of file window.cpp.
void Term::Window::set_bg_reset | ( | const std::size_t & | column, |
const std::size_t & | row ) |
Definition at line 58 of file window.cpp.
void Term::Window::set_char | ( | const std::size_t & | column, |
const std::size_t & | row, | ||
const char32_t & | character ) |
Definition at line 46 of file window.cpp.
void Term::Window::set_cursor_pos | ( | const std::size_t & | column, |
const std::size_t & | row ) |
Definition at line 78 of file window.cpp.
void Term::Window::set_fg | ( | const std::size_t & | column, |
const std::size_t & | row, | ||
const Color & | color ) |
Definition at line 64 of file window.cpp.
void Term::Window::set_fg_reset | ( | const std::size_t & | column, |
const std::size_t & | row ) |
Definition at line 52 of file window.cpp.
void Term::Window::set_h | ( | const std::size_t & | new_h | ) |
Definition at line 80 of file window.cpp.
void Term::Window::set_style | ( | const std::size_t & | column, |
const std::size_t & | row, | ||
const Style & | style ) |
Definition at line 76 of file window.cpp.
|
private |
Definition at line 85 of file window.hpp.
|
private |
Definition at line 87 of file window.hpp.
|
private |
Definition at line 83 of file window.hpp.
|
private |
Definition at line 82 of file window.hpp.
|
private |
Definition at line 84 of file window.hpp.
|
private |
Definition at line 86 of file window.hpp.
|
private |
Definition at line 81 of file window.hpp.
|
private |
Definition at line 88 of file window.hpp.