|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <cstddef> |
| 4 | +#include <string> |
| 5 | +#include <utility> |
| 6 | + |
| 7 | +namespace Term |
| 8 | +{ |
| 9 | + |
| 10 | +class Cursor |
| 11 | +{ |
| 12 | +public: |
| 13 | + Cursor() = default; |
| 14 | + Cursor(const std::size_t&, const std::size_t&); |
| 15 | + std::size_t row() const; |
| 16 | + std::size_t column() const; |
| 17 | + void setRow(const std::size_t&); |
| 18 | + void setColum(const std::size_t&); |
| 19 | + bool empty(); |
| 20 | + |
| 21 | +private: |
| 22 | + std::pair<std::size_t, std::size_t> m_position{0, 0}; |
| 23 | +}; |
| 24 | + |
| 25 | +// returns the current cursor position (row, column) (Y, X) |
| 26 | +Term::Cursor cursor_position(); |
| 27 | + |
| 28 | +// move the cursor to the given (row, column) / (Y, X) |
| 29 | +std::string cursor_move(std::size_t row, std::size_t column); |
| 30 | +// move the cursor the given rows up |
| 31 | +std::string cursor_up(std::size_t rows); |
| 32 | +// move the cursor the given rows down |
| 33 | +std::string cursor_down(std::size_t rows); |
| 34 | +// move the cursor the given columns left |
| 35 | +std::string cursor_left(std::size_t columns); |
| 36 | +// move the cursor the given columns right |
| 37 | +std::string cursor_right(std::size_t columns); |
| 38 | +// the ANSI code to generate a cursor position report |
| 39 | +std::string cursor_position_report(); |
| 40 | +// turn off the cursor |
| 41 | +std::string cursor_off(); |
| 42 | +// turn on the cursor |
| 43 | +std::string cursor_on(); |
| 44 | + |
| 45 | +// clears the screen from the current cursor position to the end of the screen |
| 46 | +std::string clear_eol(); |
| 47 | + |
| 48 | +} // namespace Term |
0 commit comments