Reference
Frame
hemline.frame.Frame
Source code in hemline/frame.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
__init__
__init__(
color=None,
text_alignment=DEFAULT_TEXT_ALIGNMENT,
alignment=DEFAULT_FRAME_ALIGNMENT,
theme=DEFAULT_THEME,
horizontal_padding=DEFAULT_HORIZONTAL_PADDING,
vertical_padding=DEFAULT_VERTICAL_PADDING,
outer_width=DEFAULT_OUTER_WIDTH,
container_width=None,
colorize=None,
wrap=DEFAULT_TEXT_WRAP,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
Color | None
|
The color of the frame. Use this for colorization out
of the box. For more sophistaced options, you can pass a
colorization function to the parameter |
None
|
text_alignment
|
Alignment
|
The alignment of the text inside the frame. |
DEFAULT_TEXT_ALIGNMENT
|
alignment
|
Alignment
|
The alignment of the frame inside the container. |
DEFAULT_FRAME_ALIGNMENT
|
theme
|
Theme
|
The appearance of the frameline. Choose one the predefined themes from hemline.themes or build your own instance of hemline.themes.Theme. |
DEFAULT_THEME
|
horizontal_padding
|
int
|
The number of whitespace characters used for horizontal padding. |
DEFAULT_HORIZONTAL_PADDING
|
vertical_padding
|
int
|
The number of blank lines used for vertical padding. |
DEFAULT_VERTICAL_PADDING
|
outer_width
|
int
|
The outer width of the Frame, including horizontal padding and the frame itself. |
DEFAULT_OUTER_WIDTH
|
container_width
|
int | None
|
The width of an imgainary container for the frame, resorts to the width of the terminal, if none is provided. |
None
|
colorize
|
Callable[[str], str] | None
|
A function to apply your custom colorization. Must take a
string return the colorized string. Passing this will override
any value provided to |
None
|
wrap
|
Callable[[str, int], str]
|
A function to apply your custom wrapping logic. Must take a string and the width and return the wrapped string. |
DEFAULT_TEXT_WRAP
|
Source code in hemline/frame.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
format
format(text)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to frame. |
required |
Source code in hemline/frame.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
hemline.frame.Frame.__init__
__init__(
color=None,
text_alignment=DEFAULT_TEXT_ALIGNMENT,
alignment=DEFAULT_FRAME_ALIGNMENT,
theme=DEFAULT_THEME,
horizontal_padding=DEFAULT_HORIZONTAL_PADDING,
vertical_padding=DEFAULT_VERTICAL_PADDING,
outer_width=DEFAULT_OUTER_WIDTH,
container_width=None,
colorize=None,
wrap=DEFAULT_TEXT_WRAP,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
Color | None
|
The color of the frame. Use this for colorization out
of the box. For more sophistaced options, you can pass a
colorization function to the parameter |
None
|
text_alignment
|
Alignment
|
The alignment of the text inside the frame. |
DEFAULT_TEXT_ALIGNMENT
|
alignment
|
Alignment
|
The alignment of the frame inside the container. |
DEFAULT_FRAME_ALIGNMENT
|
theme
|
Theme
|
The appearance of the frameline. Choose one the predefined themes from hemline.themes or build your own instance of hemline.themes.Theme. |
DEFAULT_THEME
|
horizontal_padding
|
int
|
The number of whitespace characters used for horizontal padding. |
DEFAULT_HORIZONTAL_PADDING
|
vertical_padding
|
int
|
The number of blank lines used for vertical padding. |
DEFAULT_VERTICAL_PADDING
|
outer_width
|
int
|
The outer width of the Frame, including horizontal padding and the frame itself. |
DEFAULT_OUTER_WIDTH
|
container_width
|
int | None
|
The width of an imgainary container for the frame, resorts to the width of the terminal, if none is provided. |
None
|
colorize
|
Callable[[str], str] | None
|
A function to apply your custom colorization. Must take a
string return the colorized string. Passing this will override
any value provided to |
None
|
wrap
|
Callable[[str, int], str]
|
A function to apply your custom wrapping logic. Must take a string and the width and return the wrapped string. |
DEFAULT_TEXT_WRAP
|
Source code in hemline/frame.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
hemline.frame.Frame.format
format(text)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to frame. |
required |
Source code in hemline/frame.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
Theme
hemline.themes
Theme
Source code in hemline/themes.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
__init__
__init__(
horizontal,
vertical,
top_left,
top_right,
bottom_left,
bottom_right,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
horizontal
|
SingleCharacter
|
single character string. |
required |
vertical
|
SingleCharacter
|
single character string. |
required |
top_left
|
SingleCharacter
|
single character string. |
required |
top_right
|
SingleCharacter
|
single character string. |
required |
bottom_left
|
SingleCharacter
|
single character string. |
required |
bottom_right
|
SingleCharacter
|
single character string. |
required |
Source code in hemline/themes.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
factory
factory(character, corner=None)
Convenience factory for a Theme built from one character, optionally specifying the character used for corners.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
character
|
SingleCharacter
|
The character to use for the frameline. Must be a single-character string. |
required |
corner
|
SingleCharacter | None
|
The character to use for the corners, resorts to |
None
|
Source code in hemline/themes.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
hemline.themes.Theme
Source code in hemline/themes.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
__init__
__init__(
horizontal,
vertical,
top_left,
top_right,
bottom_left,
bottom_right,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
horizontal
|
SingleCharacter
|
single character string. |
required |
vertical
|
SingleCharacter
|
single character string. |
required |
top_left
|
SingleCharacter
|
single character string. |
required |
top_right
|
SingleCharacter
|
single character string. |
required |
bottom_left
|
SingleCharacter
|
single character string. |
required |
bottom_right
|
SingleCharacter
|
single character string. |
required |
Source code in hemline/themes.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
hemline.themes.single
module-attribute
single = Theme(
horizontal="─",
vertical="│",
top_left="┌",
top_right="┐",
bottom_left="└",
bottom_right="┘",
)
hemline.themes.double
module-attribute
double = Theme(
horizontal="═",
vertical="║",
top_left="╔",
top_right="╗",
bottom_left="╚",
bottom_right="╝",
)
hemline.themes.factory
factory(character, corner=None)
Convenience factory for a Theme built from one character, optionally specifying the character used for corners.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
character
|
SingleCharacter
|
The character to use for the frameline. Must be a single-character string. |
required |
corner
|
SingleCharacter | None
|
The character to use for the corners, resorts to |
None
|
Source code in hemline/themes.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
Other
hemline.alignment.Alignment
module-attribute
Alignment = Literal['left', 'center', 'right']
hemline.colors
Color
Bases: StrEnum
Source code in hemline/colors.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
BLACK
class-attribute
instance-attribute
BLACK = '\x1b[0;30m'
BLUE
class-attribute
instance-attribute
BLUE = '\x1b[0;94m'
BROWN
class-attribute
instance-attribute
BROWN = '\x1b[1;33m'
CYAN
class-attribute
instance-attribute
CYAN = '\x1b[0;96m'
DARK_BLUE
class-attribute
instance-attribute
DARK_BLUE = '\x1b[0;34m'
DARK_GRAY
class-attribute
instance-attribute
DARK_GRAY = '\x1b[1;90m'
DARK_GREEN
class-attribute
instance-attribute
DARK_GREEN = '\x1b[0;32m'
DARK_RED
class-attribute
instance-attribute
DARK_RED = '\x1b[0;31m'
GREEN
class-attribute
instance-attribute
GREEN = '\x1b[0;92m'
LIGHT_GRAY
class-attribute
instance-attribute
LIGHT_GRAY = '\x1b[0;37m'
MAGENTA
class-attribute
instance-attribute
MAGENTA = '\x1b[;95m'
PURPLE
class-attribute
instance-attribute
PURPLE = '\x1b[0;35m'
RED
class-attribute
instance-attribute
RED = '\x1b[0;92m'
RESET
class-attribute
instance-attribute
RESET = '\x1b[0m'
TEAL
class-attribute
instance-attribute
TEAL = '\x1b[0;36m'
WHITE
class-attribute
instance-attribute
WHITE = '\x1b[;97m'
YELLOW
class-attribute
instance-attribute
YELLOW = '\x1b[;93m'
default_colorize
default_colorize(text, color)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to colorize |
required |
color
|
Color
|
The Color to use. |
required |
Source code in hemline/colors.py
24 25 26 27 28 29 30 31 | |
hemline.defaults
DEFAULT_FRAME_ALIGNMENT
module-attribute
DEFAULT_FRAME_ALIGNMENT = 'center'
DEFAULT_HORIZONTAL_PADDING
module-attribute
DEFAULT_HORIZONTAL_PADDING = 4
DEFAULT_OUTER_WIDTH
module-attribute
DEFAULT_OUTER_WIDTH = (
88 + 2 * DEFAULT_HORIZONTAL_PADDING + 2
)
DEFAULT_TEXT_ALIGNMENT
module-attribute
DEFAULT_TEXT_ALIGNMENT = 'left'
DEFAULT_TEXT_WRAP
module-attribute
DEFAULT_TEXT_WRAP = wrap
DEFAULT_VERTICAL_PADDING
module-attribute
DEFAULT_VERTICAL_PADDING = 1