Sista v3.1.0
C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
cursor.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022-2026 FLAK-ZOSO <mattia.marchese.2006@gmail.com>
3 * SPDX-License-Identifier: GPL-3.0-only
4 */
5
17#pragma once
18
19#include "ansi.hpp"
20#include "coordinates.hpp"
21
30#define CHA 'H'
39#define VPA 'd'
40
41namespace sista {
53 void clearScreen(bool spaces=true);
54
63 enum class EraseScreen: int {
66 ENTIRE_SCREEN = 2,
68 };
77 enum class EraseLine: int {
80 ENTIRE_LINE = 2,
81 };
90 enum class MoveCursor: char {
91 UP = 'A',
92 DOWN = 'B',
93 RIGHT = 'C',
94 LEFT = 'D',
98 };
107 enum class MoveCursorDEC: int {
110 };
119 enum class MoveCursorSCO: char {
122 };
123
137 struct Cursor {
138 private:
139 const static unsigned short int offset_y;
140 const static unsigned short int offset_x;
141
142 public:
144 Cursor();
146 ~Cursor();
147
153 void goTo(unsigned short int, unsigned short int) const;
159 void goTo(sista::Coordinates) const;
160
169 void eraseScreen(EraseScreen) const;
180 void eraseLine(EraseLine, bool=true) const;
181
191 void move(MoveCursor, unsigned short int) const;
200 void move(MoveCursorDEC) const;
209 void move(MoveCursorSCO) const;
210 };
211};
ANSI escape code utilities and types for terminal formatting.
Coordinates struct header file.
Sista library namespace.
Definition ansi.cpp:31
int BEGINNING_OF_PREVIOUS_LINE
Definition __init__.pyi:48
int BEGINNING_OF_NEXT_LINE
Definition __init__.pyi:47
EraseScreen
Enumeration for screen erasure options in ANSI escape codes.
Definition cursor.hpp:63
MoveCursor
Enumeration for cursor movement directions in ANSI escape codes.
Definition cursor.hpp:90
MoveCursorSCO
Enumeration for SCO-specific cursor movement commands in ANSI escape codes.
Definition cursor.hpp:119
void clearScreen(bool spaces)
Clears the terminal screen and optionally the scrollback buffer.
Definition cursor.cpp:27
EraseLine
Enumeration for line erasure options in ANSI escape codes.
Definition cursor.hpp:77
MoveCursorDEC
Enumeration for DEC-specific cursor movement commands in ANSI escape codes.
Definition cursor.hpp:107
Represents 2D coordinates with x and y values.
Definition coordinates.hpp:36
Class representing a terminal cursor for movement operations.
Definition cursor.hpp:137
void move(MoveCursor, unsigned short int) const
Moves the cursor in the specified direction by a given number of positions.
Definition cursor.cpp:59
Cursor()
Constructor that hides the cursor.
Definition cursor.cpp:35
void eraseLine(EraseLine, bool=true) const
Erases parts of the current line based on the specified EraseLine option.
Definition cursor.cpp:52
~Cursor()
Destructor that shows the cursor.
Definition cursor.cpp:38
void goTo(unsigned short int, unsigned short int) const
Moves the cursor to the specified (y, x) coordinates.
Definition cursor.cpp:42
void eraseScreen(EraseScreen) const
Erases parts of the screen based on the specified EraseScreen option.
Definition cursor.cpp:49