first commit
This commit is contained in:
commit
9f817ff112
63
ansi_escape.py
Normal file
63
ansi_escape.py
Normal file
@ -0,0 +1,63 @@
|
||||
def bell():
|
||||
print("\u0007")
|
||||
|
||||
def color(mode, ground, *args):
|
||||
return_string = "\u001b["
|
||||
if mode == "bright":
|
||||
return_string += "1;"
|
||||
|
||||
if ground == "fg":
|
||||
return_string += "3"
|
||||
elif ground == "bg":
|
||||
return_string += "4"
|
||||
|
||||
if mode == "256":
|
||||
return_string += "8;5;"
|
||||
return_string += args[0]
|
||||
return_string += "m"
|
||||
return return_string
|
||||
|
||||
elif mode == "rgb":
|
||||
return_string += "8;2;"
|
||||
return_string = return_string + args[0] + ";" + args[1] + ";" +args[2]
|
||||
return_string += "m"
|
||||
return return_string
|
||||
|
||||
elif mode == "normal":
|
||||
color_chart = {
|
||||
"black": "0",
|
||||
"red": "1",
|
||||
"green": "2",
|
||||
"yellow": "3",
|
||||
"blue": "4",
|
||||
"magenta": "5",
|
||||
"cyan": "6",
|
||||
"white": "7"
|
||||
}
|
||||
a = color_chart[args[0]]
|
||||
return_string += a
|
||||
return_string += "m"
|
||||
return return_string
|
||||
|
||||
bell = "\u0007"
|
||||
backspace = "\u0008"
|
||||
escape = "\u001b"
|
||||
csi = escape + "["
|
||||
reset = csi + "0m"
|
||||
normal = reset
|
||||
bold = csi + "1m"
|
||||
underline = csi + "4m"
|
||||
blink = csi + "5m"
|
||||
invert = csi + "7m"
|
||||
strike = csi + "9m"
|
||||
normal_intensity = csi + "22m"
|
||||
#no_italic = csi + "23m" #not vidley supported
|
||||
no_blink = csi + "25m"
|
||||
no_strike = csi + "29m"
|
||||
reset_fg = csi + "39m"
|
||||
reset_bg = csi + "49m"
|
||||
overline = csi + "53m"
|
||||
no_overline = csi + "55m"
|
||||
frame = csi + "51m"
|
||||
encircle = csi + "52m"
|
||||
no_frame = csi + "54m"
|
1
examples/ansi_escape.py
Symbolic link
1
examples/ansi_escape.py
Symbolic link
@ -0,0 +1 @@
|
||||
/home/filip/Documents/python3/ansi_escape/ansi_escape.py
|
9
examples/test.py
Normal file
9
examples/test.py
Normal file
@ -0,0 +1,9 @@
|
||||
import ansi_escape
|
||||
a = 0
|
||||
while a < 256:
|
||||
b = str(a)
|
||||
print(ansi_escape.color("256", "bg", b) + " " + b + " " + ansi_escape.reset, end='')
|
||||
a += 1
|
||||
|
||||
print(ansi_escape.escape + "]0;Demo" + ansi_escape.escape + "\\")
|
||||
input()
|
7
readme.md
Normal file
7
readme.md
Normal file
@ -0,0 +1,7 @@
|
||||
# ansi_escape
|
||||
## A pure python3 library for ansi VT-100 escape codes
|
||||
Features:
|
||||
SGR (Select Graphic Rendition)
|
||||
SGR foreground and background color in 4-bit color, 8-bit color and 24-bit color
|
||||
SGR text formating like; underline, overline and bold text
|
||||
Easy way to use the bell character
|
Loading…
Reference in New Issue
Block a user