display

Layout and Rendering TUI library
git clone git://git.dimitrijedobrota.com/display.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

element.cpp (905B)


0 #include <iostream>
2 #include "display/element.hpp"
4 namespace display
5 {
7 std::ostream& Element::set_cursor(xpos_t xpos, ypos_t ypos)
8 {
9 return std::cout << alec::cursor_position(ypos.value + 1, xpos.value + 1);
10 }
12 std::ostream& Element::set_cursor(pos_t pos)
13 {
14 return set_cursor(pos.x, pos.y);
15 }
17 void Element::render_border() const
18 {
19 using namespace literals; // NOLINT(*namespace*)
20 set_cursor(axpos(), aypos());
22 std::cout << "┌";
23 for (auto i = 2_w; i < awth(); ++i) {
24 std::cout << "─";
25 }
26 std::cout << "┐";
28 for (auto j = aypos() + 1_y; j < aypos() + ahgt(); ++j) {
29 set_cursor(axpos(), j) << "│";
30 set_cursor(axpos() + awth() - 1_w, j) << "│";
31 }
33 set_cursor(axpos(), aypos() + ahgt() - 1_h);
34 std::cout << "└";
35 for (auto i = 2_w; i < awth(); ++i) {
36 std::cout << "─";
37 }
38 std::cout << "┘";
40 std::cout << std::flush;
41 }
43 } // namespace display