blob: 563cb6e8372e81c128909b39fd12d761f36eed0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import shutil
from rich import print
from rich.align import Align
from rich.console import Console
from rich.style import Style
from rich.text import Text
from girok.constants import DisplayBoxType
console = Console()
def center_print(text: str, text_type: DisplayBoxType, wrap: bool = False) -> None:
style = Style(color=text_type.text_color_hex, bgcolor=text_type.bg_color_hex)
width = (
shutil.get_terminal_size().columns // 2
if wrap
else shutil.get_terminal_size().columns
)
content = Text(text, style=style)
console.print(Align.center(content, style=style, width=width), height=50)
|