cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
cursor.cpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2025 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
11
12Term::Cursor::Cursor(const Position& position) : m_position(position) {}
13
14std::size_t Term::Cursor::row() const { return m_position.row(); }
15
16std::size_t Term::Cursor::column() const { return m_position.column(); }
17
18bool Term::Cursor::empty() const { return (0 == m_position.row()) && (0 == m_position.column()); }
19
20bool Term::Cursor::operator==(const Term::Cursor& cursor) const { return (this->row() == cursor.row()) && (this->column() == cursor.column()); }
21
22bool Term::Cursor::operator!=(const Term::Cursor& cursor) const { return !(*this == cursor); }
23
24std::string Term::cursor_off() { return "\u001b[?25l"; }
25
26std::string Term::cursor_on() { return "\u001b[?25h"; }
27
28std::string Term::cursor_move(const std::size_t& row, const std::size_t& column) { return "\u001b[" + std::to_string(row) + ';' + std::to_string(column) + 'H'; }
29
30std::string Term::cursor_up(const std::size_t& rows) { return "\u001b[" + std::to_string(rows) + 'A'; }
31
32std::string Term::cursor_down(const std::size_t& rows) { return "\u001b[" + std::to_string(rows) + 'B'; }
33
34std::string Term::cursor_right(const std::size_t& columns) { return "\u001b[" + std::to_string(columns) + 'C'; }
35
36std::string Term::cursor_left(const std::size_t& columns) { return "\u001b[" + std::to_string(columns) + 'D'; }
37
38std::string Term::cursor_position_report() { return "\u001b[6n"; }
39
40std::string Term::clear_eol() { return "\u001b[K"; }
std::size_t column() const
Definition cursor.cpp:16
bool operator!=(const Term::Cursor &cursor) const
Definition cursor.cpp:22
Cursor()=default
bool empty() const
Definition cursor.cpp:18
std::size_t row() const
Definition cursor.cpp:14
bool operator==(const Term::Cursor &cursor) const
Definition cursor.cpp:20
std::string clear_eol()
Definition cursor.cpp:40
std::string cursor_position_report()
Definition cursor.cpp:38
std::string cursor_off()
Definition cursor.cpp:24
std::string cursor_left(const std::size_t &columns)
Definition cursor.cpp:36
std::string cursor_move(const std::size_t &row, const std::size_t &column)
Definition cursor.cpp:28
std::string cursor_on()
Definition cursor.cpp:26
std::string cursor_up(const std::size_t &rows)
Definition cursor.cpp:30
std::string cursor_right(const std::size_t &columns)
Definition cursor.cpp:34
std::string cursor_down(const std::size_t &rows)
Definition cursor.cpp:32