hspylib-clitt 0.9.118__py3-none-any.whl → 0.9.120__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hspylib-clitt might be problematic. Click here for more details.
- build/lib/build/lib/build/lib/clitt/__classpath__.py +28 -0
- build/lib/build/lib/build/lib/clitt/__init__.py +13 -0
- build/lib/build/lib/build/lib/clitt/__main__.py +139 -0
- build/lib/build/lib/build/lib/clitt/addons/__init__.py +12 -0
- build/lib/build/lib/build/lib/clitt/addons/appman/__init__.py +13 -0
- build/lib/build/lib/build/lib/clitt/addons/appman/appman.py +305 -0
- build/lib/build/lib/build/lib/clitt/addons/appman/appman_enums.py +39 -0
- build/lib/build/lib/build/lib/clitt/addons/appman/templates/__init__.py +11 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/__init__.py +14 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/widget.py +70 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/widget_entry.py +54 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/__init__.py +14 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_free.py +110 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_punch.py +246 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_send_msg.py +272 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_time_calc.py +146 -0
- build/lib/build/lib/build/lib/clitt/addons/widman/widman.py +123 -0
- build/lib/build/lib/build/lib/clitt/core/__init__.py +15 -0
- build/lib/build/lib/build/lib/clitt/core/exception/__init__.py +11 -0
- build/lib/build/lib/build/lib/clitt/core/exception/exceptions.py +19 -0
- build/lib/build/lib/build/lib/clitt/core/icons/__init__.py +12 -0
- build/lib/build/lib/build/lib/clitt/core/icons/emojis/__init__.py +12 -0
- build/lib/build/lib/build/lib/clitt/core/icons/emojis/emojis.py +41 -0
- build/lib/build/lib/build/lib/clitt/core/icons/emojis/face_smiling.py +40 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/__init__.py +18 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/app_icons.py +55 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/awesome.py +76 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +93 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/form_icons.py +69 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/game_icons.py +59 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/nav_icons.py +42 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +39 -0
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/widget_icons.py +37 -0
- build/lib/build/lib/build/lib/clitt/core/preferences.py +87 -0
- build/lib/build/lib/build/lib/clitt/core/term/__init__.py +14 -0
- build/lib/build/lib/build/lib/clitt/core/term/commons.py +106 -0
- build/lib/build/lib/build/lib/clitt/core/term/cursor.py +174 -0
- build/lib/build/lib/build/lib/clitt/core/term/screen.py +106 -0
- build/lib/build/lib/build/lib/clitt/core/term/terminal.py +202 -0
- build/lib/build/lib/build/lib/clitt/core/tui/__init__.py +20 -0
- build/lib/build/lib/build/lib/clitt/core/tui/line_input/__init__.py +12 -0
- build/lib/build/lib/build/lib/clitt/core/tui/line_input/keyboard_input.py +229 -0
- build/lib/build/lib/build/lib/clitt/core/tui/line_input/line_input.py +31 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mchoose/__init__.py +12 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mchoose/mchoose.py +43 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mchoose/menu_choose.py +192 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/__init__.py +14 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +54 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_item.py +31 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/mdashboard.py +26 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +148 -0
- build/lib/build/lib/build/lib/clitt/core/tui/menu/__init__.py +16 -0
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu.py +111 -0
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_action.py +47 -0
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_factory.py +117 -0
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_item.py +196 -0
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_ui.py +98 -0
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_view.py +57 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/__init__.py +19 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/access_type.py +26 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/field_builder.py +117 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/form_builder.py +72 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/form_field.py +180 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/input_type.py +30 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/input_validator.py +98 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/menu_input.py +292 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/minput.py +44 -0
- build/lib/build/lib/build/lib/clitt/core/tui/minput/minput_utils.py +156 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mselect/__init__.py +12 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mselect/menu_select.py +170 -0
- build/lib/build/lib/build/lib/clitt/core/tui/mselect/mselect.py +36 -0
- build/lib/build/lib/build/lib/clitt/core/tui/table/__init__.py +12 -0
- build/lib/build/lib/build/lib/clitt/core/tui/table/table_enums.py +47 -0
- build/lib/build/lib/build/lib/clitt/core/tui/table/table_renderer.py +339 -0
- build/lib/build/lib/build/lib/clitt/core/tui/tui_application.py +52 -0
- build/lib/build/lib/build/lib/clitt/core/tui/tui_component.py +154 -0
- build/lib/build/lib/build/lib/clitt/core/tui/tui_preferences.py +103 -0
- build/lib/build/lib/build/lib/clitt/utils/__init__.py +11 -0
- build/lib/build/lib/build/lib/clitt/utils/git_utils.py +66 -0
- build/lib/build/lib/clitt/__classpath__.py +28 -0
- build/lib/build/lib/clitt/__init__.py +13 -0
- build/lib/build/lib/clitt/__main__.py +139 -0
- build/lib/build/lib/clitt/addons/__init__.py +12 -0
- build/lib/build/lib/clitt/addons/appman/__init__.py +13 -0
- build/lib/build/lib/clitt/addons/appman/appman.py +305 -0
- build/lib/build/lib/clitt/addons/appman/appman_enums.py +39 -0
- build/lib/build/lib/clitt/addons/appman/templates/__init__.py +11 -0
- build/lib/build/lib/clitt/addons/widman/__init__.py +14 -0
- build/lib/build/lib/clitt/addons/widman/widget.py +70 -0
- build/lib/build/lib/clitt/addons/widman/widget_entry.py +54 -0
- build/lib/build/lib/clitt/addons/widman/widgets/__init__.py +14 -0
- build/lib/build/lib/clitt/addons/widman/widgets/widget_free.py +110 -0
- build/lib/build/lib/clitt/addons/widman/widgets/widget_punch.py +246 -0
- build/lib/build/lib/clitt/addons/widman/widgets/widget_send_msg.py +272 -0
- build/lib/build/lib/clitt/addons/widman/widgets/widget_time_calc.py +146 -0
- build/lib/build/lib/clitt/addons/widman/widman.py +123 -0
- build/lib/build/lib/clitt/core/__init__.py +15 -0
- build/lib/build/lib/clitt/core/exception/__init__.py +11 -0
- build/lib/build/lib/clitt/core/exception/exceptions.py +19 -0
- build/lib/build/lib/clitt/core/icons/__init__.py +12 -0
- build/lib/build/lib/clitt/core/icons/emojis/__init__.py +12 -0
- build/lib/build/lib/clitt/core/icons/emojis/emojis.py +41 -0
- build/lib/build/lib/clitt/core/icons/emojis/face_smiling.py +40 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/__init__.py +18 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/app_icons.py +55 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/awesome.py +76 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +93 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/form_icons.py +69 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/game_icons.py +59 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/nav_icons.py +42 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +39 -0
- build/lib/build/lib/clitt/core/icons/font_awesome/widget_icons.py +37 -0
- build/lib/build/lib/clitt/core/preferences.py +87 -0
- build/lib/build/lib/clitt/core/term/__init__.py +14 -0
- build/lib/build/lib/clitt/core/term/commons.py +106 -0
- build/lib/build/lib/clitt/core/term/cursor.py +174 -0
- build/lib/build/lib/clitt/core/term/screen.py +106 -0
- build/lib/build/lib/clitt/core/term/terminal.py +202 -0
- build/lib/build/lib/clitt/core/tui/__init__.py +20 -0
- build/lib/build/lib/clitt/core/tui/line_input/__init__.py +12 -0
- build/lib/build/lib/clitt/core/tui/line_input/keyboard_input.py +229 -0
- build/lib/build/lib/clitt/core/tui/line_input/line_input.py +31 -0
- build/lib/build/lib/clitt/core/tui/mchoose/__init__.py +12 -0
- build/lib/build/lib/clitt/core/tui/mchoose/mchoose.py +43 -0
- build/lib/build/lib/clitt/core/tui/mchoose/menu_choose.py +192 -0
- build/lib/build/lib/clitt/core/tui/mdashboard/__init__.py +14 -0
- build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +54 -0
- build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_item.py +31 -0
- build/lib/build/lib/clitt/core/tui/mdashboard/mdashboard.py +26 -0
- build/lib/build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +148 -0
- build/lib/build/lib/clitt/core/tui/menu/__init__.py +16 -0
- build/lib/build/lib/clitt/core/tui/menu/tui_menu.py +111 -0
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_action.py +47 -0
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_factory.py +117 -0
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_item.py +196 -0
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_ui.py +98 -0
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_view.py +57 -0
- build/lib/build/lib/clitt/core/tui/minput/__init__.py +19 -0
- build/lib/build/lib/clitt/core/tui/minput/access_type.py +26 -0
- build/lib/build/lib/clitt/core/tui/minput/field_builder.py +117 -0
- build/lib/build/lib/clitt/core/tui/minput/form_builder.py +72 -0
- build/lib/build/lib/clitt/core/tui/minput/form_field.py +180 -0
- build/lib/build/lib/clitt/core/tui/minput/input_type.py +30 -0
- build/lib/build/lib/clitt/core/tui/minput/input_validator.py +98 -0
- build/lib/build/lib/clitt/core/tui/minput/menu_input.py +292 -0
- build/lib/build/lib/clitt/core/tui/minput/minput.py +44 -0
- build/lib/build/lib/clitt/core/tui/minput/minput_utils.py +156 -0
- build/lib/build/lib/clitt/core/tui/mselect/__init__.py +12 -0
- build/lib/build/lib/clitt/core/tui/mselect/menu_select.py +170 -0
- build/lib/build/lib/clitt/core/tui/mselect/mselect.py +36 -0
- build/lib/build/lib/clitt/core/tui/table/__init__.py +12 -0
- build/lib/build/lib/clitt/core/tui/table/table_enums.py +47 -0
- build/lib/build/lib/clitt/core/tui/table/table_renderer.py +339 -0
- build/lib/build/lib/clitt/core/tui/tui_application.py +52 -0
- build/lib/build/lib/clitt/core/tui/tui_component.py +154 -0
- build/lib/build/lib/clitt/core/tui/tui_preferences.py +103 -0
- build/lib/build/lib/clitt/utils/__init__.py +11 -0
- build/lib/build/lib/clitt/utils/git_utils.py +66 -0
- build/lib/clitt/__classpath__.py +28 -0
- build/lib/clitt/__init__.py +13 -0
- build/lib/clitt/__main__.py +139 -0
- build/lib/clitt/addons/__init__.py +12 -0
- build/lib/clitt/addons/appman/__init__.py +13 -0
- build/lib/clitt/addons/appman/appman.py +305 -0
- build/lib/clitt/addons/appman/appman_enums.py +39 -0
- build/lib/clitt/addons/appman/templates/__init__.py +11 -0
- build/lib/clitt/addons/widman/__init__.py +14 -0
- build/lib/clitt/addons/widman/widget.py +70 -0
- build/lib/clitt/addons/widman/widget_entry.py +54 -0
- build/lib/clitt/addons/widman/widgets/__init__.py +14 -0
- build/lib/clitt/addons/widman/widgets/widget_free.py +110 -0
- build/lib/clitt/addons/widman/widgets/widget_punch.py +246 -0
- build/lib/clitt/addons/widman/widgets/widget_send_msg.py +272 -0
- build/lib/clitt/addons/widman/widgets/widget_time_calc.py +146 -0
- build/lib/clitt/addons/widman/widman.py +123 -0
- build/lib/clitt/core/__init__.py +15 -0
- build/lib/clitt/core/exception/__init__.py +11 -0
- build/lib/clitt/core/exception/exceptions.py +19 -0
- build/lib/clitt/core/icons/__init__.py +12 -0
- build/lib/clitt/core/icons/emojis/__init__.py +12 -0
- build/lib/clitt/core/icons/emojis/emojis.py +41 -0
- build/lib/clitt/core/icons/emojis/face_smiling.py +40 -0
- build/lib/clitt/core/icons/font_awesome/__init__.py +18 -0
- build/lib/clitt/core/icons/font_awesome/app_icons.py +55 -0
- build/lib/clitt/core/icons/font_awesome/awesome.py +76 -0
- build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +93 -0
- build/lib/clitt/core/icons/font_awesome/form_icons.py +69 -0
- build/lib/clitt/core/icons/font_awesome/game_icons.py +59 -0
- build/lib/clitt/core/icons/font_awesome/nav_icons.py +42 -0
- build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +39 -0
- build/lib/clitt/core/icons/font_awesome/widget_icons.py +37 -0
- build/lib/clitt/core/preferences.py +87 -0
- build/lib/clitt/core/term/__init__.py +14 -0
- build/lib/clitt/core/term/commons.py +106 -0
- build/lib/clitt/core/term/cursor.py +174 -0
- build/lib/clitt/core/term/screen.py +106 -0
- build/lib/clitt/core/term/terminal.py +202 -0
- build/lib/clitt/core/tui/__init__.py +20 -0
- build/lib/clitt/core/tui/line_input/__init__.py +12 -0
- build/lib/clitt/core/tui/line_input/keyboard_input.py +229 -0
- build/lib/clitt/core/tui/line_input/line_input.py +31 -0
- build/lib/clitt/core/tui/mchoose/__init__.py +12 -0
- build/lib/clitt/core/tui/mchoose/mchoose.py +43 -0
- build/lib/clitt/core/tui/mchoose/menu_choose.py +192 -0
- build/lib/clitt/core/tui/mdashboard/__init__.py +14 -0
- build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +54 -0
- build/lib/clitt/core/tui/mdashboard/dashboard_item.py +31 -0
- build/lib/clitt/core/tui/mdashboard/mdashboard.py +26 -0
- build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +148 -0
- build/lib/clitt/core/tui/menu/__init__.py +16 -0
- build/lib/clitt/core/tui/menu/tui_menu.py +111 -0
- build/lib/clitt/core/tui/menu/tui_menu_action.py +47 -0
- build/lib/clitt/core/tui/menu/tui_menu_factory.py +117 -0
- build/lib/clitt/core/tui/menu/tui_menu_item.py +196 -0
- build/lib/clitt/core/tui/menu/tui_menu_ui.py +98 -0
- build/lib/clitt/core/tui/menu/tui_menu_view.py +57 -0
- build/lib/clitt/core/tui/minput/__init__.py +19 -0
- build/lib/clitt/core/tui/minput/access_type.py +26 -0
- build/lib/clitt/core/tui/minput/field_builder.py +117 -0
- build/lib/clitt/core/tui/minput/form_builder.py +72 -0
- build/lib/clitt/core/tui/minput/form_field.py +180 -0
- build/lib/clitt/core/tui/minput/input_type.py +30 -0
- build/lib/clitt/core/tui/minput/input_validator.py +98 -0
- build/lib/clitt/core/tui/minput/menu_input.py +292 -0
- build/lib/clitt/core/tui/minput/minput.py +44 -0
- build/lib/clitt/core/tui/minput/minput_utils.py +156 -0
- build/lib/clitt/core/tui/mselect/__init__.py +12 -0
- build/lib/clitt/core/tui/mselect/menu_select.py +170 -0
- build/lib/clitt/core/tui/mselect/mselect.py +36 -0
- build/lib/clitt/core/tui/table/__init__.py +12 -0
- build/lib/clitt/core/tui/table/table_enums.py +47 -0
- build/lib/clitt/core/tui/table/table_renderer.py +339 -0
- build/lib/clitt/core/tui/tui_application.py +52 -0
- build/lib/clitt/core/tui/tui_component.py +154 -0
- build/lib/clitt/core/tui/tui_preferences.py +103 -0
- build/lib/clitt/utils/__init__.py +11 -0
- build/lib/clitt/utils/git_utils.py +66 -0
- clitt/.version +1 -1
- clitt/__init__.py +3 -3
- clitt/addons/__init__.py +3 -3
- clitt/addons/appman/__init__.py +3 -3
- clitt/addons/appman/templates/__init__.py +3 -3
- clitt/addons/widman/__init__.py +3 -3
- clitt/addons/widman/widgets/__init__.py +3 -3
- clitt/core/__init__.py +3 -3
- clitt/core/exception/__init__.py +3 -3
- clitt/core/icons/__init__.py +3 -3
- clitt/core/icons/emojis/__init__.py +3 -3
- clitt/core/icons/font_awesome/__init__.py +3 -3
- clitt/core/term/__init__.py +3 -3
- clitt/core/term/commons.py +11 -12
- clitt/core/tui/__init__.py +3 -3
- clitt/core/tui/line_input/__init__.py +3 -3
- clitt/core/tui/line_input/keyboard_input.py +22 -22
- clitt/core/tui/mchoose/__init__.py +3 -3
- clitt/core/tui/mdashboard/__init__.py +3 -3
- clitt/core/tui/menu/__init__.py +3 -3
- clitt/core/tui/minput/__init__.py +3 -3
- clitt/core/tui/mselect/__init__.py +3 -3
- clitt/core/tui/table/__init__.py +3 -3
- clitt/utils/__init__.py +3 -3
- {hspylib_clitt-0.9.118.dist-info → hspylib_clitt-0.9.120.dist-info}/METADATA +2 -2
- hspylib_clitt-0.9.120.dist-info/RECORD +334 -0
- {hspylib_clitt-0.9.118.dist-info → hspylib_clitt-0.9.120.dist-info}/top_level.txt +1 -0
- hspylib_clitt-0.9.118.dist-info/RECORD +0 -97
- {hspylib_clitt-0.9.118.dist-info → hspylib_clitt-0.9.120.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
@project: HsPyLib-Clitt
|
|
6
|
+
@package: clitt.core.tui
|
|
7
|
+
@file: tui_component.py
|
|
8
|
+
@created: Tue, 4 May 2021
|
|
9
|
+
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
|
|
10
|
+
@site: https://github.com/yorevs/hspylib
|
|
11
|
+
@license: MIT - Please refer to <https://opensource.org/licenses/MIT>
|
|
12
|
+
|
|
13
|
+
Copyright·(c)·2024,·HSPyLib
|
|
14
|
+
"""
|
|
15
|
+
from abc import ABC, abstractmethod
|
|
16
|
+
from clitt.core.icons.font_awesome.awesome import Awesome
|
|
17
|
+
from clitt.core.term.commons import Direction
|
|
18
|
+
from clitt.core.term.cursor import Cursor
|
|
19
|
+
from clitt.core.term.screen import Screen
|
|
20
|
+
from clitt.core.term.terminal import Terminal
|
|
21
|
+
from clitt.core.tui.tui_preferences import TUIPreferences
|
|
22
|
+
from hspylib.core.tools.text_tools import elide_text
|
|
23
|
+
from hspylib.modules.cli.keyboard import Keyboard
|
|
24
|
+
from typing import Any, List, Optional, TypeVar
|
|
25
|
+
|
|
26
|
+
T = TypeVar("T", bound=Any)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TUIComponent(ABC):
|
|
30
|
+
"""Provide a base class for terminal UI components."""
|
|
31
|
+
|
|
32
|
+
def __init__(self, title: str):
|
|
33
|
+
self._re_render = True
|
|
34
|
+
self._done = False
|
|
35
|
+
self._title = title
|
|
36
|
+
self._terminal = Terminal.INSTANCE
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def terminal(self) -> Terminal:
|
|
40
|
+
return self._terminal
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def screen(self) -> Screen:
|
|
44
|
+
return self.terminal.screen
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def cursor(self) -> Cursor:
|
|
48
|
+
return self.terminal.screen.cursor
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def prefs(self) -> TUIPreferences:
|
|
52
|
+
return self.screen.preferences
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def title(self) -> str:
|
|
56
|
+
return self._title
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def rows(self) -> int:
|
|
60
|
+
return self.screen.lines
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def columns(self) -> int:
|
|
64
|
+
return self.screen.columns
|
|
65
|
+
|
|
66
|
+
def _prepare_render(self, auto_wrap: bool = False, show_cursor: bool = False) -> None:
|
|
67
|
+
"""Prepare the screen for renderization."""
|
|
68
|
+
self.screen.add_watcher(self.invalidate)
|
|
69
|
+
Terminal.set_auto_wrap(auto_wrap)
|
|
70
|
+
Terminal.set_show_cursor(show_cursor)
|
|
71
|
+
self.screen.clear()
|
|
72
|
+
self.cursor.save()
|
|
73
|
+
|
|
74
|
+
def _loop(self, break_keys: List[Keyboard] = None) -> Keyboard:
|
|
75
|
+
"""Loop and wait for a keypress. Render the component if required."""
|
|
76
|
+
|
|
77
|
+
break_keys = break_keys or Keyboard.break_keys()
|
|
78
|
+
keypress = Keyboard.VK_NONE
|
|
79
|
+
|
|
80
|
+
# Wait for user interaction
|
|
81
|
+
while not self._done and keypress not in break_keys:
|
|
82
|
+
|
|
83
|
+
# Menu Renderization
|
|
84
|
+
if self._re_render:
|
|
85
|
+
self.render()
|
|
86
|
+
# Navigation input
|
|
87
|
+
keypress = self.handle_keypress()
|
|
88
|
+
|
|
89
|
+
self.cursor.end()
|
|
90
|
+
self.cursor.erase(Direction.DOWN)
|
|
91
|
+
self.cursor.reset_mode()
|
|
92
|
+
self.cursor.writeln("\n")
|
|
93
|
+
|
|
94
|
+
return keypress
|
|
95
|
+
|
|
96
|
+
def draw_line(self, line_fmt: str, *args: Any) -> None:
|
|
97
|
+
"""Draws a formatted component line respecting the specified max_columns.
|
|
98
|
+
:param line_fmt: the line format.
|
|
99
|
+
:param args: the format arguments.
|
|
100
|
+
"""
|
|
101
|
+
self.writeln(elide_text(line_fmt.format(*args), self.columns) + "%NC%")
|
|
102
|
+
|
|
103
|
+
def draw_navbar(self, navbar: str) -> None:
|
|
104
|
+
"""Draws the component navigation bar respecting the specified max_columns.
|
|
105
|
+
:param navbar: the component's navigation bar.
|
|
106
|
+
"""
|
|
107
|
+
self.write(navbar)
|
|
108
|
+
|
|
109
|
+
def draw_selector(self, is_selected: bool = False, has_bg_color: bool = True) -> Awesome:
|
|
110
|
+
"""Draws and highlight the selected component line.
|
|
111
|
+
:param is_selected: whether to set a selected foreground color or not.
|
|
112
|
+
:param has_bg_color: whether to set a background or not.
|
|
113
|
+
"""
|
|
114
|
+
prefs = TUIPreferences.INSTANCE
|
|
115
|
+
if is_selected:
|
|
116
|
+
selector = prefs.selected_icon
|
|
117
|
+
if has_bg_color:
|
|
118
|
+
self.write(prefs.sel_bg_color.code)
|
|
119
|
+
self.write(prefs.highlight_color.code)
|
|
120
|
+
else:
|
|
121
|
+
selector = prefs.unselected_icon
|
|
122
|
+
self.write(prefs.text_color.code)
|
|
123
|
+
|
|
124
|
+
return selector
|
|
125
|
+
|
|
126
|
+
def write(self, obj: Any) -> None:
|
|
127
|
+
"""Write the string representation of the object to the screen."""
|
|
128
|
+
self.terminal.echo(obj, end="")
|
|
129
|
+
|
|
130
|
+
def writeln(self, obj: Any) -> None:
|
|
131
|
+
"""Write the string representation of the object to the screen, appending a new line."""
|
|
132
|
+
self.terminal.echo(obj)
|
|
133
|
+
|
|
134
|
+
def invalidate(self) -> None:
|
|
135
|
+
"""Invalidate current TUI renderization."""
|
|
136
|
+
self.screen.clear()
|
|
137
|
+
self.cursor.save()
|
|
138
|
+
self.render()
|
|
139
|
+
|
|
140
|
+
@abstractmethod
|
|
141
|
+
def execute(self) -> Optional[T | List[T]]:
|
|
142
|
+
"""Execute the main TUI component flow."""
|
|
143
|
+
|
|
144
|
+
@abstractmethod
|
|
145
|
+
def render(self) -> None:
|
|
146
|
+
"""Renders the TUI component."""
|
|
147
|
+
|
|
148
|
+
@abstractmethod
|
|
149
|
+
def navbar(self, **kwargs) -> str:
|
|
150
|
+
"""Get the TUI component's navigation bar (optional)."""
|
|
151
|
+
|
|
152
|
+
@abstractmethod
|
|
153
|
+
def handle_keypress(self) -> Keyboard:
|
|
154
|
+
"""Handle a keyboard press."""
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
@project: HsPyLib-Clitt
|
|
6
|
+
@package: clitt.core.tui
|
|
7
|
+
@file: tui_preferences.py
|
|
8
|
+
@created: Tue, 4 May 2021
|
|
9
|
+
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
|
|
10
|
+
@site: https://github.com/yorevs/hspylib
|
|
11
|
+
@license: MIT - Please refer to <https://opensource.org/licenses/MIT>
|
|
12
|
+
|
|
13
|
+
Copyright·(c)·2024,·HSPyLib
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from clitt.core.icons.font_awesome.form_icons import FormIcons
|
|
17
|
+
from clitt.core.icons.font_awesome.nav_icons import Awesome, NavIcons
|
|
18
|
+
from clitt.core.preferences import Preferences
|
|
19
|
+
from hspylib.modules.cli.vt100.vt_color import VtColor
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TUIPreferences(Preferences):
|
|
23
|
+
"""Terminal UI Preferences class."""
|
|
24
|
+
|
|
25
|
+
INSTANCE = None
|
|
26
|
+
|
|
27
|
+
def __init__(self):
|
|
28
|
+
super().__init__("hhs.clitt")
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def max_rows(self) -> int:
|
|
32
|
+
return max(3, self.get_preference("max.rows", 10))
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def items_per_line(self) -> int:
|
|
36
|
+
return max(2, self.get_preference("items.per.line", 6))
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def title_line_length(self) -> int:
|
|
40
|
+
return max(15, self.get_preference("title.line.len", 30))
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def title_color(self) -> VtColor:
|
|
44
|
+
return self.get_preference("title.color", VtColor.ORANGE)
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def caption_color(self) -> VtColor:
|
|
48
|
+
return self.get_preference("caption.color", VtColor.WHITE)
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def text_color(self) -> VtColor:
|
|
52
|
+
return self.get_preference("text.color", VtColor.WHITE)
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def success_color(self) -> VtColor:
|
|
56
|
+
return self.get_preference("success.color", VtColor.GREEN)
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def warning_color(self) -> VtColor:
|
|
60
|
+
return self.get_preference("warning.color", VtColor.YELLOW)
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def error_color(self) -> VtColor:
|
|
64
|
+
return self.get_preference("error.color", VtColor.RED)
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def highlight_color(self) -> VtColor:
|
|
68
|
+
return self.get_preference("highlight.color", VtColor.CYAN)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def navbar_color(self) -> VtColor:
|
|
72
|
+
return self.get_preference("navbar.color", VtColor.YELLOW)
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def tooltip_color(self) -> VtColor:
|
|
76
|
+
return self.get_preference("tooltip.color", VtColor.GREEN)
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def breadcrumb_color(self) -> VtColor:
|
|
80
|
+
return self.get_preference("breadcrumb.color", VtColor.compose(VtColor.BG_BLUE, VtColor.WHITE))
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def sel_bg_color(self) -> VtColor:
|
|
84
|
+
return self.get_preference("sel.bg.color", VtColor.BLUE)
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def selected_icon(self) -> Awesome:
|
|
88
|
+
return self.get_preference("selected.icon", NavIcons.POINTER)
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def unselected_icon(self) -> Awesome:
|
|
92
|
+
return self.get_preference("unselected.icon", Awesome.no_icon())
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def checked_icon(self) -> Awesome:
|
|
96
|
+
return self.get_preference("checked.icon", FormIcons.MARKED)
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def unchecked_icon(self) -> Awesome:
|
|
100
|
+
return self.get_preference("unchecked.icon", FormIcons.UNMARKED)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
assert (tui_preferences := TUIPreferences().INSTANCE) is not None, "Failed to create TUIPreferences instance"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
@project: HsPyLib
|
|
6
|
+
@package: clitt.utils
|
|
7
|
+
@file: git_utils.py
|
|
8
|
+
@created: Nov 14, 2019
|
|
9
|
+
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior
|
|
10
|
+
@site: https://github.com/yorevs/hspylib
|
|
11
|
+
@license: MIT - Please refer to <https://opensource.org/licenses/MIT>
|
|
12
|
+
|
|
13
|
+
Copyright·(c)·2024,·HSPyLib
|
|
14
|
+
"""
|
|
15
|
+
from clitt.core.term.terminal import Terminal
|
|
16
|
+
from hspylib.modules.application.exit_status import ExitStatus
|
|
17
|
+
from typing import Tuple
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GitTools:
|
|
21
|
+
"""TODO"""
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def top_level_dir() -> Tuple[str, ExitStatus]:
|
|
25
|
+
"""TODO"""
|
|
26
|
+
return Terminal.shell_exec("git rev-parse --show-toplevel")
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def current_branch() -> Tuple[str, ExitStatus]:
|
|
30
|
+
"""TODO"""
|
|
31
|
+
return Terminal.shell_exec("git symbolic-ref --short HEAD")
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def changelog(from_tag: str, to_tag: str) -> Tuple[str, ExitStatus]:
|
|
35
|
+
"""TODO"""
|
|
36
|
+
return Terminal.shell_exec(f"git log --oneline --pretty='format:%h %ad %s' --date=short {from_tag}^..{to_tag}^")
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def unreleased() -> Tuple[str, ExitStatus]:
|
|
40
|
+
"""TODO"""
|
|
41
|
+
latest_tag = Terminal.shell_exec("git describe --tags --abbrev=0 HEAD^")
|
|
42
|
+
return Terminal.shell_exec(f"git log --oneline --pretty='format:%h %ad %s' --date=short '{latest_tag}'..HEAD")
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def release_date(tag_name: str) -> Tuple[str, ExitStatus]:
|
|
46
|
+
"""TODO"""
|
|
47
|
+
return Terminal.shell_exec(f"git log -1 --pretty='format:%ad' --date=short {tag_name}")
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def tag_list() -> Tuple[str, ExitStatus]:
|
|
51
|
+
"""TODO"""
|
|
52
|
+
return Terminal.shell_exec("git log --tags --simplify-by-decoration --pretty='format:%ci %d'")
|
|
53
|
+
|
|
54
|
+
@staticmethod
|
|
55
|
+
def create_tag(version: str, commit_id: str = "HEAD", description: str = None) -> Tuple[str, ExitStatus]:
|
|
56
|
+
"""TODO"""
|
|
57
|
+
return Terminal.shell_exec(f"git tag -a v{version} {commit_id} -m '{description or version}'")
|
|
58
|
+
|
|
59
|
+
@staticmethod
|
|
60
|
+
def search_logs(filter_by: str = ".*") -> Tuple[str, ExitStatus]:
|
|
61
|
+
"""TODO"""
|
|
62
|
+
return Terminal.shell_exec(f"git log --grep='{filter_by}' --pretty=format:'%h %ad %s' --date=short")
|
|
63
|
+
|
|
64
|
+
@staticmethod
|
|
65
|
+
def show_file(filename: str, commit_id: str = "HEAD") -> Tuple[str, ExitStatus]:
|
|
66
|
+
return Terminal.shell_exec(f"git show {commit_id}:{filename}")
|
clitt/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.9.
|
|
1
|
+
0.9.120
|
clitt/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt
|
|
5
|
+
# Package: main.build.lib.clitt
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -10,4 +10,4 @@ __all__ = [
|
|
|
10
10
|
'core',
|
|
11
11
|
'utils'
|
|
12
12
|
]
|
|
13
|
-
__version__ = '0.9.
|
|
13
|
+
__version__ = '0.9.120'
|
clitt/addons/__init__.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.addons
|
|
5
|
+
# Package: main.build.lib.clitt.addons
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
'appman',
|
|
10
10
|
'widman'
|
|
11
11
|
]
|
|
12
|
-
__version__ = '0.9.
|
|
12
|
+
__version__ = '0.9.120'
|
clitt/addons/appman/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.addons.appman
|
|
5
|
+
# Package: main.build.lib.clitt.addons.appman
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -10,4 +10,4 @@ __all__ = [
|
|
|
10
10
|
'appman_enums',
|
|
11
11
|
'templates'
|
|
12
12
|
]
|
|
13
|
-
__version__ = '0.9.
|
|
13
|
+
__version__ = '0.9.120'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.addons.appman.templates
|
|
5
|
+
# Package: main.build.lib.clitt.addons.appman.templates
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
|
|
10
10
|
]
|
|
11
|
-
__version__ = '0.9.
|
|
11
|
+
__version__ = '0.9.120'
|
clitt/addons/widman/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.addons.widman
|
|
5
|
+
# Package: main.build.lib.clitt.addons.widman
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -11,4 +11,4 @@ __all__ = [
|
|
|
11
11
|
'widgets',
|
|
12
12
|
'widman'
|
|
13
13
|
]
|
|
14
|
-
__version__ = '0.9.
|
|
14
|
+
__version__ = '0.9.120'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.addons.widman.widgets
|
|
5
|
+
# Package: main.build.lib.clitt.addons.widman.widgets
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -11,4 +11,4 @@ __all__ = [
|
|
|
11
11
|
'widget_send_msg',
|
|
12
12
|
'widget_time_calc'
|
|
13
13
|
]
|
|
14
|
-
__version__ = '0.9.
|
|
14
|
+
__version__ = '0.9.120'
|
clitt/core/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.core
|
|
5
|
+
# Package: main.build.lib.clitt.core
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -12,4 +12,4 @@ __all__ = [
|
|
|
12
12
|
'term',
|
|
13
13
|
'tui'
|
|
14
14
|
]
|
|
15
|
-
__version__ = '0.9.
|
|
15
|
+
__version__ = '0.9.120'
|
clitt/core/exception/__init__.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.core.exception
|
|
5
|
+
# Package: main.build.lib.clitt.core.exception
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
'exceptions'
|
|
10
10
|
]
|
|
11
|
-
__version__ = '0.9.
|
|
11
|
+
__version__ = '0.9.120'
|
clitt/core/icons/__init__.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.core.icons
|
|
5
|
+
# Package: main.build.lib.clitt.core.icons
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
'emojis',
|
|
10
10
|
'font_awesome'
|
|
11
11
|
]
|
|
12
|
-
__version__ = '0.9.
|
|
12
|
+
__version__ = '0.9.120'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.core.icons.emojis
|
|
5
|
+
# Package: main.build.lib.clitt.core.icons.emojis
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
'emojis',
|
|
10
10
|
'face_smiling'
|
|
11
11
|
]
|
|
12
|
-
__version__ = '0.9.
|
|
12
|
+
__version__ = '0.9.120'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.core.icons.font_awesome
|
|
5
|
+
# Package: main.build.lib.clitt.core.icons.font_awesome
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -15,4 +15,4 @@ __all__ = [
|
|
|
15
15
|
'trickplay_icons',
|
|
16
16
|
'widget_icons'
|
|
17
17
|
]
|
|
18
|
-
__version__ = '0.9.
|
|
18
|
+
__version__ = '0.9.120'
|
clitt/core/term/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.core.term
|
|
5
|
+
# Package: main.build.lib.clitt.core.term
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -11,4 +11,4 @@ __all__ = [
|
|
|
11
11
|
'screen',
|
|
12
12
|
'terminal'
|
|
13
13
|
]
|
|
14
|
-
__version__ = '0.9.
|
|
14
|
+
__version__ = '0.9.120'
|
clitt/core/term/commons.py
CHANGED
|
@@ -13,18 +13,16 @@
|
|
|
13
13
|
Copyright 2024, HSPyLib team
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
from clitt.core.exception.exceptions import NotATerminalError
|
|
17
|
-
from hspylib.core.enums.enumeration import Enumeration
|
|
18
|
-
from hspylib.core.tools.commons import is_debugging
|
|
19
|
-
from hspylib.modules.cli.vt100.vt_100 import Vt100
|
|
20
|
-
from shutil import get_terminal_size
|
|
21
|
-
from typing import Callable, Tuple, TypeAlias, Union
|
|
22
|
-
|
|
23
|
-
import logging as log
|
|
24
16
|
import re
|
|
25
17
|
import sys
|
|
26
18
|
import termios
|
|
27
19
|
import tty
|
|
20
|
+
from shutil import get_terminal_size
|
|
21
|
+
from typing import Callable, Tuple, TypeAlias, Union
|
|
22
|
+
|
|
23
|
+
from hspylib.core.enums.enumeration import Enumeration
|
|
24
|
+
from hspylib.core.tools.commons import is_debugging
|
|
25
|
+
from hspylib.modules.cli.vt100.vt_100 import Vt100
|
|
28
26
|
|
|
29
27
|
# fmt: off
|
|
30
28
|
Dimension : TypeAlias = Tuple[int, int]
|
|
@@ -37,7 +35,10 @@ EraseDirection : TypeAlias = Union["Direction", "Portion"]
|
|
|
37
35
|
|
|
38
36
|
def is_a_tty() -> bool:
|
|
39
37
|
"""Checks whether we are under a tty environment."""
|
|
40
|
-
|
|
38
|
+
try:
|
|
39
|
+
return sys.stdout.isatty() and sys.stdin.isatty()
|
|
40
|
+
except ValueError:
|
|
41
|
+
return sys.stdout.isatty()
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
class Direction(Enumeration):
|
|
@@ -65,7 +66,6 @@ def get_dimensions(fallback: Tuple[int, int] = (24, 80)) -> Tuple[int, int]:
|
|
|
65
66
|
:return lines, columns
|
|
66
67
|
"""
|
|
67
68
|
if not is_a_tty():
|
|
68
|
-
log.warning(NotATerminalError("get_dimensions:: Requires a terminal (TTY)"))
|
|
69
69
|
return fallback
|
|
70
70
|
dim = get_terminal_size((fallback[1], fallback[0]))
|
|
71
71
|
return dim.lines, dim.columns
|
|
@@ -81,7 +81,6 @@ def get_cursor_position(fallback: Tuple[int, int] = (0, 0)) -> Tuple[int, int]:
|
|
|
81
81
|
return pos
|
|
82
82
|
|
|
83
83
|
if not is_a_tty():
|
|
84
|
-
log.warning(NotATerminalError("get_cursor_position:: Requires a terminal (TTY)"))
|
|
85
84
|
return pos
|
|
86
85
|
|
|
87
86
|
buf, re_query_resp = "", r"^\x1b\[(\d*);(\d*)R"
|
|
@@ -99,7 +98,7 @@ def get_cursor_position(fallback: Tuple[int, int] = (0, 0)) -> Tuple[int, int]:
|
|
|
99
98
|
groups = matches.groups()
|
|
100
99
|
pos = int(groups[0]), int(groups[1])
|
|
101
100
|
except termios.error:
|
|
102
|
-
|
|
101
|
+
pass
|
|
103
102
|
finally:
|
|
104
103
|
if stdin and attrs:
|
|
105
104
|
termios.tcsetattr(stdin, termios.TCSANOW, attrs) # Reset terminal attributes
|
clitt/core/tui/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.core.tui
|
|
5
|
+
# Package: main.build.lib.clitt.core.tui
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -17,4 +17,4 @@ __all__ = [
|
|
|
17
17
|
'tui_component',
|
|
18
18
|
'tui_preferences'
|
|
19
19
|
]
|
|
20
|
-
__version__ = '0.9.
|
|
20
|
+
__version__ = '0.9.120'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# _*_ coding: utf-8 _*_
|
|
2
2
|
#
|
|
3
|
-
# hspylib-clitt v0.9.
|
|
3
|
+
# hspylib-clitt v0.9.120
|
|
4
4
|
#
|
|
5
|
-
# Package: main.clitt.core.tui.line_input
|
|
5
|
+
# Package: main.build.lib.clitt.core.tui.line_input
|
|
6
6
|
"""Package initialization."""
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
'keyboard_input',
|
|
10
10
|
'line_input'
|
|
11
11
|
]
|
|
12
|
-
__version__ = '0.9.
|
|
12
|
+
__version__ = '0.9.120'
|