Connect++ 0.5.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
cursor.hpp
1/*
2
3Copyright © 2023-24 Sean Holden. All rights reserved.
4
5*/
6/*
7
8This file is part of Connect++.
9
10Connect++ is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License as published by the
12Free Software Foundation, either version 3 of the License, or (at your
13option) any later version.
14
15Connect++ is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18more details.
19
20You should have received a copy of the GNU General Public License along
21with Connect++. If not, see <https://www.gnu.org/licenses/>.
22
23*/
24
25#ifndef CURSER_HPP
26#define CURSER_HPP
27
28#include<iostream>
29#include<string>
30
31using std::string;
32using std::to_string;
33
34namespace cursor_symbols {
35
54 class Cursor {
55 private:
56 static string ESC;
57 public:
58 Cursor() {};
59
60 static string up(uint8_t n) {
61 string s;
62 if (n >= 1) {
63 s += ESC;
64 s += to_string(n);
65 s += "A";
66 }
67 return s;
68 }
69 static string down(uint8_t n) {
70 string s;
71 if (n >= 1) {
72 s += ESC;
73 s += to_string(n);
74 s += "B";
75 }
76 return s;
77 }
78 static string right(uint8_t n) {
79 string s;
80 if (n >= 1) {
81 s += ESC;
82 s += to_string(n);
83 s += "C";
84 }
85 return s;
86 }
87 static string left(uint8_t n) {
88 string s;
89 if (n >= 1) {
90 s += ESC;
91 s += to_string(n);
92 s += "D";
93 }
94 return s;
95 }
96 static string down_n_lines(uint8_t n) {
97 string s;
98 if (n >= 1) {
99 s += ESC;
100 s += to_string(n);
101 s += "E";
102 }
103 return s;
104 }
105 static string up_n_lines(uint8_t n) {
106 string s;
107 if (n >= 1) {
108 s += ESC;
109 s += to_string(n);
110 s += "F";
111 }
112 return s;
113 }
114 static string to_column(uint8_t n) {
115 string s;
116 if (n >= 1) {
117 s += ESC;
118 s += to_string(n);
119 s += "G";
120 }
121 return s;
122 }
126 static string to(uint8_t n, uint8_t m) {
127 string s;
128 if (n >= 1 && m >= 1) {
129 s += ESC;
130 s += to_string(n);
131 s += ";";
132 s += to_string(m);
133 s += "H";
134 }
135 return s;
136 }
143 static string erase_display(uint8_t n) {
144 string s;
145 if (n >= 0) {
146 s += ESC;
147 s += to_string(n);
148 s += "J";
149 }
150 return s;
151 }
157 static string erase_line(uint8_t n) {
158 string s;
159 if (n >= 0) {
160 s += ESC;
161 s += to_string(n);
162 s += "K";
163 }
164 return s;
165 }
166 };
167}
168
169#endif
Simple library for doing things involving moving the curser when producing terminal output.
Definition cursor.hpp:54
static string erase_display(uint8_t n)
Definition cursor.hpp:143
static string to(uint8_t n, uint8_t m)
Definition cursor.hpp:126
static string erase_line(uint8_t n)
Definition cursor.hpp:157