hspylib-clitt 0.9.115__py3-none-any.whl → 0.9.117__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.
- clitt/.version +1 -1
- clitt/__classpath__.py +2 -2
- clitt/__init__.py +3 -3
- clitt/__main__.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/appman/templates/main_qt_view.py.tpl +1 -1
- 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/cursor.py +1 -1
- clitt/core/term/screen.py +1 -1
- clitt/core/term/terminal.py +2 -2
- clitt/core/tui/__init__.py +3 -3
- clitt/core/tui/line_input/__init__.py +3 -3
- clitt/core/tui/line_input/keyboard_input.py +34 -34
- clitt/core/tui/line_input/line_input.py +5 -13
- 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/core/tui/tui_application.py +11 -23
- clitt/core/tui/tui_preferences.py +1 -1
- clitt/utils/__init__.py +3 -3
- {hspylib_clitt-0.9.115.dist-info → hspylib_clitt-0.9.117.dist-info}/METADATA +2 -2
- hspylib_clitt-0.9.117.dist-info/RECORD +97 -0
- {hspylib_clitt-0.9.115.dist-info → hspylib_clitt-0.9.117.dist-info}/WHEEL +1 -1
- {hspylib_clitt-0.9.115.dist-info → hspylib_clitt-0.9.117.dist-info}/top_level.txt +0 -1
- build/lib/build/lib/clitt/__classpath__.py +0 -28
- build/lib/build/lib/clitt/__init__.py +0 -13
- build/lib/build/lib/clitt/__main__.py +0 -139
- build/lib/build/lib/clitt/addons/__init__.py +0 -12
- build/lib/build/lib/clitt/addons/appman/__init__.py +0 -13
- build/lib/build/lib/clitt/addons/appman/appman.py +0 -305
- build/lib/build/lib/clitt/addons/appman/appman_enums.py +0 -39
- build/lib/build/lib/clitt/addons/appman/templates/__init__.py +0 -11
- build/lib/build/lib/clitt/addons/widman/__init__.py +0 -14
- build/lib/build/lib/clitt/addons/widman/widget.py +0 -70
- build/lib/build/lib/clitt/addons/widman/widget_entry.py +0 -54
- build/lib/build/lib/clitt/addons/widman/widgets/__init__.py +0 -14
- build/lib/build/lib/clitt/addons/widman/widgets/widget_free.py +0 -110
- build/lib/build/lib/clitt/addons/widman/widgets/widget_punch.py +0 -246
- build/lib/build/lib/clitt/addons/widman/widgets/widget_send_msg.py +0 -272
- build/lib/build/lib/clitt/addons/widman/widgets/widget_time_calc.py +0 -146
- build/lib/build/lib/clitt/addons/widman/widman.py +0 -123
- build/lib/build/lib/clitt/core/__init__.py +0 -15
- build/lib/build/lib/clitt/core/exception/__init__.py +0 -11
- build/lib/build/lib/clitt/core/exception/exceptions.py +0 -18
- build/lib/build/lib/clitt/core/icons/__init__.py +0 -12
- build/lib/build/lib/clitt/core/icons/emojis/__init__.py +0 -12
- build/lib/build/lib/clitt/core/icons/emojis/emojis.py +0 -41
- build/lib/build/lib/clitt/core/icons/emojis/face_smiling.py +0 -40
- build/lib/build/lib/clitt/core/icons/font_awesome/__init__.py +0 -18
- build/lib/build/lib/clitt/core/icons/font_awesome/app_icons.py +0 -55
- build/lib/build/lib/clitt/core/icons/font_awesome/awesome.py +0 -76
- build/lib/build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +0 -93
- build/lib/build/lib/clitt/core/icons/font_awesome/form_icons.py +0 -69
- build/lib/build/lib/clitt/core/icons/font_awesome/game_icons.py +0 -59
- build/lib/build/lib/clitt/core/icons/font_awesome/nav_icons.py +0 -42
- build/lib/build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +0 -39
- build/lib/build/lib/clitt/core/icons/font_awesome/widget_icons.py +0 -37
- build/lib/build/lib/clitt/core/preferences.py +0 -87
- build/lib/build/lib/clitt/core/term/__init__.py +0 -14
- build/lib/build/lib/clitt/core/term/commons.py +0 -82
- build/lib/build/lib/clitt/core/term/cursor.py +0 -159
- build/lib/build/lib/clitt/core/term/screen.py +0 -91
- build/lib/build/lib/clitt/core/term/terminal.py +0 -203
- build/lib/build/lib/clitt/core/tui/__init__.py +0 -20
- build/lib/build/lib/clitt/core/tui/line_input/__init__.py +0 -12
- build/lib/build/lib/clitt/core/tui/line_input/keyboard_input.py +0 -228
- build/lib/build/lib/clitt/core/tui/line_input/line_input.py +0 -43
- build/lib/build/lib/clitt/core/tui/mchoose/__init__.py +0 -12
- build/lib/build/lib/clitt/core/tui/mchoose/mchoose.py +0 -44
- build/lib/build/lib/clitt/core/tui/mchoose/menu_choose.py +0 -200
- build/lib/build/lib/clitt/core/tui/mdashboard/__init__.py +0 -14
- build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +0 -54
- build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_item.py +0 -31
- build/lib/build/lib/clitt/core/tui/mdashboard/mdashboard.py +0 -26
- build/lib/build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +0 -154
- build/lib/build/lib/clitt/core/tui/menu/__init__.py +0 -16
- build/lib/build/lib/clitt/core/tui/menu/tui_menu.py +0 -111
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_action.py +0 -47
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_factory.py +0 -117
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_item.py +0 -196
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_ui.py +0 -98
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_view.py +0 -57
- build/lib/build/lib/clitt/core/tui/minput/__init__.py +0 -19
- build/lib/build/lib/clitt/core/tui/minput/access_type.py +0 -26
- build/lib/build/lib/clitt/core/tui/minput/field_builder.py +0 -117
- build/lib/build/lib/clitt/core/tui/minput/form_builder.py +0 -72
- build/lib/build/lib/clitt/core/tui/minput/form_field.py +0 -180
- build/lib/build/lib/clitt/core/tui/minput/input_type.py +0 -30
- build/lib/build/lib/clitt/core/tui/minput/input_validator.py +0 -98
- build/lib/build/lib/clitt/core/tui/minput/menu_input.py +0 -292
- build/lib/build/lib/clitt/core/tui/minput/minput.py +0 -44
- build/lib/build/lib/clitt/core/tui/minput/minput_utils.py +0 -156
- build/lib/build/lib/clitt/core/tui/mselect/__init__.py +0 -12
- build/lib/build/lib/clitt/core/tui/mselect/menu_select.py +0 -171
- build/lib/build/lib/clitt/core/tui/mselect/mselect.py +0 -36
- build/lib/build/lib/clitt/core/tui/table/__init__.py +0 -12
- build/lib/build/lib/clitt/core/tui/table/table_enums.py +0 -47
- build/lib/build/lib/clitt/core/tui/table/table_renderer.py +0 -339
- build/lib/build/lib/clitt/core/tui/tui_application.py +0 -65
- build/lib/build/lib/clitt/core/tui/tui_component.py +0 -155
- build/lib/build/lib/clitt/core/tui/tui_preferences.py +0 -103
- build/lib/build/lib/clitt/utils/__init__.py +0 -11
- build/lib/build/lib/clitt/utils/git_utils.py +0 -66
- build/lib/clitt/__classpath__.py +0 -28
- build/lib/clitt/__init__.py +0 -13
- build/lib/clitt/__main__.py +0 -139
- build/lib/clitt/addons/__init__.py +0 -12
- build/lib/clitt/addons/appman/__init__.py +0 -13
- build/lib/clitt/addons/appman/appman.py +0 -305
- build/lib/clitt/addons/appman/appman_enums.py +0 -39
- build/lib/clitt/addons/appman/templates/__init__.py +0 -11
- build/lib/clitt/addons/widman/__init__.py +0 -14
- build/lib/clitt/addons/widman/widget.py +0 -70
- build/lib/clitt/addons/widman/widget_entry.py +0 -54
- build/lib/clitt/addons/widman/widgets/__init__.py +0 -14
- build/lib/clitt/addons/widman/widgets/widget_free.py +0 -110
- build/lib/clitt/addons/widman/widgets/widget_punch.py +0 -246
- build/lib/clitt/addons/widman/widgets/widget_send_msg.py +0 -272
- build/lib/clitt/addons/widman/widgets/widget_time_calc.py +0 -146
- build/lib/clitt/addons/widman/widman.py +0 -123
- build/lib/clitt/core/__init__.py +0 -15
- build/lib/clitt/core/exception/__init__.py +0 -11
- build/lib/clitt/core/exception/exceptions.py +0 -18
- build/lib/clitt/core/icons/__init__.py +0 -12
- build/lib/clitt/core/icons/emojis/__init__.py +0 -12
- build/lib/clitt/core/icons/emojis/emojis.py +0 -41
- build/lib/clitt/core/icons/emojis/face_smiling.py +0 -40
- build/lib/clitt/core/icons/font_awesome/__init__.py +0 -18
- build/lib/clitt/core/icons/font_awesome/app_icons.py +0 -55
- build/lib/clitt/core/icons/font_awesome/awesome.py +0 -76
- build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +0 -93
- build/lib/clitt/core/icons/font_awesome/form_icons.py +0 -69
- build/lib/clitt/core/icons/font_awesome/game_icons.py +0 -59
- build/lib/clitt/core/icons/font_awesome/nav_icons.py +0 -42
- build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +0 -39
- build/lib/clitt/core/icons/font_awesome/widget_icons.py +0 -37
- build/lib/clitt/core/preferences.py +0 -87
- build/lib/clitt/core/term/__init__.py +0 -14
- build/lib/clitt/core/term/commons.py +0 -82
- build/lib/clitt/core/term/cursor.py +0 -159
- build/lib/clitt/core/term/screen.py +0 -91
- build/lib/clitt/core/term/terminal.py +0 -203
- build/lib/clitt/core/tui/__init__.py +0 -20
- build/lib/clitt/core/tui/line_input/__init__.py +0 -12
- build/lib/clitt/core/tui/line_input/keyboard_input.py +0 -228
- build/lib/clitt/core/tui/line_input/line_input.py +0 -43
- build/lib/clitt/core/tui/mchoose/__init__.py +0 -12
- build/lib/clitt/core/tui/mchoose/mchoose.py +0 -44
- build/lib/clitt/core/tui/mchoose/menu_choose.py +0 -200
- build/lib/clitt/core/tui/mdashboard/__init__.py +0 -14
- build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +0 -54
- build/lib/clitt/core/tui/mdashboard/dashboard_item.py +0 -31
- build/lib/clitt/core/tui/mdashboard/mdashboard.py +0 -26
- build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +0 -154
- build/lib/clitt/core/tui/menu/__init__.py +0 -16
- build/lib/clitt/core/tui/menu/tui_menu.py +0 -111
- build/lib/clitt/core/tui/menu/tui_menu_action.py +0 -47
- build/lib/clitt/core/tui/menu/tui_menu_factory.py +0 -117
- build/lib/clitt/core/tui/menu/tui_menu_item.py +0 -196
- build/lib/clitt/core/tui/menu/tui_menu_ui.py +0 -98
- build/lib/clitt/core/tui/menu/tui_menu_view.py +0 -57
- build/lib/clitt/core/tui/minput/__init__.py +0 -19
- build/lib/clitt/core/tui/minput/access_type.py +0 -26
- build/lib/clitt/core/tui/minput/field_builder.py +0 -117
- build/lib/clitt/core/tui/minput/form_builder.py +0 -72
- build/lib/clitt/core/tui/minput/form_field.py +0 -180
- build/lib/clitt/core/tui/minput/input_type.py +0 -30
- build/lib/clitt/core/tui/minput/input_validator.py +0 -98
- build/lib/clitt/core/tui/minput/menu_input.py +0 -292
- build/lib/clitt/core/tui/minput/minput.py +0 -44
- build/lib/clitt/core/tui/minput/minput_utils.py +0 -156
- build/lib/clitt/core/tui/mselect/__init__.py +0 -12
- build/lib/clitt/core/tui/mselect/menu_select.py +0 -171
- build/lib/clitt/core/tui/mselect/mselect.py +0 -36
- build/lib/clitt/core/tui/table/__init__.py +0 -12
- build/lib/clitt/core/tui/table/table_enums.py +0 -47
- build/lib/clitt/core/tui/table/table_renderer.py +0 -339
- build/lib/clitt/core/tui/tui_application.py +0 -65
- build/lib/clitt/core/tui/tui_component.py +0 -155
- build/lib/clitt/core/tui/tui_preferences.py +0 -103
- build/lib/clitt/utils/__init__.py +0 -11
- build/lib/clitt/utils/git_utils.py +0 -66
- hspylib_clitt-0.9.115.dist-info/RECORD +0 -255
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib-AskAI
|
|
6
|
-
@package: main.clitt.core.tui.line_input
|
|
7
|
-
@file: keyboard_input.py
|
|
8
|
-
@created: Wed, 17 Jan 2024
|
|
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
|
-
import pyperclip
|
|
17
|
-
from hspylib.modules.cli.keyboard import Keyboard
|
|
18
|
-
from hspylib.modules.cli.vt100.vt_color import VtColor
|
|
19
|
-
from typing import Optional, List, Dict
|
|
20
|
-
|
|
21
|
-
from clitt.core.term.commons import Direction, Portion
|
|
22
|
-
from clitt.core.term.terminal import Terminal
|
|
23
|
-
from clitt.core.tui.tui_component import TUIComponent
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class KeyboardInput(TUIComponent):
|
|
27
|
-
"""Provides a keyboard input for terminal UIs with undo and history."""
|
|
28
|
-
|
|
29
|
-
# Current history index.
|
|
30
|
-
_HIST_INDEX: int = 0
|
|
31
|
-
|
|
32
|
-
# Dict containing all previously accepted inputs.
|
|
33
|
-
_HISTORY: Dict[int, str] = {0: ""}
|
|
34
|
-
|
|
35
|
-
# Stack containing current input changes.
|
|
36
|
-
_UNDO_HISTORY: List[str] = []
|
|
37
|
-
|
|
38
|
-
# Stack containing current input reverts.
|
|
39
|
-
_REDO_HISTORY: List[str] = []
|
|
40
|
-
|
|
41
|
-
@staticmethod
|
|
42
|
-
def preload_history(history: List[str]) -> None:
|
|
43
|
-
"""Preload the input with the provided dictionary."""
|
|
44
|
-
for entry in history:
|
|
45
|
-
KeyboardInput._add_history(entry)
|
|
46
|
-
|
|
47
|
-
@staticmethod
|
|
48
|
-
def forget_history() -> None:
|
|
49
|
-
"""Forget all input history entries."""
|
|
50
|
-
tmp: str = KeyboardInput._HISTORY[0]
|
|
51
|
-
KeyboardInput._HISTORY.clear()
|
|
52
|
-
KeyboardInput._HISTORY[0] = tmp
|
|
53
|
-
|
|
54
|
-
@staticmethod
|
|
55
|
-
def history() -> List[str]:
|
|
56
|
-
"""Return the actual input history."""
|
|
57
|
-
return list(filter(lambda v: v, KeyboardInput._HISTORY.values()))
|
|
58
|
-
|
|
59
|
-
@staticmethod
|
|
60
|
-
def _add_history(input_text: str) -> None:
|
|
61
|
-
"""Add the following input to the history set.
|
|
62
|
-
:param input_text: The input text to add to the history.
|
|
63
|
-
"""
|
|
64
|
-
if input_text and input_text not in list(KeyboardInput._HISTORY.values())[1:]:
|
|
65
|
-
KeyboardInput._HISTORY[max(1, len(KeyboardInput._HISTORY))] = input_text
|
|
66
|
-
KeyboardInput._HIST_INDEX += 1
|
|
67
|
-
|
|
68
|
-
@classmethod
|
|
69
|
-
def _next_in_history(cls) -> Optional[str]:
|
|
70
|
-
index = min(len(cls._HISTORY), cls._HIST_INDEX + 1)
|
|
71
|
-
text = cls._HISTORY.get(index, "")
|
|
72
|
-
cls._HIST_INDEX = min(len(cls._HISTORY) - 1, index)
|
|
73
|
-
return text or cls._HISTORY[0]
|
|
74
|
-
|
|
75
|
-
@classmethod
|
|
76
|
-
def _prev_in_history(cls) -> Optional[str]:
|
|
77
|
-
index = max(1, cls._HIST_INDEX)
|
|
78
|
-
text = cls._HISTORY.get(index, "")
|
|
79
|
-
cls._HIST_INDEX = max(1, index - 1)
|
|
80
|
-
return text
|
|
81
|
-
|
|
82
|
-
@classmethod
|
|
83
|
-
def _undo(cls) -> Optional[str]:
|
|
84
|
-
text = cls._UNDO_HISTORY.pop() if cls._UNDO_HISTORY else None
|
|
85
|
-
if cls._HISTORY[0] not in cls._REDO_HISTORY:
|
|
86
|
-
cls._REDO_HISTORY.append(cls._HISTORY[0])
|
|
87
|
-
return text
|
|
88
|
-
|
|
89
|
-
@classmethod
|
|
90
|
-
def _redo(cls) -> Optional[str]:
|
|
91
|
-
text = cls._REDO_HISTORY.pop() if cls._REDO_HISTORY else None
|
|
92
|
-
if cls._HISTORY[0] not in cls._UNDO_HISTORY:
|
|
93
|
-
cls._UNDO_HISTORY.append(cls._HISTORY[0])
|
|
94
|
-
return text
|
|
95
|
-
|
|
96
|
-
def __init__(self, prompt: str = "", prompt_color: VtColor = VtColor.NC):
|
|
97
|
-
super().__init__(prompt)
|
|
98
|
-
self._prompt_color = prompt_color
|
|
99
|
-
self._input_index = 0
|
|
100
|
-
self._input_text: str = ""
|
|
101
|
-
self._HISTORY[0] = ""
|
|
102
|
-
|
|
103
|
-
@property
|
|
104
|
-
def length(self) -> int:
|
|
105
|
-
return len(self._input_text) if self._input_text else 0
|
|
106
|
-
|
|
107
|
-
def _prepare_render(self, auto_wrap: bool = True, show_cursor: bool = True) -> None:
|
|
108
|
-
Terminal.set_auto_wrap(auto_wrap)
|
|
109
|
-
Terminal.set_show_cursor(show_cursor)
|
|
110
|
-
self.cursor.save()
|
|
111
|
-
|
|
112
|
-
def _loop(self, break_keys: List[Keyboard] = None) -> Keyboard:
|
|
113
|
-
break_keys = break_keys or Keyboard.break_keys()
|
|
114
|
-
keypress = Keyboard.VK_NONE
|
|
115
|
-
|
|
116
|
-
# Wait for user interaction
|
|
117
|
-
while not self._done and keypress not in break_keys:
|
|
118
|
-
# Menu Renderization
|
|
119
|
-
if self._re_render:
|
|
120
|
-
self.render()
|
|
121
|
-
# Navigation input
|
|
122
|
-
keypress = self.handle_keypress()
|
|
123
|
-
|
|
124
|
-
return keypress
|
|
125
|
-
|
|
126
|
-
def execute(self) -> Optional[str | Keyboard]:
|
|
127
|
-
self._prepare_render()
|
|
128
|
-
keypress = self._loop()
|
|
129
|
-
|
|
130
|
-
if keypress.isEnter():
|
|
131
|
-
self._add_history(self._input_text)
|
|
132
|
-
self._UNDO_HISTORY.clear()
|
|
133
|
-
self._REDO_HISTORY.clear()
|
|
134
|
-
elif keypress == Keyboard.VK_ESC:
|
|
135
|
-
self._input_text = None
|
|
136
|
-
|
|
137
|
-
self.writeln("")
|
|
138
|
-
|
|
139
|
-
return self._input_text
|
|
140
|
-
|
|
141
|
-
def render(self) -> None:
|
|
142
|
-
Terminal.set_show_cursor(False)
|
|
143
|
-
self.cursor.restore()
|
|
144
|
-
self._terminal.cursor.erase(Portion.LINE)
|
|
145
|
-
self.write(f"{self._prompt_color.placeholder}{self.title}%NC%")
|
|
146
|
-
self.write(self._input_text)
|
|
147
|
-
self._re_render = False
|
|
148
|
-
self._set_cursor_pos()
|
|
149
|
-
Terminal.set_show_cursor()
|
|
150
|
-
|
|
151
|
-
def navbar(self, **kwargs) -> str:
|
|
152
|
-
pass
|
|
153
|
-
|
|
154
|
-
def handle_keypress(self) -> Keyboard:
|
|
155
|
-
if keypress := Keyboard.wait_keystroke():
|
|
156
|
-
match keypress:
|
|
157
|
-
case Keyboard.VK_BACKSPACE:
|
|
158
|
-
if self._input_index > 0:
|
|
159
|
-
self._input_index = max(0, self._input_index - 1)
|
|
160
|
-
self._update_input(
|
|
161
|
-
self._input_text[: self._input_index] + self._input_text[1 + self._input_index :]
|
|
162
|
-
)
|
|
163
|
-
case Keyboard.VK_DELETE:
|
|
164
|
-
self._update_input(
|
|
165
|
-
self._input_text[: self._input_index] + self._input_text[1 + self._input_index :]
|
|
166
|
-
)
|
|
167
|
-
case Keyboard.VK_CTRL_F:
|
|
168
|
-
self.forget_history()
|
|
169
|
-
case Keyboard.VK_CTRL_P:
|
|
170
|
-
text = (pyperclip.paste() or '').replace("\n", "↵")
|
|
171
|
-
self._update_input(
|
|
172
|
-
self._input_text[: self._input_index] + text + self._input_text[self._input_index :]
|
|
173
|
-
)
|
|
174
|
-
self._input_index += len(text)
|
|
175
|
-
case Keyboard.VK_CTRL_R:
|
|
176
|
-
self._input_index = 0
|
|
177
|
-
self._update_input("")
|
|
178
|
-
case Keyboard.VK_CTRL_U: # Undo
|
|
179
|
-
undo_text = self._undo()
|
|
180
|
-
self._input_text = undo_text
|
|
181
|
-
self._input_index = self.length
|
|
182
|
-
self._HISTORY[0] = self._input_text
|
|
183
|
-
case Keyboard.VK_CTRL_K: # redo
|
|
184
|
-
redo_text = self._redo()
|
|
185
|
-
self._input_text = redo_text if redo_text else self._input_text
|
|
186
|
-
self._input_index = self.length
|
|
187
|
-
self._HISTORY[0] = self._input_text
|
|
188
|
-
case Keyboard.VK_LEFT:
|
|
189
|
-
self._input_index = max(0, self._input_index - 1)
|
|
190
|
-
case Keyboard.VK_RIGHT:
|
|
191
|
-
self._input_index = min(self.length, self._input_index + 1)
|
|
192
|
-
case Keyboard.VK_UP:
|
|
193
|
-
self._input_text = self._prev_in_history()
|
|
194
|
-
self._input_index = self.length
|
|
195
|
-
case Keyboard.VK_DOWN:
|
|
196
|
-
self._input_text = self._next_in_history()
|
|
197
|
-
self._input_index = self.length
|
|
198
|
-
case Keyboard.VK_HOME:
|
|
199
|
-
self._input_index = 0
|
|
200
|
-
case Keyboard.VK_END:
|
|
201
|
-
self._input_index = self.length
|
|
202
|
-
case _ as key if key.val.isprintable():
|
|
203
|
-
self._update_input(
|
|
204
|
-
self._input_text[: self._input_index] + key.val + self._input_text[self._input_index :]
|
|
205
|
-
)
|
|
206
|
-
self._input_index += 1
|
|
207
|
-
case _ as key if key in Keyboard.break_keys():
|
|
208
|
-
self._done = True
|
|
209
|
-
case _:
|
|
210
|
-
self._input_text = keypress
|
|
211
|
-
self._done = True
|
|
212
|
-
self._re_render = True
|
|
213
|
-
|
|
214
|
-
return keypress
|
|
215
|
-
|
|
216
|
-
def _set_cursor_pos(self):
|
|
217
|
-
"""Set the cursor position on the input."""
|
|
218
|
-
index_offset = max(0, self.length - self._input_index)
|
|
219
|
-
self.screen.cursor.move(index_offset, Direction.LEFT)
|
|
220
|
-
|
|
221
|
-
def _update_input(self, text: str) -> str:
|
|
222
|
-
"""Update the value of the input.
|
|
223
|
-
:param text: The text to be set.
|
|
224
|
-
"""
|
|
225
|
-
self._UNDO_HISTORY.append(self._input_text)
|
|
226
|
-
self._HISTORY[0] = text if text not in self._HISTORY else self._input_text
|
|
227
|
-
self._input_text = text
|
|
228
|
-
return text
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib-AskAI
|
|
6
|
-
@package: main.clitt.core.tui.line_input
|
|
7
|
-
@file: line_input.py
|
|
8
|
-
@created: Wed, 17 Jan 2024
|
|
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 hspylib.modules.cli.keyboard import Keyboard
|
|
16
|
-
from hspylib.modules.cli.vt100.vt_color import VtColor
|
|
17
|
-
from typing import Optional
|
|
18
|
-
|
|
19
|
-
from clitt.core.tui.line_input.keyboard_input import KeyboardInput
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def line_input(
|
|
23
|
-
prompt: str = "",
|
|
24
|
-
prompt_color: VtColor = VtColor.NC,
|
|
25
|
-
) -> Optional[str | Keyboard]:
|
|
26
|
-
"""Read a string from standard input.
|
|
27
|
-
:param prompt: The message to be displayed to the user.
|
|
28
|
-
:param prompt_color: The color of the prompt text.
|
|
29
|
-
"""
|
|
30
|
-
ptt = KeyboardInput(prompt, prompt_color)
|
|
31
|
-
return ptt.execute()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if __name__ == "__main__":
|
|
35
|
-
hist = ["Hugo", "Joao", "Koko", "Hugo"]
|
|
36
|
-
KeyboardInput.preload_history(hist)
|
|
37
|
-
print("-=" * 30)
|
|
38
|
-
while (i := line_input("What is it? ")) not in ["bye", ""]:
|
|
39
|
-
if isinstance(i, Keyboard):
|
|
40
|
-
print(i)
|
|
41
|
-
else:
|
|
42
|
-
print("Input:", i)
|
|
43
|
-
print(KeyboardInput.history())
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.mchoose
|
|
7
|
-
@file: mchoose.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 hspylib.core.enums.charset import Charset
|
|
16
|
-
from typing import List, Optional, TypeVar
|
|
17
|
-
|
|
18
|
-
from clitt.core.tui.mchoose.menu_choose import MenuChoose
|
|
19
|
-
|
|
20
|
-
T = TypeVar("T")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def mchoose(
|
|
24
|
-
items: List[T],
|
|
25
|
-
checked: bool | List[bool] = False,
|
|
26
|
-
title: str = "Please choose among the options",
|
|
27
|
-
output: str = None
|
|
28
|
-
) -> Optional[List[T]]:
|
|
29
|
-
"""
|
|
30
|
-
Terminal UI menu choose input method.
|
|
31
|
-
:param items: the provided items to choose from.
|
|
32
|
-
:param checked: whether all items ate initially marked or not.
|
|
33
|
-
:param title: the title to be displayed before the options.
|
|
34
|
-
:param output: optional output file containing the marked items.
|
|
35
|
-
:return: the list of marked items.
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
result = MenuChoose(title, items, checked).execute()
|
|
39
|
-
|
|
40
|
-
if result and output:
|
|
41
|
-
with open(output, "w", encoding=Charset.UTF_8.val) as f_out:
|
|
42
|
-
f_out.write(" ".join(result))
|
|
43
|
-
|
|
44
|
-
return result
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.mchoose
|
|
7
|
-
@file: menu_choose.py
|
|
8
|
-
@created: Wed, 17 May 2023
|
|
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 hspylib.modules.cli.keyboard import Keyboard
|
|
16
|
-
from hspylib.core.tools.commons import to_bool
|
|
17
|
-
from hspylib.core.tools.dict_tools import get_or_default
|
|
18
|
-
from typing import List, Optional, TypeAlias, TypeVar
|
|
19
|
-
|
|
20
|
-
from clitt.core.icons.font_awesome.nav_icons import NavIcons
|
|
21
|
-
from clitt.core.term.commons import Direction, Portion
|
|
22
|
-
from clitt.core.tui.tui_component import TUIComponent
|
|
23
|
-
|
|
24
|
-
T = TypeVar("T")
|
|
25
|
-
|
|
26
|
-
MChooseItems: TypeAlias = List[T]
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class MenuChoose(TUIComponent):
|
|
30
|
-
"""Terminal UI menu choose input method."""
|
|
31
|
-
|
|
32
|
-
NAV_ICONS = NavIcons.compose(NavIcons.UP, NavIcons.DOWN)
|
|
33
|
-
|
|
34
|
-
ROW_OFFSET = 5
|
|
35
|
-
|
|
36
|
-
MIN_ROWS = 3
|
|
37
|
-
|
|
38
|
-
def __init__(
|
|
39
|
-
self,
|
|
40
|
-
title: str,
|
|
41
|
-
items: MChooseItems,
|
|
42
|
-
checked: bool | List[bool] = False):
|
|
43
|
-
|
|
44
|
-
super().__init__(title)
|
|
45
|
-
self.items = items
|
|
46
|
-
self.show_from = 0
|
|
47
|
-
self.show_to = self._max_rows()
|
|
48
|
-
self.diff_index = self.show_to - self.show_from
|
|
49
|
-
self.sel_index = 0
|
|
50
|
-
self.max_line_length = max(len(str(item)) for item in items)
|
|
51
|
-
# Initialize all options
|
|
52
|
-
if isinstance(checked, bool):
|
|
53
|
-
self.sel_options = [checked for _ in range(len(items))]
|
|
54
|
-
else:
|
|
55
|
-
# Check both sizes
|
|
56
|
-
self.sel_options = [get_or_default(checked, i, 0) for i in range(len(items))]
|
|
57
|
-
|
|
58
|
-
def execute(self) -> Optional[MChooseItems]:
|
|
59
|
-
if len(self.items) == 0:
|
|
60
|
-
return None
|
|
61
|
-
|
|
62
|
-
self._prepare_render()
|
|
63
|
-
keypress = self._loop()
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
[op for idx, op in enumerate(self.items) if self.sel_options[idx]]
|
|
67
|
-
if keypress.isEnter() else None
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
def render(self) -> None:
|
|
71
|
-
length = len(self.items)
|
|
72
|
-
self.cursor.restore()
|
|
73
|
-
self.writeln(f"{self.prefs.title_color.placeholder}{self.title}%EOL%%NC%")
|
|
74
|
-
|
|
75
|
-
for idx in range(self.show_from, self.show_to):
|
|
76
|
-
if idx >= length:
|
|
77
|
-
break # When the index is greater than the number of items, stop rendering
|
|
78
|
-
|
|
79
|
-
option_line = str(self.items[idx])
|
|
80
|
-
self.cursor.erase(Portion.LINE)
|
|
81
|
-
# Print the selector if the index is currently selected
|
|
82
|
-
selector = self.draw_selector(idx == self.sel_index)
|
|
83
|
-
mark = self.prefs.checked_icon if to_bool(self.sel_options[idx]) else self.prefs.unchecked_icon
|
|
84
|
-
# fmt: off
|
|
85
|
-
line_fmt = (
|
|
86
|
-
" {:>" + f"{len(str(length))}" + "} "
|
|
87
|
-
+ "{:>" + f"{len(selector)}" + "} "
|
|
88
|
-
+ "{:>" + f"{len(str(mark))}" + "} "
|
|
89
|
-
+ "{:<" + f"{self.max_line_length}" + "} "
|
|
90
|
-
)
|
|
91
|
-
# fmt: on
|
|
92
|
-
self.draw_line(line_fmt, idx + 1, selector, mark, option_line)
|
|
93
|
-
|
|
94
|
-
self.draw_navbar(self.navbar(to=length))
|
|
95
|
-
self._re_render = False
|
|
96
|
-
|
|
97
|
-
def navbar(self, **kwargs) -> str:
|
|
98
|
-
return (
|
|
99
|
-
f"%EOL%{self.prefs.navbar_color.placeholder}"
|
|
100
|
-
f"[Enter] Accept [{self.NAV_ICONS}] "
|
|
101
|
-
f"Navigate [Space] Mark [I] Invert [Esc] Quit [1..{kwargs['to']}] Goto: %NC%"
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
def handle_keypress(self) -> Keyboard:
|
|
105
|
-
if keypress := Keyboard.wait_keystroke():
|
|
106
|
-
match keypress:
|
|
107
|
-
case _ as key if key in Keyboard.break_keys():
|
|
108
|
-
self._done = True
|
|
109
|
-
case Keyboard.VK_UP:
|
|
110
|
-
self._handle_key_up()
|
|
111
|
-
case Keyboard.VK_DOWN:
|
|
112
|
-
self._handle_key_down()
|
|
113
|
-
case Keyboard.VK_TAB:
|
|
114
|
-
self._handle_tab()
|
|
115
|
-
case Keyboard.VK_SHIFT_TAB:
|
|
116
|
-
self._handle_shift_tab()
|
|
117
|
-
case Keyboard.VK_SPACE:
|
|
118
|
-
self._handle_space()
|
|
119
|
-
case _ as key if key in [Keyboard.VK_i, Keyboard.VK_I]:
|
|
120
|
-
self._handle_key_i()
|
|
121
|
-
case _ as key if key in Keyboard.digits():
|
|
122
|
-
self._handle_digit(keypress)
|
|
123
|
-
|
|
124
|
-
return keypress
|
|
125
|
-
|
|
126
|
-
def _handle_digit(self, digit: Keyboard) -> None:
|
|
127
|
-
"""TODO"""
|
|
128
|
-
length = len(self.items)
|
|
129
|
-
typed_index = digit.value
|
|
130
|
-
self.write(f"{digit.value}") # echo the digit typed
|
|
131
|
-
index_len = 1
|
|
132
|
-
while len(typed_index) < len(str(length)):
|
|
133
|
-
keystroke = Keyboard.wait_keystroke()
|
|
134
|
-
if not keystroke or not keystroke.isdigit():
|
|
135
|
-
typed_index = None if keystroke != Keyboard.VK_ENTER else typed_index
|
|
136
|
-
break
|
|
137
|
-
typed_index = f"{typed_index}{keystroke.value if keystroke else ''}"
|
|
138
|
-
self.write(f"{keystroke.value if keystroke else ''}")
|
|
139
|
-
index_len += 1
|
|
140
|
-
# Erase the index typed by the user
|
|
141
|
-
self.cursor.move(index_len, Direction.LEFT)
|
|
142
|
-
self.cursor.erase(Direction.RIGHT)
|
|
143
|
-
if typed_index and 1 <= int(typed_index) <= length:
|
|
144
|
-
self.show_to = max(int(typed_index), self.diff_index)
|
|
145
|
-
self.show_from = self.show_to - self.diff_index
|
|
146
|
-
self.sel_index = int(typed_index) - 1
|
|
147
|
-
self._re_render = True
|
|
148
|
-
|
|
149
|
-
def _handle_key_up(self) -> None:
|
|
150
|
-
"""TODO"""
|
|
151
|
-
if self.sel_index == self.show_from and self.show_from > 0:
|
|
152
|
-
self.show_from -= 1
|
|
153
|
-
self.show_to -= 1
|
|
154
|
-
if self.sel_index - 1 >= 0:
|
|
155
|
-
self.sel_index -= 1
|
|
156
|
-
self._re_render = True
|
|
157
|
-
|
|
158
|
-
def _handle_key_down(self) -> None:
|
|
159
|
-
"""TODO"""
|
|
160
|
-
length = len(self.items)
|
|
161
|
-
if self.sel_index + 1 == self.show_to and self.show_to < length:
|
|
162
|
-
self.show_from += 1
|
|
163
|
-
self.show_to += 1
|
|
164
|
-
if self.sel_index + 1 < length:
|
|
165
|
-
self.sel_index += 1
|
|
166
|
-
self._re_render = True
|
|
167
|
-
|
|
168
|
-
def _handle_tab(self) -> None:
|
|
169
|
-
"""TODO"""
|
|
170
|
-
length = len(self.items)
|
|
171
|
-
page_index = min(self.show_to + self.diff_index, length)
|
|
172
|
-
self.show_to = max(page_index, self.diff_index)
|
|
173
|
-
self.show_from = self.show_to - self.diff_index
|
|
174
|
-
self.sel_index = self.show_from
|
|
175
|
-
self._re_render = True
|
|
176
|
-
|
|
177
|
-
def _handle_shift_tab(self) -> None:
|
|
178
|
-
"""TODO"""
|
|
179
|
-
page_index = max(self.show_from - self.diff_index, 0)
|
|
180
|
-
self.show_from = min(page_index, self.diff_index)
|
|
181
|
-
self.show_to = self.show_from + self.diff_index
|
|
182
|
-
self.sel_index = self.show_from
|
|
183
|
-
self._re_render = True
|
|
184
|
-
|
|
185
|
-
def _handle_space(self) -> None:
|
|
186
|
-
"""TODO"""
|
|
187
|
-
if self.sel_options[self.sel_index] == 0:
|
|
188
|
-
self.sel_options[self.sel_index] = 1
|
|
189
|
-
else:
|
|
190
|
-
self.sel_options[self.sel_index] = 0
|
|
191
|
-
self._re_render = True
|
|
192
|
-
|
|
193
|
-
def _handle_key_i(self) -> None:
|
|
194
|
-
"""TODO"""
|
|
195
|
-
self.sel_options = [(0 if op == 1 else 1) for op in self.sel_options]
|
|
196
|
-
self._re_render = True
|
|
197
|
-
|
|
198
|
-
def _max_rows(self) -> int:
|
|
199
|
-
screen_lines = self.screen.lines - self.ROW_OFFSET
|
|
200
|
-
return min(self.prefs.max_rows, screen_lines)
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# _*_ coding: utf-8 _*_
|
|
2
|
-
#
|
|
3
|
-
# hspylib-clitt v0.9.115
|
|
4
|
-
#
|
|
5
|
-
# Package: main.build.lib.build.lib.clitt.core.tui.mdashboard
|
|
6
|
-
"""Package initialization."""
|
|
7
|
-
|
|
8
|
-
__all__ = [
|
|
9
|
-
'dashboard_builder',
|
|
10
|
-
'dashboard_item',
|
|
11
|
-
'mdashboard',
|
|
12
|
-
'menu_dashboard'
|
|
13
|
-
]
|
|
14
|
-
__version__ = '0.9.115'
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.mdashboard
|
|
7
|
-
@file: dashboard_builder.py
|
|
8
|
-
@created: Thu, 20 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 clitt.core.icons.font_awesome.awesome import Awesome
|
|
16
|
-
from clitt.core.tui.mdashboard.dashboard_item import DashboardItem
|
|
17
|
-
from typing import Callable, List, Optional
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class DashboardBuilder:
|
|
21
|
-
"""Dashboard builder."""
|
|
22
|
-
|
|
23
|
-
@staticmethod
|
|
24
|
-
class DashboardItemBuilder:
|
|
25
|
-
"""Dashboard item builder."""
|
|
26
|
-
|
|
27
|
-
def __init__(self, parent: "DashboardBuilder"):
|
|
28
|
-
self._parent = parent
|
|
29
|
-
self._item = DashboardItem()
|
|
30
|
-
|
|
31
|
-
def icon(self, icon: Awesome) -> "DashboardBuilder.DashboardItemBuilder":
|
|
32
|
-
self._item.icon = icon
|
|
33
|
-
return self
|
|
34
|
-
|
|
35
|
-
def tooltip(self, tooltip: str) -> "DashboardBuilder.DashboardItemBuilder":
|
|
36
|
-
self._item.tooltip = tooltip
|
|
37
|
-
return self
|
|
38
|
-
|
|
39
|
-
def on_trigger(self, on_trigger: Callable) -> Optional["DashboardBuilder.DashboardItemBuilder"]:
|
|
40
|
-
self._item.on_trigger = on_trigger
|
|
41
|
-
return self
|
|
42
|
-
|
|
43
|
-
def build(self) -> "DashboardBuilder":
|
|
44
|
-
self._parent.items.append(self._item)
|
|
45
|
-
return self._parent
|
|
46
|
-
|
|
47
|
-
def __init__(self):
|
|
48
|
-
self.items = []
|
|
49
|
-
|
|
50
|
-
def item(self) -> DashboardItemBuilder:
|
|
51
|
-
return DashboardBuilder.DashboardItemBuilder(self)
|
|
52
|
-
|
|
53
|
-
def build(self) -> List[DashboardItem]:
|
|
54
|
-
return self.items
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.mdashboard
|
|
7
|
-
@file: dashboard_item.py
|
|
8
|
-
@created: Thu, 20 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 clitt.core.icons.font_awesome.awesome import Awesome
|
|
16
|
-
from typing import Callable, Optional
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class DashboardItem:
|
|
20
|
-
"""Represent a dashboard item."""
|
|
21
|
-
|
|
22
|
-
def __init__(self, icon: Awesome = None, tooltip: str = None, on_trigger: Optional[Callable] = None):
|
|
23
|
-
self.icon = icon
|
|
24
|
-
self.tooltip = tooltip
|
|
25
|
-
self.on_trigger = on_trigger
|
|
26
|
-
|
|
27
|
-
def __str__(self):
|
|
28
|
-
return f'{self.icon} "{self.tooltip}" -> {self.on_trigger}'
|
|
29
|
-
|
|
30
|
-
def __repr__(self):
|
|
31
|
-
return str(self)
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.mdashboard
|
|
7
|
-
@file: mdashboard.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 clitt.core.tui.mdashboard.dashboard_item import DashboardItem
|
|
16
|
-
from clitt.core.tui.mdashboard.menu_dashboard import MenuDashBoard
|
|
17
|
-
from typing import List, Optional
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def mdashboard(items: List[DashboardItem], title: str = "Please select one item") -> Optional[DashboardItem]:
|
|
21
|
-
"""
|
|
22
|
-
Wrapper for the Menu Dashboard.
|
|
23
|
-
:param items: the provided dashboard items to select from.
|
|
24
|
-
:param title: the title to be displayed before the options.
|
|
25
|
-
"""
|
|
26
|
-
return MenuDashBoard(title, items).execute()
|