1 #ifndef TERMOX_PAINTER_GLYPH_STRING_HPP
2 #define TERMOX_PAINTER_GLYPH_STRING_HPP
7 #include <termox/common/mb_to_u32.hpp>
8 #include <termox/painter/brush.hpp>
9 #include <termox/painter/color.hpp>
10 #include <termox/painter/glyph.hpp>
11 #include <termox/painter/trait.hpp>
22 static constexpr
auto npos = -1;
33 template <
typename... Attributes>
36 for (char32_t c : symbols)
40 template <
typename... Attributes>
41 Glyph_string(char32_t
const* symbols, Attributes... attrs)
45 template <
typename... Attributes>
46 Glyph_string(std::u32string
const& symbols, Attributes... attrs)
54 template <
typename... Attributes>
59 template <
typename... Attributes>
64 template <
typename... Attributes>
65 Glyph_string(std::string
const& symbols, Attributes... attrs)
71 template <
typename InputIterator>
73 : vector<
Glyph>::vector(first, last)
86 [[nodiscard]]
auto length() const ->
int;
90 [[nodiscard]] auto
size() const ->
int;
95 [[nodiscard]] auto
u32str() const -> std::u32string;
100 [[nodiscard]] auto
str() const -> std::
string;
125 using size_type =
int;
126 using std::vector<
Glyph>::value_type;
127 using std::vector<
Glyph>::allocator_type;
128 using std::vector<
Glyph>::difference_type;
129 using std::vector<
Glyph>::reference;
130 using std::vector<
Glyph>::const_reference;
131 using std::vector<
Glyph>::pointer;
132 using std::vector<
Glyph>::const_pointer;
133 using std::vector<
Glyph>::iterator;
134 using std::vector<
Glyph>::const_iterator;
135 using std::vector<
Glyph>::reverse_iterator;
136 using std::vector<
Glyph>::const_reverse_iterator;
138 using std::vector<
Glyph>::operator[];
140 using std::vector<
Glyph>::assign;
141 using std::vector<
Glyph>::get_allocator;
142 using std::vector<
Glyph>::at;
143 using std::vector<
Glyph>::front;
144 using std::vector<
Glyph>::back;
145 using std::vector<
Glyph>::data;
146 using std::vector<
Glyph>::begin;
147 using std::vector<
Glyph>::cbegin;
148 using std::vector<
Glyph>::end;
149 using std::vector<
Glyph>::cend;
150 using std::vector<
Glyph>::rbegin;
151 using std::vector<
Glyph>::crbegin;
152 using std::vector<
Glyph>::rend;
153 using std::vector<
Glyph>::crend;
154 using std::vector<
Glyph>::empty;
155 using std::vector<
Glyph>::max_size;
156 using std::vector<
Glyph>::reserve;
157 using std::vector<
Glyph>::capacity;
158 using std::vector<
Glyph>::shrink_to_fit;
159 using std::vector<
Glyph>::clear;
160 using std::vector<
Glyph>::insert;
161 using std::vector<
Glyph>::erase;
162 using std::vector<
Glyph>::push_back;
163 using std::vector<
Glyph>::pop_back;
164 using std::vector<
Glyph>::resize;
165 using std::vector<
Glyph>::swap;
178 [[nodiscard]]
auto operator|(char32_t
const* gs, Trait t) ->
ox::Glyph_string;
180 [[nodiscard]]
auto operator|(char32_t
const* gs, Traits ts) ->
ox::Glyph_string;
184 [[nodiscard]]
auto operator|(
char const* gs, Traits ts) ->
ox::Glyph_string;
193 [[nodiscard]]
auto operator|(
Glyph_string gs, Background_color c)
196 [[nodiscard]]
auto operator|(char32_t
const* gs, Background_color c)
202 [[nodiscard]]
auto operator|(
Glyph_string gs, Foreground_color c)
205 [[nodiscard]]
auto operator|(char32_t
const* gs, Foreground_color c)
215 [[nodiscard]]
auto operator|(char32_t
const* gs, Brush b) ->
Glyph_string;
Holds the look of any paintable object with Traits and Colors.
Definition: brush.hpp:13
Holds a collection of Glyphs with a similar interface to std::string.
Definition: glyph_string.hpp:19
Glyph_string(std::u32string_view symbols, Attributes... attrs)
Construct with a Glyph for each char32_t in symbols and Brush b.
Definition: glyph_string.hpp:34
Glyph_string()=default
Default constructs an empty Glyph_string.
Glyph_string(std::string_view symbols, Attributes... attrs)
Construct with a Glyph for each character in symbols and Brush b.
Definition: glyph_string.hpp:55
void remove_traits(Traits traits)
Remove a series of Traits from every Glyph within the Glyph_string.
Definition: glyph_string.cpp:76
auto append(Glyph g) -> Glyph_string &
Append a single Glyph to the end of *this.
Definition: glyph_string.cpp:21
auto length() const -> int
Return the number of Glyphs in *this Glyph_string.
Definition: glyph_string.cpp:34
auto size() const -> int
Return the number of Glyphs in *this Glyph_string.
Definition: glyph_string.cpp:36
Glyph_string(InputIterator first, InputIterator last)
Construct with iterators from any container providing Input Iterators.
Definition: glyph_string.hpp:72
static constexpr auto npos
Used to indicate 'Until the end of the string'.
Definition: glyph_string.hpp:22
void clear_traits()
Remove all currently set traits on each Glyph.
Definition: glyph_string.cpp:58
void add_color(Background_color bg)
Add bg as the background color to every Glyph contained in *this.
Definition: glyph_string.cpp:64
void remove_background()
Set the background color as the default for every Glyph in *this.
Definition: glyph_string.cpp:82
void add_traits(Traits traits)
Add traits to every Glyph contained in *this.
Definition: glyph_string.cpp:52
auto str() const -> std::string
Convert to a std::string.
Definition: glyph_string.cpp:47
void remove_foreground()
Set the foreground color as the default for every Glyph in *this.
Definition: glyph_string.cpp:88
auto u32str() const -> std::u32string
Convert to a std::u32string, each Glyph being a char32_t.
Definition: glyph_string.cpp:38
Holds a description of a paintable tile on the screen.
Definition: glyph.hpp:11