cprint-python/readme.md

29 lines
1.1 KiB
Markdown
Raw Normal View History

2021-03-23 21:41:52 +01:00
# cprint for Python
2021-03-23 21:39:54 +01:00
2021-03-23 21:36:42 +01:00
cprint / colorPrint is a simple prettyprint function for python using ANSI escape characters.
Call cprint(str), inserting the cprint codes surrounded by percent signs(Ex. below).
Using getString(str) directly returns a string instead of printing to stdout.
Several color tags and modifiers can be used in the same tag if they are separated by a comma
2021-03-23 21:41:52 +01:00
### Colors
2021-03-23 21:36:42 +01:00
Text colors are denoted with the first lower case letter
-> (r)ed (g)reen (b)lue (c)yan (m)agenta (y)ellow (bl)ack (w)hite
Background colors are the same, but with a leading "b"
2021-03-23 21:41:52 +01:00
### Modifiers
2021-03-23 21:36:42 +01:00
(B)old (U)nderlined (I)nverted/reversed (RS)=reset/default
2021-03-23 21:51:06 +01:00
### Macros/Shortcuts
2021-03-23 21:36:42 +01:00
(warning) = Yellow, Bold
(error) = Red , Bold, Underlined
2021-03-23 21:41:52 +01:00
### Example code:
2021-03-23 21:39:54 +01:00
```
2021-03-23 21:36:42 +01:00
from cprint import *
2021-03-23 21:39:54 +01:00
cprint("%bc,r%This is pretty high visibility %y%with different colors")
2021-03-23 21:36:42 +01:00
cprint("%bw,b%This text is blue on white, %B,U,I% this is bold, underlined and white on blue")
2021-03-23 21:39:54 +01:00
cprint("%warning%This is a warning!")
cprint("%error%And this is an error")
```
2021-03-23 21:41:52 +01:00
![Screenshot of example code](cprint-screenshot.png "Example")