-
Notifications
You must be signed in to change notification settings - Fork 2
/
ansiCode.py
52 lines (38 loc) · 910 Bytes
/
ansiCode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sys
reset = "\u001b[0m"
bold = "\u001b[1m"
underline = "\u001b[4m"
# Color
red = "\u001b[31m"
green = "\u001b[32m"
black = "\u001b[30m"
# Cursor navigation
def Up(c) :
return "\u001b[%dA" % (c)
def Down(c) :
return "\u001b[%dB" % (c)
def Right(c) :
return "\u001b[%dC" % (c)
def Left(c) :
return "\u001b[%dD" % (c)
def ClearScreen(c) :
return "\u001b[%dJ" % (c)
def ClearLine(c) :
return "\u001b[%dK" % (c)
def SavePosition(n) :
return "\u001b[%s" % (n)
def LoadPosition(n) :
return "\u001b[%s" % (n)
def Print(s) :
sys.stdout.write(s)
sys.stdout.flush()
return
def PrintOnThisLineBold(s) :
Print("%s%s%s%s%s" % (Left(1000), ClearLine(0), bold, s, reset))
return
def PrintOnThisLine(s) :
Print("%s%s%s" % (Left(1000), ClearLine(0), s))
return
def PrintFromLeft(s, l) :
Print("%s%s%s" % (Left(l), ClearLine(0), s))
return