-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconyo.cpp
More file actions
73 lines (58 loc) · 1.11 KB
/
conyo.cpp
File metadata and controls
73 lines (58 loc) · 1.11 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
#include "conyo.h"
#include <iostream>
#include <cmath>
using namespace std;
namespace cy
{
// Escape sequence
#define CSI "\x1b["
void cursorStep(CYCurDir dir, int n)
{
cout << CSI << n << char('A' + int(dir)) << std::flush;
}
// Move cursor relatively in Y direction, sets X to 1
void cursorMoveVert(int n)
{
cout << CSI << n << (n < 0 ? "E" : "F") << std::flush;
}
// Move cursor absolutely in X direction
void cursorSetCol(int n)
{
cout << CSI << (n + 1) << "G" << std::flush;
}
// Move cursor to absolute position
void cursorSetPos(int col, int row)
{
cout << CSI << int(row * 0.5 +1) << ";" << (col+1) << "H" << std::flush;
}
// Save cursor position
void cursorSavePos()
{
cout << CSI "s" << std::flush;
}
// Restore saved cursor position
void cursorRestorePos()
{
cout << CSI "u" << std::flush;
}
// Hide cursor
void cursorHide()
{
cout << CSI "?l" << std::flush;
}
// Show cursor
void cursorShow()
{
cout << CSI "?h" << std::flush;
}
//Clear screen
void screenClear()
{
cout << CSI "2J" << std::flush;
}
// set fg color
void screenFGColor(int n)
{
cout << CSI << n << "m" << std::flush;
}
}