Connect++ 0.6.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
cursor_symbols::Cursor Class Reference

Simple library for doing things involving moving the curser when producing terminal output. More...

#include <cursor.hpp>

Collaboration diagram for cursor_symbols::Cursor:

Static Public Member Functions

static string up (uint8_t n)
 
static string down (uint8_t n)
 
static string right (uint8_t n)
 
static string left (uint8_t n)
 
static string down_n_lines (uint8_t n)
 
static string up_n_lines (uint8_t n)
 
static string to_column (uint8_t n)
 
static string to (uint8_t n, uint8_t m)
 
static string erase_display (uint8_t n)
 
static string erase_line (uint8_t n)
 

Static Private Attributes

static string ESC = "\033["
 

Detailed Description

Simple library for doing things involving moving the curser when producing terminal output.

This is achieved using ANSI escape codes, see:

https://en.wikipedia.org/wiki/ANSI_escape_code#CSIsection

That page is hard to decipher. Suffice to say that the left-hand-side of the table for "CSI introducers" is interpreted as follows:

\033[ n A - move curser n places up. \033[ n B - move curser n places down.

... and so on. Colours are then the "Set Graphic Rendition" part that appears as "CSI n m" and translates to ""\033[ n m".

Definition at line 55 of file cursor.hpp.

Constructor & Destructor Documentation

◆ Cursor()

cursor_symbols::Cursor::Cursor ( )
inline

Definition at line 59 of file cursor.hpp.

59{};

Member Function Documentation

◆ down()

static string cursor_symbols::Cursor::down ( uint8_t n)
inlinestatic

Definition at line 70 of file cursor.hpp.

70 {
71 string s;
72 if (n >= 1) {
73 s += ESC;
74 s += to_string(n);
75 s += "B";
76 }
77 return s;
78 }

◆ down_n_lines()

static string cursor_symbols::Cursor::down_n_lines ( uint8_t n)
inlinestatic

Definition at line 97 of file cursor.hpp.

97 {
98 string s;
99 if (n >= 1) {
100 s += ESC;
101 s += to_string(n);
102 s += "E";
103 }
104 return s;
105 }

◆ erase_display()

static string cursor_symbols::Cursor::erase_display ( uint8_t n)
inlinestatic

0 - to screen end. 1 - to screen beginning. 2 - whole screen. 3 - 2 + erase scrolling back buffer.

Definition at line 144 of file cursor.hpp.

144 {
145 string s;
146 if (n >= 0) {
147 s += ESC;
148 s += to_string(n);
149 s += "J";
150 }
151 return s;
152 }

◆ erase_line()

static string cursor_symbols::Cursor::erase_line ( uint8_t n)
inlinestatic

0 - to end. 1 - to beginning. 2 - whole line.

Definition at line 158 of file cursor.hpp.

158 {
159 string s;
160 if (n >= 0) {
161 s += ESC;
162 s += to_string(n);
163 s += "K";
164 }
165 return s;
166 }

◆ left()

static string cursor_symbols::Cursor::left ( uint8_t n)
inlinestatic

Definition at line 88 of file cursor.hpp.

88 {
89 string s;
90 if (n >= 1) {
91 s += ESC;
92 s += to_string(n);
93 s += "D";
94 }
95 return s;
96 }

◆ right()

static string cursor_symbols::Cursor::right ( uint8_t n)
inlinestatic

Definition at line 79 of file cursor.hpp.

79 {
80 string s;
81 if (n >= 1) {
82 s += ESC;
83 s += to_string(n);
84 s += "C";
85 }
86 return s;
87 }

◆ to()

static string cursor_symbols::Cursor::to ( uint8_t n,
uint8_t m )
inlinestatic

Origin is top left corner. n is row and m is column.

Definition at line 127 of file cursor.hpp.

127 {
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 }

◆ to_column()

static string cursor_symbols::Cursor::to_column ( uint8_t n)
inlinestatic

Definition at line 115 of file cursor.hpp.

115 {
116 string s;
117 if (n >= 1) {
118 s += ESC;
119 s += to_string(n);
120 s += "G";
121 }
122 return s;
123 }

◆ up()

static string cursor_symbols::Cursor::up ( uint8_t n)
inlinestatic

Definition at line 61 of file cursor.hpp.

61 {
62 string s;
63 if (n >= 1) {
64 s += ESC;
65 s += to_string(n);
66 s += "A";
67 }
68 return s;
69 }

◆ up_n_lines()

static string cursor_symbols::Cursor::up_n_lines ( uint8_t n)
inlinestatic

Definition at line 106 of file cursor.hpp.

106 {
107 string s;
108 if (n >= 1) {
109 s += ESC;
110 s += to_string(n);
111 s += "F";
112 }
113 return s;
114 }

Member Data Documentation

◆ ESC

string cursor_symbols::Cursor::ESC = "\033["
staticprivate

Definition at line 57 of file cursor.hpp.


The documentation for this class was generated from the following files: