ansicli 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ansicli/ansi.py +321 -0
- ansicli/bgbrightcolor.py +12 -0
- ansicli/bgcolor.py +12 -0
- ansicli/brightcolor.py +12 -0
- ansicli/color.py +12 -0
- ansicli/cursor.py +32 -0
- ansicli/erase.py +13 -0
- ansicli/keyboard.py +102 -0
- ansicli/private.py +11 -0
- ansicli/screen.py +18 -0
- ansicli/sgr.py +22 -0
- ansicli-0.0.1.dist-info/METADATA +10 -0
- ansicli-0.0.1.dist-info/RECORD +15 -0
- ansicli-0.0.1.dist-info/WHEEL +4 -0
- ansicli-0.0.1.dist-info/licenses/LICENSE +21 -0
ansicli/ansi.py
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
class Ansi:
|
|
2
|
+
ESC = '\x1B'
|
|
3
|
+
CSI = '\x9B'
|
|
4
|
+
CSI = '\x1B['
|
|
5
|
+
DCS = '\x90'
|
|
6
|
+
OSC = '\x9D'
|
|
7
|
+
|
|
8
|
+
BEL = '\x07' # Terminal bell
|
|
9
|
+
BS = '\x08' # Backspace
|
|
10
|
+
HT = '\x09' # Horizontal Tab
|
|
11
|
+
LF = '\x0A' # Linefeed/newline
|
|
12
|
+
VT = '\x0B' # Vertical tab
|
|
13
|
+
FF = '\x0C' # Formeed
|
|
14
|
+
NP = '\x0C' # New Page
|
|
15
|
+
CR = '\x0D' # Carriage Return
|
|
16
|
+
ESC = '\x1B' # Escape
|
|
17
|
+
DEL = '\x7F' # Delete
|
|
18
|
+
|
|
19
|
+
class AnsiStyle:
|
|
20
|
+
RESET = 0
|
|
21
|
+
|
|
22
|
+
BOLD = 1
|
|
23
|
+
DIM = 2
|
|
24
|
+
ITALIC = 3
|
|
25
|
+
UNDER = 4
|
|
26
|
+
BLINK = 5
|
|
27
|
+
INV = 7
|
|
28
|
+
HIDE = 8
|
|
29
|
+
STRK = 9
|
|
30
|
+
|
|
31
|
+
RBOLD = 22
|
|
32
|
+
RDIM = 22
|
|
33
|
+
RITALIC = 23
|
|
34
|
+
RUNDER = 24
|
|
35
|
+
RBLINK = 25
|
|
36
|
+
RINV = 27
|
|
37
|
+
RHIDE = 28
|
|
38
|
+
RSTRK = 29
|
|
39
|
+
|
|
40
|
+
class AnsiColorBG:
|
|
41
|
+
BLACK = 40
|
|
42
|
+
RED = 41
|
|
43
|
+
GREEN = 42
|
|
44
|
+
YELLOW = 43
|
|
45
|
+
BLUE = 44
|
|
46
|
+
MAGENTA = 45
|
|
47
|
+
CYAN = 46
|
|
48
|
+
WHITE = 47
|
|
49
|
+
DEFAULT = 49
|
|
50
|
+
|
|
51
|
+
BRIGHTBLACK = 100
|
|
52
|
+
BRIGHTRED = 101
|
|
53
|
+
BRIGHTGREEN = 102
|
|
54
|
+
BRIGHTYELLOW = 103
|
|
55
|
+
BRIGHTBLUE = 104
|
|
56
|
+
BRIGHTMAGENTA = 105
|
|
57
|
+
BRIGHTCYAN = 106
|
|
58
|
+
BRIGHTWHITE = 107
|
|
59
|
+
|
|
60
|
+
def col(n:int|str): return f'{Ansi.CSI}{n}m'
|
|
61
|
+
|
|
62
|
+
def col256(n:int|str): return f'{Ansi.CSI}38;5;{n}m'
|
|
63
|
+
def col256bg(n:int|str): return f'{Ansi.CSI}48;5;{n}m'
|
|
64
|
+
|
|
65
|
+
def colrgb(r:int|str,g:int|str,b:int|str): return f'{Ansi.CSI}38;2;{r};{g};{b}m'
|
|
66
|
+
def colrgbbg(r:int|str,g:int|str,b:int|str): return f'{Ansi.CSI}48;2;{r};{g};{b}m'
|
|
67
|
+
|
|
68
|
+
class AnsiColor:
|
|
69
|
+
BLACK = 30
|
|
70
|
+
RED = 31
|
|
71
|
+
GREEN = 32
|
|
72
|
+
YELLOW = 33
|
|
73
|
+
BLUE = 34
|
|
74
|
+
MAGENTA = 35
|
|
75
|
+
CYAN = 36
|
|
76
|
+
WHITE = 37
|
|
77
|
+
DEFAULT = 39
|
|
78
|
+
|
|
79
|
+
BRIGHTBLACK = 90
|
|
80
|
+
BRIGHTRED = 91
|
|
81
|
+
BRIGHTGREEN = 92
|
|
82
|
+
BRIGHTYELLOW = 93
|
|
83
|
+
BRIGHTBLUE = 94
|
|
84
|
+
BRIGHTMAGENTA = 95
|
|
85
|
+
BRIGHTCYAN = 96
|
|
86
|
+
BRIGHTWHITE = 97
|
|
87
|
+
|
|
88
|
+
bg = AnsiColorBG
|
|
89
|
+
|
|
90
|
+
# col256 = _col256
|
|
91
|
+
# col256bg = _col256bg
|
|
92
|
+
# colrgb = _colrgb
|
|
93
|
+
# colrgbbg = _colrgbbg
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _sgr(n:int|str): return f'{Ansi.CSI}{n}m'
|
|
97
|
+
|
|
98
|
+
def sgr(*n:int|str):
|
|
99
|
+
s = f'{Ansi.CSI}'
|
|
100
|
+
r = ''
|
|
101
|
+
for i in n: r+=f'{i}{';' if len(r)/2 < len(n) else ''}'
|
|
102
|
+
return f'{s}{r}m'
|
|
103
|
+
|
|
104
|
+
class AnsiSGR:
|
|
105
|
+
RESET = _sgr(0)
|
|
106
|
+
|
|
107
|
+
BOLD = _sgr(1)
|
|
108
|
+
DIM = _sgr(2)
|
|
109
|
+
ITALIC = _sgr(3)
|
|
110
|
+
UNDER = _sgr(4)
|
|
111
|
+
BLINK = _sgr(5)
|
|
112
|
+
INV = _sgr(7)
|
|
113
|
+
HIDE = _sgr(8)
|
|
114
|
+
STRK = _sgr(9)
|
|
115
|
+
|
|
116
|
+
RBOLD = _sgr(22)
|
|
117
|
+
RDIM = _sgr(22)
|
|
118
|
+
RITALIC = _sgr(23)
|
|
119
|
+
RUNDER = _sgr(24)
|
|
120
|
+
RBLINK = _sgr(25)
|
|
121
|
+
RINV = _sgr(27)
|
|
122
|
+
RHIDE = _sgr(28)
|
|
123
|
+
RSTRK = _sgr(29)
|
|
124
|
+
|
|
125
|
+
# sgr = _sgrgroup
|
|
126
|
+
|
|
127
|
+
def goto(ln:int|str,col:int|str): return f'{Ansi.CSI}{ln};{col}H'
|
|
128
|
+
def up(n:int|str=1): return f'{Ansi.CSI}{n}A'
|
|
129
|
+
def down(n:int|str=1): return f'{Ansi.CSI}{n}B'
|
|
130
|
+
def right(n:int|str=1): return f'{Ansi.CSI}{n}C'
|
|
131
|
+
def left(n:int|str=1): return f'{Ansi.CSI}{n}D'
|
|
132
|
+
def upln(n:int|str): return f'{Ansi.CSI}{n}E'
|
|
133
|
+
def downln(n:int|str): return f'{Ansi.CSI}{n}F'
|
|
134
|
+
def clmn(n:int|str): return f'{Ansi.CSI}{n}G'
|
|
135
|
+
|
|
136
|
+
class AnsiMove:
|
|
137
|
+
HOME = f'{Ansi.CSI}H'
|
|
138
|
+
|
|
139
|
+
UP = f'{Ansi.CSI}A'
|
|
140
|
+
DOWN = f'{Ansi.CSI}B'
|
|
141
|
+
RIGHT = f'{Ansi.CSI}C'
|
|
142
|
+
LEFT = f'{Ansi.CSI}D'
|
|
143
|
+
|
|
144
|
+
SCROLLUP = f'{Ansi.ESC} M'
|
|
145
|
+
SAVE = f'{Ansi.ESC} 7'
|
|
146
|
+
LD = f'{Ansi.ESC} 8'
|
|
147
|
+
SAVESCO = f'{Ansi.CSI}s'
|
|
148
|
+
LDSCO = f'{Ansi.CSI}u'
|
|
149
|
+
|
|
150
|
+
# goto = _goto
|
|
151
|
+
# up = _up
|
|
152
|
+
# down = _down
|
|
153
|
+
# right = _right
|
|
154
|
+
# left = _left
|
|
155
|
+
# upln = _upln
|
|
156
|
+
# downln = _downln
|
|
157
|
+
# col = _col
|
|
158
|
+
|
|
159
|
+
class AnsiErase:
|
|
160
|
+
ER2END = f'{Ansi.CSI}J'
|
|
161
|
+
ER2START = f'{Ansi.CSI}1J'
|
|
162
|
+
ERSCREEN = f'{Ansi.CSI}2J'
|
|
163
|
+
ERSAVED = f'{Ansi.CSI}3J'
|
|
164
|
+
ER2EOL = f'{Ansi.CSI}K'
|
|
165
|
+
ERSTART2CUR = f'{Ansi.CSI}1K'
|
|
166
|
+
ERLNANDRETURN = f'{Ansi.CSI}2K{Ansi.CR}'
|
|
167
|
+
|
|
168
|
+
def resetscreen(n:int|str): return f'{Ansi.CSI}={n}l'
|
|
169
|
+
|
|
170
|
+
class AnsiScreen:
|
|
171
|
+
MONO_TXT_40x25 = f'{Ansi.CSI}=0h'
|
|
172
|
+
COL_TXT_40x25 = f'{Ansi.CSI}=1h'
|
|
173
|
+
MONO_TXT_80x25 = f'{Ansi.CSI}=2h'
|
|
174
|
+
COL_TXT_80x25 = f'{Ansi.CSI}=3h'
|
|
175
|
+
COLOR4_GRPH_320x200 = f'{Ansi.CSI}=4h'
|
|
176
|
+
MONO_GRPH_320x200 = f'{Ansi.CSI}=5h'
|
|
177
|
+
MONO_GRPH_640x200 = f'{Ansi.CSI}=6h'
|
|
178
|
+
LINEWRAP = f'{Ansi.CSI}=7h'
|
|
179
|
+
COLOR_GRPH_320x200 = f'{Ansi.CSI}=13h'
|
|
180
|
+
COLOR16_GRPH_640x200 = f'{Ansi.CSI}=14h'
|
|
181
|
+
MONO2_GRPH_640x350 = f'{Ansi.CSI}=15h'
|
|
182
|
+
COLOR16_GRPH_640x350 = f'{Ansi.CSI}=16h'
|
|
183
|
+
MONO2_GRPH_640x380 = f'{Ansi.CSI}=17h'
|
|
184
|
+
COLOR16_GRPH_640x480 = f'{Ansi.CSI}=18h'
|
|
185
|
+
COLOR256_GRPH_320x200 = f'{Ansi.CSI}=19h'
|
|
186
|
+
|
|
187
|
+
# reset = _resetscreen
|
|
188
|
+
|
|
189
|
+
class AnsiPrivateMode:
|
|
190
|
+
CURINV = f'{Ansi.CSI}?25l'
|
|
191
|
+
CURVIS = f'{Ansi.CSI}?25h'
|
|
192
|
+
|
|
193
|
+
SCREENRESTORE = f'{Ansi.CSI}?47l'
|
|
194
|
+
SAVESCREEN = f'{Ansi.CSI}?25h'
|
|
195
|
+
|
|
196
|
+
SAVE_CURSOR_ENABLE_ALT_BUFF = f'{Ansi.CSI}?1049h'
|
|
197
|
+
RESTORE_CURSORE_DISABLE_ALT_BUFF = f'{Ansi.CSI}?1049l'
|
|
198
|
+
|
|
199
|
+
def _AnsiKBcode(c:str,s:str|int) -> str: return f'{Ansi.CSI}{c};{s}p'
|
|
200
|
+
|
|
201
|
+
class AnsiKBShift:
|
|
202
|
+
pass
|
|
203
|
+
|
|
204
|
+
class AnsiKBCtrl:
|
|
205
|
+
pass
|
|
206
|
+
|
|
207
|
+
class AnsiKBAlt:
|
|
208
|
+
pass
|
|
209
|
+
|
|
210
|
+
class AnsiKB:
|
|
211
|
+
CODE = _AnsiKBcode
|
|
212
|
+
shift = AnsiKBShift
|
|
213
|
+
ctrl = AnsiKBCtrl
|
|
214
|
+
alt = AnsiKBAlt
|
|
215
|
+
|
|
216
|
+
F1 = '0;59'
|
|
217
|
+
F2 = '0;60'
|
|
218
|
+
F3 = '0;61'
|
|
219
|
+
F4 = '0;62'
|
|
220
|
+
F5 = '0;63'
|
|
221
|
+
F6 = '0;64'
|
|
222
|
+
F7 = '0;65'
|
|
223
|
+
F8 = '0;66'
|
|
224
|
+
F9 = '0;67'
|
|
225
|
+
F10 = '0;68'
|
|
226
|
+
F11 = '0;133'
|
|
227
|
+
F12 = '0;134'
|
|
228
|
+
|
|
229
|
+
NHOME = '0;71'
|
|
230
|
+
NUP = '0;72'
|
|
231
|
+
NPGUP = '0;73'
|
|
232
|
+
NLEFT = '0;75'
|
|
233
|
+
NRIGHT = '0;77'
|
|
234
|
+
NEND = '0;79'
|
|
235
|
+
NDOWN = '0;80'
|
|
236
|
+
NPGDOWN = '0;81'
|
|
237
|
+
NINS = '0;82'
|
|
238
|
+
NDEL = '0;83'
|
|
239
|
+
|
|
240
|
+
HOME = '224;71'
|
|
241
|
+
UP = '224;72'
|
|
242
|
+
PGUP = '224;73'
|
|
243
|
+
LEFT = '224;75'
|
|
244
|
+
RIGHT = '224;77'
|
|
245
|
+
END = '224;79'
|
|
246
|
+
DOWN = '224;80'
|
|
247
|
+
PGDOWN = '224;81'
|
|
248
|
+
INS = '224;82'
|
|
249
|
+
DEL = '224;83'
|
|
250
|
+
|
|
251
|
+
BACKSPACE = '8'
|
|
252
|
+
ENTER = '13'
|
|
253
|
+
TAB = '9'
|
|
254
|
+
NULL = '0;3'
|
|
255
|
+
|
|
256
|
+
A = '97'
|
|
257
|
+
B = '98'
|
|
258
|
+
C = '99'
|
|
259
|
+
D = '100'
|
|
260
|
+
E = '101'
|
|
261
|
+
F = '102'
|
|
262
|
+
G = '103'
|
|
263
|
+
H = '104'
|
|
264
|
+
I = '105'
|
|
265
|
+
J = '106'
|
|
266
|
+
K = '107'
|
|
267
|
+
L = '108'
|
|
268
|
+
M = '109'
|
|
269
|
+
N = '110'
|
|
270
|
+
O = '111'
|
|
271
|
+
P = '112'
|
|
272
|
+
Q = '113'
|
|
273
|
+
R = '114'
|
|
274
|
+
S = '115'
|
|
275
|
+
T = '116'
|
|
276
|
+
U = '117'
|
|
277
|
+
V = '118'
|
|
278
|
+
W = '119'
|
|
279
|
+
X = '120'
|
|
280
|
+
Y = '121'
|
|
281
|
+
Z = '122'
|
|
282
|
+
|
|
283
|
+
ONE = '49'
|
|
284
|
+
TWO = '50'
|
|
285
|
+
THREE = '51'
|
|
286
|
+
FOUR = '52'
|
|
287
|
+
FIVE = '53'
|
|
288
|
+
SIX = '54'
|
|
289
|
+
SEVEN = '55'
|
|
290
|
+
EIGHT = '56'
|
|
291
|
+
NINE = '57'
|
|
292
|
+
ZERO = '48'
|
|
293
|
+
|
|
294
|
+
HYPHEN = '45'
|
|
295
|
+
EQUALS = '61'
|
|
296
|
+
RBRACK = '91'
|
|
297
|
+
LBRACK = '93'
|
|
298
|
+
SPACE = '92' #????
|
|
299
|
+
SEMICOLON = '59'
|
|
300
|
+
APOSTROPHE = '39'
|
|
301
|
+
COMMA = '44'
|
|
302
|
+
PERIOD = '46'
|
|
303
|
+
FSLASH = '47'
|
|
304
|
+
BTICK = '96'
|
|
305
|
+
|
|
306
|
+
NENTER = '13'
|
|
307
|
+
NFSLASH = '47'
|
|
308
|
+
NSTAR = '42'
|
|
309
|
+
NHYPHEN = '45'
|
|
310
|
+
NPLUS = '43'
|
|
311
|
+
NFIVE = '0;76'
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
# Style = AnsiStyle
|
|
315
|
+
# SGR = AnsiSGR
|
|
316
|
+
# Color = AnsiColor
|
|
317
|
+
# Move = AnsiMove
|
|
318
|
+
# Erase = AnsiErase
|
|
319
|
+
# Screen = AnsiScreen
|
|
320
|
+
# Private = AnsiPrivateMode
|
|
321
|
+
# KB = AnsiKB
|
ansicli/bgbrightcolor.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from src.ansicli.ansi import AnsiColorBG, col
|
|
2
|
+
|
|
3
|
+
class BgBrightColor:
|
|
4
|
+
BLACK = col(AnsiColorBG.BRIGHTBLACK)
|
|
5
|
+
RED = col(AnsiColorBG.BRIGHTRED)
|
|
6
|
+
GREEN = col(AnsiColorBG.BRIGHTGREEN)
|
|
7
|
+
YELLOW = col(AnsiColorBG.BRIGHTYELLOW)
|
|
8
|
+
BLUE = col(AnsiColorBG.BRIGHTBLUE)
|
|
9
|
+
MAGENTA = col(AnsiColorBG.BRIGHTMAGENTA)
|
|
10
|
+
CYAN = col(AnsiColorBG.BRIGHTCYAN)
|
|
11
|
+
WHITE = col(AnsiColorBG.BRIGHTWHITE)
|
|
12
|
+
DEFAULT = col(AnsiColorBG.DEFAULT)
|
ansicli/bgcolor.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from src.ansicli.ansi import AnsiColorBG, col
|
|
2
|
+
|
|
3
|
+
class BgColor:
|
|
4
|
+
BLACK = col(AnsiColorBG.BLACK)
|
|
5
|
+
RED = col(AnsiColorBG.RED)
|
|
6
|
+
GREEN = col(AnsiColorBG.GREEN)
|
|
7
|
+
YELLOW = col(AnsiColorBG.YELLOW)
|
|
8
|
+
BLUE = col(AnsiColorBG.BLUE)
|
|
9
|
+
MAGENTA = col(AnsiColorBG.MAGENTA)
|
|
10
|
+
CYAN = col(AnsiColorBG.CYAN)
|
|
11
|
+
WHITE = col(AnsiColorBG.WHITE)
|
|
12
|
+
DEFAULT = col(AnsiColorBG.DEFAULT)
|
ansicli/brightcolor.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from src.ansicli.ansi import AnsiColor, col
|
|
2
|
+
|
|
3
|
+
class BrightColor:
|
|
4
|
+
BLACK = col(AnsiColor.BRIGHTBLACK)
|
|
5
|
+
RED = col(AnsiColor.BRIGHTRED)
|
|
6
|
+
GREEN = col(AnsiColor.BRIGHTGREEN)
|
|
7
|
+
YELLOW = col(AnsiColor.BRIGHTYELLOW)
|
|
8
|
+
BLUE = col(AnsiColor.BRIGHTBLUE)
|
|
9
|
+
MAGENTA = col(AnsiColor.BRIGHTMAGENTA)
|
|
10
|
+
CYAN = col(AnsiColor.BRIGHTCYAN)
|
|
11
|
+
WHITE = col(AnsiColor.BRIGHTWHITE)
|
|
12
|
+
DEFAULT = col(AnsiColor.DEFAULT)
|
ansicli/color.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from src.ansicli.ansi import AnsiColor, col
|
|
2
|
+
|
|
3
|
+
class Color:
|
|
4
|
+
BLACK = col(AnsiColor.BLACK)
|
|
5
|
+
RED = col(AnsiColor.RED)
|
|
6
|
+
GREEN = col(AnsiColor.GREEN)
|
|
7
|
+
YELLOW = col(AnsiColor.YELLOW)
|
|
8
|
+
BLUE = col(AnsiColor.BLUE)
|
|
9
|
+
MAGENTA = col(AnsiColor.MAGENTA)
|
|
10
|
+
CYAN = col(AnsiColor.CYAN)
|
|
11
|
+
WHITE = col(AnsiColor.WHITE)
|
|
12
|
+
DEFAULT = col(AnsiColor.DEFAULT)
|
ansicli/cursor.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from src.ansicli.ansi import Ansi
|
|
2
|
+
|
|
3
|
+
class Cursor:
|
|
4
|
+
@staticmethod
|
|
5
|
+
def goto(ln:int|str,col:int|str): return f'{Ansi.CSI}{ln};{col}H'
|
|
6
|
+
@staticmethod
|
|
7
|
+
def up(n:int|str=1): return f'{Ansi.CSI}{n}A'
|
|
8
|
+
@staticmethod
|
|
9
|
+
def down(n:int|str=1): return f'{Ansi.CSI}{n}B'
|
|
10
|
+
@staticmethod
|
|
11
|
+
def right(n:int|str=1): return f'{Ansi.CSI}{n}C'
|
|
12
|
+
@staticmethod
|
|
13
|
+
def left(n:int|str=1): return f'{Ansi.CSI}{n}D'
|
|
14
|
+
@staticmethod
|
|
15
|
+
def upln(n:int|str): return f'{Ansi.CSI}{n}E'
|
|
16
|
+
@staticmethod
|
|
17
|
+
def downln(n:int|str): return f'{Ansi.CSI}{n}F'
|
|
18
|
+
@staticmethod
|
|
19
|
+
def clmn(n:int|str): return f'{Ansi.CSI}{n}G'
|
|
20
|
+
|
|
21
|
+
HOME = f'{Ansi.CSI}H'
|
|
22
|
+
|
|
23
|
+
UP = f'{Ansi.CSI}A'
|
|
24
|
+
DOWN = f'{Ansi.CSI}B'
|
|
25
|
+
RIGHT = f'{Ansi.CSI}C'
|
|
26
|
+
LEFT = f'{Ansi.CSI}D'
|
|
27
|
+
|
|
28
|
+
SCROLLUP = f'{Ansi.ESC} M'
|
|
29
|
+
SAVE = f'{Ansi.ESC} 7'
|
|
30
|
+
LD = f'{Ansi.ESC} 8'
|
|
31
|
+
SAVESCO = f'{Ansi.CSI}s'
|
|
32
|
+
LDSCO = f'{Ansi.CSI}u'
|
ansicli/erase.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from src.ansicli.ansi import Ansi
|
|
2
|
+
|
|
3
|
+
class Erase:
|
|
4
|
+
ER2END = f'{Ansi.CSI}J'
|
|
5
|
+
ER2START = f'{Ansi.CSI}1J'
|
|
6
|
+
ERSCREEN = f'{Ansi.CSI}2J'
|
|
7
|
+
ERSAVED = f'{Ansi.CSI}3J'
|
|
8
|
+
ER2EOL = f'{Ansi.CSI}K'
|
|
9
|
+
ERSTART2CUR = f'{Ansi.CSI}1K'
|
|
10
|
+
ERLNANDRETURN = f'{Ansi.CSI}2K{Ansi.CR}'
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def resetscreen(n:int|str): return f'{Ansi.CSI}={n}l'
|
ansicli/keyboard.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
from src.ansicli.ansi import Ansi
|
|
2
|
+
|
|
3
|
+
class AnsiKB:
|
|
4
|
+
@staticmethod
|
|
5
|
+
def _AnsiKBcode(c:str,s:str|int) -> str: return f'{Ansi.CSI}{c};{s}p'
|
|
6
|
+
|
|
7
|
+
F1 = '0;59'
|
|
8
|
+
F2 = '0;60'
|
|
9
|
+
F3 = '0;61'
|
|
10
|
+
F4 = '0;62'
|
|
11
|
+
F5 = '0;63'
|
|
12
|
+
F6 = '0;64'
|
|
13
|
+
F7 = '0;65'
|
|
14
|
+
F8 = '0;66'
|
|
15
|
+
F9 = '0;67'
|
|
16
|
+
F10 = '0;68'
|
|
17
|
+
F11 = '0;133'
|
|
18
|
+
F12 = '0;134'
|
|
19
|
+
|
|
20
|
+
NHOME = '0;71'
|
|
21
|
+
NUP = '0;72'
|
|
22
|
+
NPGUP = '0;73'
|
|
23
|
+
NLEFT = '0;75'
|
|
24
|
+
NRIGHT = '0;77'
|
|
25
|
+
NEND = '0;79'
|
|
26
|
+
NDOWN = '0;80'
|
|
27
|
+
NPGDOWN = '0;81'
|
|
28
|
+
NINS = '0;82'
|
|
29
|
+
NDEL = '0;83'
|
|
30
|
+
|
|
31
|
+
HOME = '224;71'
|
|
32
|
+
UP = '224;72'
|
|
33
|
+
PGUP = '224;73'
|
|
34
|
+
LEFT = '224;75'
|
|
35
|
+
RIGHT = '224;77'
|
|
36
|
+
END = '224;79'
|
|
37
|
+
DOWN = '224;80'
|
|
38
|
+
PGDOWN = '224;81'
|
|
39
|
+
INS = '224;82'
|
|
40
|
+
DEL = '224;83'
|
|
41
|
+
|
|
42
|
+
BACKSPACE = '8'
|
|
43
|
+
ENTER = '13'
|
|
44
|
+
TAB = '9'
|
|
45
|
+
NULL = '0;3'
|
|
46
|
+
|
|
47
|
+
A = '97'
|
|
48
|
+
B = '98'
|
|
49
|
+
C = '99'
|
|
50
|
+
D = '100'
|
|
51
|
+
E = '101'
|
|
52
|
+
F = '102'
|
|
53
|
+
G = '103'
|
|
54
|
+
H = '104'
|
|
55
|
+
I = '105'
|
|
56
|
+
J = '106'
|
|
57
|
+
K = '107'
|
|
58
|
+
L = '108'
|
|
59
|
+
M = '109'
|
|
60
|
+
N = '110'
|
|
61
|
+
O = '111'
|
|
62
|
+
P = '112'
|
|
63
|
+
Q = '113'
|
|
64
|
+
R = '114'
|
|
65
|
+
S = '115'
|
|
66
|
+
T = '116'
|
|
67
|
+
U = '117'
|
|
68
|
+
V = '118'
|
|
69
|
+
W = '119'
|
|
70
|
+
X = '120'
|
|
71
|
+
Y = '121'
|
|
72
|
+
Z = '122'
|
|
73
|
+
|
|
74
|
+
ONE = '49'
|
|
75
|
+
TWO = '50'
|
|
76
|
+
THREE = '51'
|
|
77
|
+
FOUR = '52'
|
|
78
|
+
FIVE = '53'
|
|
79
|
+
SIX = '54'
|
|
80
|
+
SEVEN = '55'
|
|
81
|
+
EIGHT = '56'
|
|
82
|
+
NINE = '57'
|
|
83
|
+
ZERO = '48'
|
|
84
|
+
|
|
85
|
+
HYPHEN = '45'
|
|
86
|
+
EQUALS = '61'
|
|
87
|
+
RBRACK = '91'
|
|
88
|
+
LBRACK = '93'
|
|
89
|
+
SPACE = '92' #????
|
|
90
|
+
SEMICOLON = '59'
|
|
91
|
+
APOSTROPHE = '39'
|
|
92
|
+
COMMA = '44'
|
|
93
|
+
PERIOD = '46'
|
|
94
|
+
FSLASH = '47'
|
|
95
|
+
BTICK = '96'
|
|
96
|
+
|
|
97
|
+
NENTER = '13'
|
|
98
|
+
NFSLASH = '47'
|
|
99
|
+
NSTAR = '42'
|
|
100
|
+
NHYPHEN = '45'
|
|
101
|
+
NPLUS = '43'
|
|
102
|
+
NFIVE = '0;76'
|
ansicli/private.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from src.ansicli.ansi import Ansi
|
|
2
|
+
|
|
3
|
+
class Private:
|
|
4
|
+
CURINV = f'{Ansi.CSI}?25l'
|
|
5
|
+
CURVIS = f'{Ansi.CSI}?25h'
|
|
6
|
+
|
|
7
|
+
SCREENRESTORE = f'{Ansi.CSI}?47l'
|
|
8
|
+
SAVESCREEN = f'{Ansi.CSI}?25h'
|
|
9
|
+
|
|
10
|
+
SAVE_CURSOR_ENABLE_ALT_BUFF = f'{Ansi.CSI}?1049h'
|
|
11
|
+
RESTORE_CURSORE_DISABLE_ALT_BUFF = f'{Ansi.CSI}?1049l'
|
ansicli/screen.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from src.ansicli.ansi import Ansi
|
|
2
|
+
|
|
3
|
+
class Screen:
|
|
4
|
+
MONO_TXT_40x25 = f'{Ansi.CSI}=0h'
|
|
5
|
+
COL_TXT_40x25 = f'{Ansi.CSI}=1h'
|
|
6
|
+
MONO_TXT_80x25 = f'{Ansi.CSI}=2h'
|
|
7
|
+
COL_TXT_80x25 = f'{Ansi.CSI}=3h'
|
|
8
|
+
COLOR4_GRPH_320x200 = f'{Ansi.CSI}=4h'
|
|
9
|
+
MONO_GRPH_320x200 = f'{Ansi.CSI}=5h'
|
|
10
|
+
MONO_GRPH_640x200 = f'{Ansi.CSI}=6h'
|
|
11
|
+
LINEWRAP = f'{Ansi.CSI}=7h'
|
|
12
|
+
COLOR_GRPH_320x200 = f'{Ansi.CSI}=13h'
|
|
13
|
+
COLOR16_GRPH_640x200 = f'{Ansi.CSI}=14h'
|
|
14
|
+
MONO2_GRPH_640x350 = f'{Ansi.CSI}=15h'
|
|
15
|
+
COLOR16_GRPH_640x350 = f'{Ansi.CSI}=16h'
|
|
16
|
+
MONO2_GRPH_640x380 = f'{Ansi.CSI}=17h'
|
|
17
|
+
COLOR16_GRPH_640x480 = f'{Ansi.CSI}=18h'
|
|
18
|
+
COLOR256_GRPH_320x200 = f'{Ansi.CSI}=19h'
|
ansicli/sgr.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from src.ansicli.ansi import _sgr
|
|
2
|
+
|
|
3
|
+
class SGR:
|
|
4
|
+
RESET = _sgr(0)
|
|
5
|
+
|
|
6
|
+
BOLD = _sgr(1)
|
|
7
|
+
DIM = _sgr(2)
|
|
8
|
+
ITALIC = _sgr(3)
|
|
9
|
+
UNDER = _sgr(4)
|
|
10
|
+
BLINK = _sgr(5)
|
|
11
|
+
INV = _sgr(7)
|
|
12
|
+
HIDE = _sgr(8)
|
|
13
|
+
STRK = _sgr(9)
|
|
14
|
+
|
|
15
|
+
RBOLD = _sgr(22)
|
|
16
|
+
RDIM = _sgr(22)
|
|
17
|
+
RITALIC = _sgr(23)
|
|
18
|
+
RUNDER = _sgr(24)
|
|
19
|
+
RBLINK = _sgr(25)
|
|
20
|
+
RINV = _sgr(27)
|
|
21
|
+
RHIDE = _sgr(28)
|
|
22
|
+
RSTRK = _sgr(29)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ansicli
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: ANSI CLI stuff
|
|
5
|
+
Author: Unwholly
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.9
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ansicli/ansi.py,sha256=YjWVXAClZE_bX8pqlqGvMruy6XgzYDiWRtxTdYJfGK0,6642
|
|
2
|
+
ansicli/bgbrightcolor.py,sha256=h1hW2ss1NU4dw1T_BHT7iVScKteoV6Z-h21ewFmo8rI,443
|
|
3
|
+
ansicli/bgcolor.py,sha256=g-CNKtO23ss0r8cPaJexNDkgzPUkDslomQ2gdkwYxvo,389
|
|
4
|
+
ansicli/brightcolor.py,sha256=ICw9L-ldj-QcgSeijDnFwbjrr4zzJWyjwzx6VtArX3E,421
|
|
5
|
+
ansicli/color.py,sha256=ZE3Evb3Pwzz1LYS02-1nSa5hrd6wR_QyJNtC8P-ARoo,367
|
|
6
|
+
ansicli/cursor.py,sha256=kQj9tkVgBnxwKzO1ojkVSDBgNX_najPidY_k3KxzoEg,927
|
|
7
|
+
ansicli/erase.py,sha256=4YGdHprwIGPUwngGR5wuUf2WtpZqNzK9Oq2XVQBbG9Q,363
|
|
8
|
+
ansicli/keyboard.py,sha256=yn1ff9rHRSnXFCtPW7hOazXMQh9L9-AX1ZCLPJ7Nhvk,1742
|
|
9
|
+
ansicli/private.py,sha256=OCLqrVPRMI9sb7GhUa8I6PsERTmMvsjY2P5mI3N5fgA,309
|
|
10
|
+
ansicli/screen.py,sha256=iFoqSr_q1rbPfDF-7Q9VdHkFPu9mSWOx1r48i7BtGwg,682
|
|
11
|
+
ansicli/sgr.py,sha256=oTGyeO3Tp21NvTJZRl5pqeJf0lD1ON4S3dJh8OYNZk0,412
|
|
12
|
+
ansicli-0.0.1.dist-info/METADATA,sha256=mCN-gA0LV6nS8HIIYLFpUlbU74HIdqFqwrEkVHs2bKE,256
|
|
13
|
+
ansicli-0.0.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
14
|
+
ansicli-0.0.1.dist-info/licenses/LICENSE,sha256=je3tujlSRohOTT7Lv0tv8PQtbF2dqO-gTz3joiAR0YA,1086
|
|
15
|
+
ansicli-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Unwholly
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|