Connect++ 0.6.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#include<cstdint>
31
32using std::string;
33using std::to_string;
34
35namespace cursor_symbols {
36
55 class Cursor {
56 private:
57 static string ESC;
58 public:
59 Cursor() {};
60
61 static string up(uint8_t n) {
62 string s;
63 if (n >= 1) {
64 s += ESC;
65 s += to_string(n);
66 s += "A";
67 }
68 return s;
69 }
70 static string down(uint8_t n) {
71 string s;
72 if (n >= 1) {
73 s += ESC;
74 s += to_string(n);
75 s += "B";
76 }
77 return s;
78 }
79 static string right(uint8_t n) {
80 string s;
81 if (n >= 1) {
82 s += ESC;
83 s += to_string(n);
84 s += "C";
85 }
86 return s;
87 }
88 static string left(uint8_t n) {
89 string s;
90 if (n >= 1) {
91 s += ESC;
92 s += to_string(n);
93 s += "D";
94 }
95 return s;
96 }
97 static string down_n_lines(uint8_t n) {
98 string s;
99 if (n >= 1) {
100 s += ESC;
101 s += to_string(n);
102 s += "E";
103 }
104 return s;
105 }
106 static string up_n_lines(uint8_t n) {
107 string s;
108 if (n >= 1) {
109 s += ESC;
110 s += to_string(n);
111 s += "F";
112 }
113 return s;
114 }
115 static string to_column(uint8_t n) {
116 string s;
117 if (n >= 1) {
118 s += ESC;
119 s += to_string(n);
120 s += "G";
121 }
122 return s;
123 }
127 static string to(uint8_t n, uint8_t m) {
128 string s;
129 if (n >= 1 && m >= 1) {
130 s += ESC;
131 s += to_string(n);
132 s += ";";
133 s += to_string(m);
134 s += "H";
135 }
136 return s;
137 }
144 static string erase_display(uint8_t n) {
145 string s;
146 if (n >= 0) {
147 s += ESC;
148 s += to_string(n);
149 s += "J";
150 }
151 return s;
152 }
158 static string erase_line(uint8_t n) {
159 string s;
160 if (n >= 0) {
161 s += ESC;
162 s += to_string(n);
163 s += "K";
164 }
165 return s;
166 }
167 };
168}
169
170#endif
Simple library for doing things involving moving the curser when producing terminal output.
Definition cursor.hpp:55
static string erase_display(uint8_t n)
Definition cursor.hpp:144
static string to(uint8_t n, uint8_t m)
Definition cursor.hpp:127
static string erase_line(uint8_t n)
Definition cursor.hpp:158