cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
cursor.hpp
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-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
12#include <cstddef>
13#include <cstdint>
14#include <string>
15
16namespace Term
17{
18
19class Cursor
20{
21public:
22 Cursor() = default;
23 Cursor(const std::size_t& row, const std::size_t& column);
24 std::size_t row() const;
25 std::size_t column() const;
26 void setRow(const std::size_t&);
27 void setColum(const std::size_t&);
28 bool empty() const;
29 bool operator==(const Term::Cursor& cursor) const;
30 bool operator!=(const Term::Cursor& cursor) const;
31
32private:
33 std::pair<std::size_t, std::size_t> m_position;
34};
35
36// returns the current cursor position (row, column) (Y, X)
38
39// move the cursor to the given (row, column) / (Y, X)
40std::string cursor_move(const std::size_t& row, const std::size_t& column);
41// move the cursor the given rows up
42std::string cursor_up(const std::size_t& rows);
43// move the cursor the given rows down
44std::string cursor_down(const std::size_t& rows);
45// move the cursor the given columns left
46std::string cursor_left(const std::size_t& columns);
47// move the cursor the given columns right
48std::string cursor_right(const std::size_t& columns);
49// the ANSI code to generate a cursor position report
50std::string cursor_position_report();
51// turn off the cursor
52std::string cursor_off();
53// turn on the cursor
54std::string cursor_on();
55
56// clears the screen from the current cursor position to the end of the screen
57std::string clear_eol();
58
59} // namespace Term
std::size_t column() const
Definition cursor.cpp:16
void setColum(const std::size_t &)
Definition cursor.cpp:22
std::pair< std::size_t, std::size_t > m_position
Definition cursor.hpp:33
bool operator!=(const Term::Cursor &cursor) const
Definition cursor.cpp:26
void setRow(const std::size_t &)
Definition cursor.cpp:20
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:24
Definition args.cpp:13
std::string clear_eol()
Definition cursor.cpp:44
std::string cursor_position_report()
Definition cursor.cpp:42
Term::Cursor cursor_position()
Definition cursor.cpp:26
std::string cursor_off()
Definition cursor.cpp:28
std::string cursor_left(const std::size_t &columns)
Definition cursor.cpp:40
std::string cursor_move(const std::size_t &row, const std::size_t &column)
Definition cursor.cpp:32
std::string cursor_on()
Definition cursor.cpp:30
std::string cursor_up(const std::size_t &rows)
Definition cursor.cpp:34
std::string cursor_right(const std::size_t &columns)
Definition cursor.cpp:38
std::string cursor_down(const std::size_t &rows)
Definition cursor.cpp:36