17#define WIN32_LEAN_AND_MEAN
25#if !defined(FTXUI_UNLIKELY)
26#if defined(COMPILER_GCC) || defined(__clang__)
27#define FTXUI_UNLIKELY(x) __builtin_expect(!!(x), 0)
29#define FTXUI_UNLIKELY(x) (x)
33#if !defined(FTXUI_LIKELY)
34#if defined(COMPILER_GCC) || defined(__clang__)
35#define FTXUI_LIKELY(x) __builtin_expect(!!(x), 1)
37#define FTXUI_LIKELY(x) (x)
52 static bool done =
false;
75 std::stringstream&
ss,
80 ss <<
"\x1B]8;;" <<
screen->Hyperlink(
next.hyperlink) <<
"\x1B\\";
88 ss << (
next.bold ?
"\x1B[1m" :
"");
89 ss << (
next.dim ?
"\x1B[2m" :
"");
94 next.underlined_double !=
prev.underlined_double)) {
95 ss << (
next.underlined ?
"\x1B[4m"
96 :
next.underlined_double ?
"\x1B[21m"
102 ss << (
next.blink ?
"\x1B[5m"
108 ss << (
next.inverted ?
"\x1B[7m"
114 ss << (
next.strikethrough ?
"\x1B[9m"
119 next.background_color !=
prev.background_color)) {
120 ss <<
"\x1B[" +
next.foreground_color.Print(
false) +
"m";
121 ss <<
"\x1B[" +
next.background_color.Print(
true) +
"m";
134 if (left <
other.left) {
return true; }
135 if (left >
other.left) {
return false; }
136 if (top <
other.top) {
return true; }
137 if (top >
other.top) {
return false; }
138 if (right <
other.right) {
return true; }
139 if (right >
other.right) {
return false; }
140 if (down <
other.down) {
return true; }
141 if (down >
other.down) {
return false; }
142 if (round <
other.round) {
return true; }
143 if (round >
other.round) {
return false; }
151 {
"─", {1, 0, 1, 0, 0}},
152 {
"━", {2, 0, 2, 0, 0}},
153 {
"╍", {2, 0, 2, 0, 0}},
155 {
"│", {0, 1, 0, 1, 0}},
156 {
"┃", {0, 2, 0, 2, 0}},
157 {
"╏", {0, 2, 0, 2, 0}},
159 {
"┌", {0, 0, 1, 1, 0}},
160 {
"┍", {0, 0, 2, 1, 0}},
161 {
"┎", {0, 0, 1, 2, 0}},
162 {
"┏", {0, 0, 2, 2, 0}},
164 {
"┐", {1, 0, 0, 1, 0}},
165 {
"┑", {2, 0, 0, 1, 0}},
166 {
"┒", {1, 0, 0, 2, 0}},
167 {
"┓", {2, 0, 0, 2, 0}},
169 {
"└", {0, 1, 1, 0, 0}},
170 {
"┕", {0, 1, 2, 0, 0}},
171 {
"┖", {0, 2, 1, 0, 0}},
172 {
"┗", {0, 2, 2, 0, 0}},
174 {
"┘", {1, 1, 0, 0, 0}},
175 {
"┙", {2, 1, 0, 0, 0}},
176 {
"┚", {1, 2, 0, 0, 0}},
177 {
"┛", {2, 2, 0, 0, 0}},
179 {
"├", {0, 1, 1, 1, 0}},
180 {
"┝", {0, 1, 2, 1, 0}},
181 {
"┞", {0, 2, 1, 1, 0}},
182 {
"┟", {0, 1, 1, 2, 0}},
183 {
"┠", {0, 2, 1, 2, 0}},
184 {
"┡", {0, 2, 2, 1, 0}},
185 {
"┢", {0, 1, 2, 2, 0}},
186 {
"┣", {0, 2, 2, 2, 0}},
188 {
"┤", {1, 1, 0, 1, 0}},
189 {
"┥", {2, 1, 0, 1, 0}},
190 {
"┦", {1, 2, 0, 1, 0}},
191 {
"┧", {1, 1, 0, 2, 0}},
192 {
"┨", {1, 2, 0, 2, 0}},
193 {
"┩", {2, 2, 0, 1, 0}},
194 {
"┪", {2, 1, 0, 2, 0}},
195 {
"┫", {2, 2, 0, 2, 0}},
197 {
"┬", {1, 0, 1, 1, 0}},
198 {
"┭", {2, 0, 1, 1, 0}},
199 {
"┮", {1, 0, 2, 1, 0}},
200 {
"┯", {2, 0, 2, 1, 0}},
201 {
"┰", {1, 0, 1, 2, 0}},
202 {
"┱", {2, 0, 1, 2, 0}},
203 {
"┲", {1, 0, 2, 2, 0}},
204 {
"┳", {2, 0, 2, 2, 0}},
206 {
"┴", {1, 1, 1, 0, 0}},
207 {
"┵", {2, 1, 1, 0, 0}},
208 {
"┶", {1, 1, 2, 0, 0}},
209 {
"┷", {2, 1, 2, 0, 0}},
210 {
"┸", {1, 2, 1, 0, 0}},
211 {
"┹", {2, 2, 1, 0, 0}},
212 {
"┺", {1, 2, 2, 0, 0}},
213 {
"┻", {2, 2, 2, 0, 0}},
215 {
"┼", {1, 1, 1, 1, 0}},
216 {
"┽", {2, 1, 1, 1, 0}},
217 {
"┾", {1, 1, 2, 1, 0}},
218 {
"┿", {2, 1, 2, 1, 0}},
219 {
"╀", {1, 2, 1, 1, 0}},
220 {
"╁", {1, 1, 1, 2, 0}},
221 {
"╂", {1, 2, 1, 2, 0}},
222 {
"╃", {2, 2, 1, 1, 0}},
223 {
"╄", {1, 2, 2, 1, 0}},
224 {
"╅", {2, 1, 1, 2, 0}},
225 {
"╆", {1, 1, 2, 2, 0}},
226 {
"╇", {2, 2, 2, 1, 0}},
227 {
"╈", {2, 1, 2, 2, 0}},
228 {
"╉", {2, 2, 1, 2, 0}},
229 {
"╊", {1, 2, 2, 2, 0}},
230 {
"╋", {2, 2, 2, 2, 0}},
232 {
"═", {3, 0, 3, 0, 0}},
233 {
"║", {0, 3, 0, 3, 0}},
235 {
"╒", {0, 0, 3, 1, 0}},
236 {
"╓", {0, 0, 1, 3, 0}},
237 {
"╔", {0, 0, 3, 3, 0}},
239 {
"╕", {3, 0, 0, 1, 0}},
240 {
"╖", {1, 0, 0, 3, 0}},
241 {
"╗", {3, 0, 0, 3, 0}},
243 {
"╘", {0, 1, 3, 0, 0}},
244 {
"╙", {0, 3, 1, 0, 0}},
245 {
"╚", {0, 3, 3, 0, 0}},
247 {
"╛", {3, 1, 0, 0, 0}},
248 {
"╜", {1, 3, 0, 0, 0}},
249 {
"╝", {3, 3, 0, 0, 0}},
251 {
"╞", {0, 1, 3, 1, 0}},
252 {
"╟", {0, 3, 1, 3, 0}},
253 {
"╠", {0, 3, 3, 3, 0}},
255 {
"╡", {3, 1, 0, 1, 0}},
256 {
"╢", {1, 3, 0, 3, 0}},
257 {
"╣", {3, 3, 0, 3, 0}},
259 {
"╤", {3, 0, 3, 1, 0}},
260 {
"╥", {1, 0, 1, 3, 0}},
261 {
"╦", {3, 0, 3, 3, 0}},
263 {
"╧", {3, 1, 3, 0, 0}},
264 {
"╨", {1, 3, 1, 0, 0}},
265 {
"╩", {3, 3, 3, 0, 0}},
267 {
"╪", {3, 1, 3, 1, 0}},
268 {
"╫", {1, 3, 1, 3, 0}},
269 {
"╬", {3, 3, 3, 3, 0}},
271 {
"╭", {0, 0, 1, 1, 1}},
272 {
"╮", {1, 0, 0, 1, 1}},
273 {
"╯", {1, 1, 0, 0, 1}},
274 {
"╰", {0, 1, 1, 0, 1}},
276 {
"╴", {1, 0, 0, 0, 0}},
277 {
"╵", {0, 1, 0, 0, 0}},
278 {
"╶", {0, 0, 1, 0, 0}},
279 {
"╷", {0, 0, 0, 1, 0}},
281 {
"╸", {2, 0, 0, 0, 0}},
282 {
"╹", {0, 2, 0, 0, 0}},
283 {
"╺", {0, 0, 2, 0, 0}},
284 {
"╻", {0, 0, 0, 2, 0}},
286 {
"╼", {1, 0, 2, 0, 0}},
287 {
"╽", {0, 1, 0, 2, 0}},
288 {
"╾", {2, 0, 1, 0, 0}},
289 {
"╿", {0, 2, 0, 1, 0}},
293template <
class A,
class B>
294std::map<B, A>
InvertMap(
const std::map<A, B> input) {
296 for (
const auto&
it : input) {
364 return pixel.automerge &&
pixel.character.size() == 3;
396 : stencil{0, dimx - 1, 0, dimy - 1},
417 std::stringstream
ss;
422 for (
int y = 0; y <
dimy_; ++y) {
450 std::cout <<
ToString() <<
'\0' << std::flush;
501 std::stringstream
ss;
505 for (
int y = 1; y <
dimy_; ++y) {
511 for (
int y = 1; y <
dimy_; ++y) {
521 for (
auto&
cell : line) {
536 for (
int y = 0; y <
dimy_; ++y) {
537 for (
int x = 0; x <
dimx_; ++x) {
567 if (
hyperlinks_.size() == std::numeric_limits<uint8_t>::max()) {
A rectangular grid of Pixel.
const std::string & Hyperlink(uint8_t id) const
std::string ToString() const
static Screen Create(Dimensions dimension)
Create a screen with the given dimension.
Pixel & PixelAt(int x, int y)
Access a cell (Pixel) at a given position.
std::string & at(int x, int y)
Access a character in a cell at a given position.
Screen(int dimx, int dimy)
uint8_t RegisterHyperlink(const std::string &link)
std::string ResetPosition(bool clear=false) const
Return a string to be printed in order to reset the cursor position to the beginning of the screen.
void Clear()
Clear all the pixel from the screen.
std::vector< std::string > hyperlinks_
std::vector< std::vector< Pixel > > pixels_
Dimensions Size()
Get the terminal size.
int string_width(const std::string &)
Component Slider(SliderOption< T > options)
A slider in any direction.
#define FTXUI_UNLIKELY(x)
bool Contain(int x, int y) const
A unicode character and its associated style.