Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
cursor.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include "ansi.hpp"
15#include "coordinates.hpp"
16
25#define CHA 'H'
34#define VPA 'd'
35
36namespace sista {
48 void clearScreen(bool spaces=true);
49
58 enum class EraseScreen: int {
61 ENTIRE_SCREEN = 2,
63 };
72 enum class EraseLine: int {
75 ENTIRE_LINE = 2,
76 };
85 enum class MoveCursor: char {
86 UP = 'A',
87 DOWN = 'B',
88 RIGHT = 'C',
89 LEFT = 'D',
93 };
102 enum class MoveCursorDEC: int {
105 };
114 enum class MoveCursorSCO: char {
117 };
118
132 struct Cursor {
133 private:
134 const static unsigned short int offset_y;
135 const static unsigned short int offset_x;
136
137 public:
139 Cursor();
141 ~Cursor();
142
148 void goTo(unsigned short int, unsigned short int) const;
154 void goTo(sista::Coordinates) const;
155
164 void eraseScreen(EraseScreen) const;
175 void eraseLine(EraseLine, bool=true) const;
176
186 void move(MoveCursor, unsigned short int) const;
195 void move(MoveCursorDEC) const;
204 void move(MoveCursorSCO) const;
205 };
206};
ANSI escape code utilities and types for terminal formatting.
Coordinates struct header file.
Sista library namespace.
Definition: ansi.cpp:25
EraseScreen
Enumeration for screen erasure options in ANSI escape codes.
Definition: cursor.hpp:58
MoveCursor
Enumeration for cursor movement directions in ANSI escape codes.
Definition: cursor.hpp:85
MoveCursorSCO
Enumeration for SCO-specific cursor movement commands in ANSI escape codes.
Definition: cursor.hpp:114
void clearScreen(bool spaces)
Clears the terminal screen and optionally the scrollback buffer.
Definition: cursor.cpp:22
EraseLine
Enumeration for line erasure options in ANSI escape codes.
Definition: cursor.hpp:72
MoveCursorDEC
Enumeration for DEC-specific cursor movement commands in ANSI escape codes.
Definition: cursor.hpp:102
Represents 2D coordinates with x and y values.
Definition: coordinates.hpp:31
Manages terminal cursor operations.
Definition: cursor.hpp:132
void move(MoveCursor, unsigned short int) const
Moves the cursor in the specified direction by a given number of positions.
Definition: cursor.cpp:57
Cursor()
Constructor that hides the cursor and clears the screen.
Definition: cursor.cpp:30
void eraseLine(EraseLine, bool=true) const
Erases parts of the current line based on the specified EraseLine option.
Definition: cursor.cpp:50
~Cursor()
Destructor that shows the cursor and resets ANSI settings.
Definition: cursor.cpp:34
void goTo(unsigned short int, unsigned short int) const
Moves the cursor to the specified (y, x) coordinates.
Definition: cursor.cpp:40
void eraseScreen(EraseScreen) const
Erases parts of the screen based on the specified EraseScreen option.
Definition: cursor.cpp:47