Ansie implements super easy and super powerful work with styles and colors.
All you need to do is just choose style or color and wrap your string:
from ansie.styles import bold, red
print(bold('Im bold'))
print(red.fg('Im red'))
Note: The color is actually map of foreground and background colors for which
we use fg
and bg
.
print(red.fg('Im red foreground'))
print(red.bg('Im red background'))
You also can create your own color using rgb
function:
from ansie.styles import rgb
my_super_unusual_red = rgb(255, 0, 1)
print(my_super_unsual_red.bg('Wow!'))
Or/and create styles union:
from ansie.styles import red, italic, rgb
my_super_unuasul_black = rgb(0, 1, 0)
my_style = red.bg + my_super_unusual_black.fg + italic
print(my_style('Here could be your ad :D'))
Styles:
- bold
- dim
- italic
- underline
- blinking
- inverse
- invisible
- strikethrough
Colors:
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- color256(i)
- rgb(r, g, b)
Unfinished yet :\
Functions:
- cursor_goto(column, row)
- cursor_up
- cursor_down
- cursor_right
- cursor_left
- cursor_save(*, dec, sco)
- cursor_restore(*, dec, sco)
- clear_row
- clear_row_before_cursor
- clear_row_after_cursor
- clear_screen
- clear_screen_before_cursor
- clear_screen_after_cursor
Probably you want generate ESC codes by yourself, Ansie also can help you with this.
- esc(*sequence) - Generates ESC code.
>>> esc('one', 'two')
'\x1Bone\x1Btwo'
- csi(*sequence) - Generates CSI code.
>>> csi('one', 'two')
'\x1B[one\x1B[two'
- style(*sequence) - Generates Style code.
>>> style('one', 'two')
'\x1B[one;twom'