Module termcolors
source code
Simple colors for terminal output.
Main class is TermColors.
ANSY 4 bit color for unix.
==========================
[FG;BGm FG;BGm \e[FG;BGm
30-37 (30 + n) == text 90-97==bright text
40-47 (40 + n) == background 100-107==bright background
n color
0 black
1 red
2 green
3 yellow
4 blue
5 magenta
6 cyan
7 white
[31m == set red text
[31;42m == set red text and green background
ESC==\033
ESC [ 0 m # reset all (colors and brightness)
ESC [ 1 m # bright
ESC [ 2 m # dim (looks same as normal brightness)
ESC [ 22 m # normal brightness
# FOREGROUND:
ESC [ 30 m # black
ESC [ 31 m # red
ESC [ 32 m # green
ESC [ 33 m # yellow
ESC [ 34 m # blue
ESC [ 35 m # magenta
ESC [ 36 m # cyan
ESC [ 37 m # white
ESC [ 39 m # reset
# BACKGROUND
ESC [ 40 m # black
ESC [ 41 m # red
ESC [ 42 m # green
ESC [ 43 m # yellow
ESC [ 44 m # blue
ESC [ 45 m # magenta
ESC [ 46 m # cyan
ESC [ 47 m # white
ESC [ 49 m # reset
# cursor positioning
ESC [ y;x H # position cursor at x across, y down
ESC [ y;x f # position cursor at x across, y down
ESC [ n A # move cursor n lines up
ESC [ n B # move cursor n lines down
ESC [ n C # move cursor n characters forward
ESC [ n D # move cursor n characters backward
# clear the screen
ESC [ mode J # clear the screen
# clear the line
ESC [ mode K # clear the line
Windows colors.
===============
0-7 dark
8-15 bright
text background
0 black 0
1 blue 16
2 green 32
3 cyan 48 (blue+green)
4 red 64
5 magenta 80 (blue+red)
6 yellow 96 (green+red)
7 white 112 (blue+green+red)
FOREGROUND_BLUE = 0x01,
FOREGROUND_GREEN = 0x02,
FOREGROUND_RED = 0x04,
FOREGROUND_INTENSITY = 0x08,
BACKGROUND_BLUE = 0x10,
BACKGROUND_GREEN = 0x20,
BACKGROUND_RED = 0x40
BACKGROUND_INTENSITY = 0x80
|
|
_OSWIN = True
Is os is Windows.
|
|
|
__package__ = None
|
Imports:
ctypes,
platform,
sys,
re,
atexit,
io