This repository was archived by the owner on Nov 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcursor.hpp
More file actions
89 lines (78 loc) · 1.67 KB
/
cursor.hpp
File metadata and controls
89 lines (78 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "constants.hpp"
#include "matrix.hpp"
class Field;
class Cursor {
public:
int x;
int y;
Field *field;
Cursor() {
this->x = 0;
this->y = 0;
}
Cursor(Field *field) {
this->x = 0;
this->y = 0;
this->field = field;
}
Cursor(int x, int y) {
this->x = x;
this->y = y;
}
Cursor(int x, int y, Field *field) {
this->x = x;
this->y = y;
this->field = field;
}
void moveUp(int n) {
std::cout << CSI << n << CUU_;
this->y -= n;
}
void moveDown(int n) {
std::cout << CSI << n << CUD_;
this->y += n;
}
void moveForward(int n) {
std::cout << CSI << n << CUF_;
this->x += n;
}
void moveBackward(int n) {
std::cout << CSI << n << CUB_;
this->x -= n;
}
void nextLine(int n) {
std::cout << CSI << n << CNL_;
this->y += n;
}
void previousLine(int n) {
std::cout << CSI << n << CPL_;
this->y -= n;
}
void horizontalAbsolute(int x) {
std::cout << CSI << x << CHA_;
this->x = x;
}
void verticalAbsolute(int y) {
std::cout << CSI << y << VPA_;
this->y = y;
}
void position(int x, int y) {
std::cout << CSI << y << ';' << x << CUP_;
this->x = x;
this->y = y;
}
void savePosition() {
std::cout << CSI << ANSISYSSC;
}
void restorePosition() {
std::cout << CSI << ANSISYSRC;
}
void backspace() {
std::cout << BS;
this->x--;
};
void deleteChar() {
std::cout << DEL;
};
void print(char c);
};