Connect++ 0.4.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 54 of file cursor.hpp.

Constructor & Destructor Documentation

◆ Cursor()

cursor_symbols::Cursor::Cursor ( )
inline

Definition at line 58 of file cursor.hpp.

58{};

Member Function Documentation

◆ down()

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

Definition at line 69 of file cursor.hpp.

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

◆ down_n_lines()

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

Definition at line 96 of file cursor.hpp.

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

◆ 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 143 of file cursor.hpp.

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

◆ 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 157 of file cursor.hpp.

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

◆ left()

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

Definition at line 87 of file cursor.hpp.

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

◆ right()

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

Definition at line 78 of file cursor.hpp.

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

◆ 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 126 of file cursor.hpp.

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

◆ to_column()

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

Definition at line 114 of file cursor.hpp.

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

◆ up()

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

Definition at line 60 of file cursor.hpp.

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

◆ up_n_lines()

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

Definition at line 105 of file cursor.hpp.

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

Member Data Documentation

◆ ESC

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

Definition at line 56 of file cursor.hpp.


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