-
Notifications
You must be signed in to change notification settings - Fork 2
/
csi.cpp
110 lines (94 loc) · 1.77 KB
/
csi.cpp
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "csi.hpp"
std::string csi::enable(style style){
return prefix + std::to_string(
(int)style + (int)style::enable_offset
) + "m";
}
std::string csi::disable(style style){
return prefix + std::to_string(
(int)style + (int)style::disable_offset
) + "m";
}
std::string csi::foreground(color color){
return prefix + std::to_string(
(int)color + (int)color::foreground_offset
) + "m";
}
std::string csi::background(color color){
return prefix + std::to_string(
(int)color + (int)color::background_offset
) + "m";
}
std::string csi::cursor_up(int cells){
return {
prefix +
std::to_string(cells) + "A"
};
}
std::string csi::cursor_down(int cells){
return {
prefix +
std::to_string(cells) + "B"
};
}
std::string csi::cursor_forward(int cells){
return {
prefix +
std::to_string(cells) + "C"
};
}
std::string csi::cursor_back(int cells){
return {
prefix +
std::to_string(cells) + "D"
};
}
std::string csi::cursor_next_line(int lines){
return {
prefix +
std::to_string(lines) + "E"
};
}
std::string csi::cursor_previous_line(int lines){
return {
prefix +
std::to_string(lines) + "F"
};
}
std::string csi::cursor_position(int row, int column){
return {
prefix +
std::to_string(row) + ";" +
std::to_string(column) + "H"
};
}
std::string csi::erase_display(erase_mode mode){
return {
prefix +
std::to_string((int)mode) + "J"
};
}
std::string csi::erase_line(erase_mode mode){
return {
prefix +
std::to_string((int)mode) + "K"
};
}
std::string csi::scroll_up(int lines){
return {
prefix +
std::to_string(lines) + "S"
};
}
std::string csi::scroll_down(int lines){
return {
prefix +
std::to_string(lines) + "T"
};
}
std::string csi::select_graphic_rendition(int code){
return {
prefix +
std::to_string(code) + "m"
};
}