macros
All PTG-builtin TIM macros.
apply_default_macros(lang)
Applies all macros in DEFAULT_MACROS
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lang |
MarkupLanguage
|
The language to apply the macros to. |
required |
Source code in pytermgui/markup/macros.py
28 29 30 31 32 33 34 35 36 |
|
export_macro(func)
A decorator to add a function to DEFAULT_MACROS
.
Source code in pytermgui/markup/macros.py
18 19 20 21 22 23 24 25 |
|
macro_align(width, alignment, content)
Aligns given text using fstrings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width |
str
|
The width to align to. |
required |
alignment |
str
|
One of "left", "center", "right". |
required |
content |
str
|
The content to align; implicit argument. |
required |
Source code in pytermgui/markup/macros.py
60 61 62 63 64 65 66 67 68 69 70 71 |
|
macro_expand(lang, tag)
Expands a tag alias.
Source code in pytermgui/markup/macros.py
74 75 76 77 78 79 80 81 |
|
macro_gradient(base_str, item)
Creates an xterm-256 gradient from a base color.
This exploits the way the colors are arranged in the xterm color table; every 36th color is the next item of a single gradient.
The start of this given gradient is calculated by decreasing the given base by 36 on every iteration as long as the point is a valid gradient start.
After that, the 6 colors of this gradient are calculated and applied.
Source code in pytermgui/markup/macros.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
macro_lower(text)
Turns the text into lowercase.
Source code in pytermgui/markup/macros.py
46 47 48 49 50 |
|
macro_rainbow(item)
Creates rainbow-colored text.
Source code in pytermgui/markup/macros.py
111 112 113 114 115 116 117 |
|
macro_shuffle(item)
Shuffles a string using shuffle.shuffle on its list cast.
Source code in pytermgui/markup/macros.py
84 85 86 87 88 89 90 91 |
|
macro_title(text)
Turns the text into titlecase.
Source code in pytermgui/markup/macros.py
53 54 55 56 57 |
|
macro_upper(text)
Turns the text into uppercase.
Source code in pytermgui/markup/macros.py
39 40 41 42 43 |
|