inquirer-textual 0.3.0__py3-none-any.whl → 0.4.0__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.
- inquirer_textual/InquirerApp.py +7 -11
- inquirer_textual/common/Answer.py +22 -0
- inquirer_textual/common/ChoiceLabel.py +6 -6
- inquirer_textual/common/{PromptMessage.py → Prompt.py} +3 -3
- inquirer_textual/common/defaults.py +24 -0
- inquirer_textual/prompts.py +1 -1
- inquirer_textual/version.py +1 -1
- inquirer_textual/widgets/InquirerCheckbox.py +6 -14
- inquirer_textual/widgets/InquirerConfirm.py +23 -7
- inquirer_textual/widgets/InquirerEditor.py +2 -2
- inquirer_textual/widgets/InquirerMulti.py +14 -16
- inquirer_textual/widgets/InquirerNumber.py +3 -4
- inquirer_textual/widgets/InquirerPath.py +7 -5
- inquirer_textual/widgets/InquirerPattern.py +29 -23
- inquirer_textual/widgets/InquirerSecret.py +3 -4
- inquirer_textual/widgets/InquirerSelect.py +27 -23
- inquirer_textual/widgets/InquirerText.py +3 -4
- {inquirer_textual-0.3.0.dist-info → inquirer_textual-0.4.0.dist-info}/METADATA +1 -1
- inquirer_textual-0.4.0.dist-info/RECORD +30 -0
- inquirer_textual/common/AppConfig.py +0 -9
- inquirer_textual/common/StandardTheme.py +0 -10
- inquirer_textual-0.3.0.dist-info/RECORD +0 -30
- {inquirer_textual-0.3.0.dist-info → inquirer_textual-0.4.0.dist-info}/WHEEL +0 -0
- {inquirer_textual-0.3.0.dist-info → inquirer_textual-0.4.0.dist-info}/licenses/LICENSE +0 -0
inquirer_textual/InquirerApp.py
CHANGED
|
@@ -12,7 +12,7 @@ from textual.widgets import Footer
|
|
|
12
12
|
from inquirer_textual.common.InquirerHeader import InquirerHeader
|
|
13
13
|
from inquirer_textual.common.InquirerResult import InquirerResult
|
|
14
14
|
from inquirer_textual.common.Shortcut import Shortcut
|
|
15
|
-
from inquirer_textual.common.
|
|
15
|
+
from inquirer_textual.common.defaults import DEFAULT_THEME
|
|
16
16
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
17
17
|
|
|
18
18
|
T = TypeVar('T')
|
|
@@ -20,13 +20,9 @@ T = TypeVar('T')
|
|
|
20
20
|
|
|
21
21
|
class InquirerApp(App[InquirerResult[T]], inherit_bindings=False): # type: ignore[call-arg]
|
|
22
22
|
CSS = """
|
|
23
|
-
App {
|
|
24
|
-
background: black;
|
|
25
|
-
}
|
|
26
23
|
Screen {
|
|
27
24
|
border-top: none;
|
|
28
25
|
border-bottom: none;
|
|
29
|
-
background: transparent;
|
|
30
26
|
height: auto;
|
|
31
27
|
}
|
|
32
28
|
"""
|
|
@@ -36,7 +32,8 @@ class InquirerApp(App[InquirerResult[T]], inherit_bindings=False): # type: igno
|
|
|
36
32
|
Binding("ctrl+d", "quit", "Quit", show=False, priority=True)
|
|
37
33
|
]
|
|
38
34
|
|
|
39
|
-
def __init__(self) -> None:
|
|
35
|
+
def __init__(self, theme: str = 'inquirer-textual-default') -> None:
|
|
36
|
+
self._theme = theme
|
|
40
37
|
self.widget: InquirerWidget | None = None
|
|
41
38
|
self.shortcuts: list[Shortcut] | None = None
|
|
42
39
|
self.header: str | list[str] | None = None
|
|
@@ -48,6 +45,8 @@ class InquirerApp(App[InquirerResult[T]], inherit_bindings=False): # type: igno
|
|
|
48
45
|
super().__init__()
|
|
49
46
|
|
|
50
47
|
def on_mount(self) -> None:
|
|
48
|
+
self.register_theme(DEFAULT_THEME)
|
|
49
|
+
self.theme = self._theme
|
|
51
50
|
self._update_bindings()
|
|
52
51
|
if self.inquiry_func:
|
|
53
52
|
self.run_worker(self.inquiry_func_worker, thread=True)
|
|
@@ -154,9 +153,6 @@ class InquirerApp(App[InquirerResult[T]], inherit_bindings=False): # type: igno
|
|
|
154
153
|
|
|
155
154
|
def get_theme_variable_defaults(self) -> dict[str, str]:
|
|
156
155
|
return {
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
'error-color': StandardTheme.error_color,
|
|
160
|
-
'select-list-item-highlight-foreground': StandardTheme.select_list_item_highlight_foreground,
|
|
161
|
-
'select-question-mark': StandardTheme.select_question_mark,
|
|
156
|
+
'inquirer-textual-question-mark': self.current_theme.foreground or 'initial',
|
|
157
|
+
'inquirer-textual-input-color': self.current_theme.foreground or 'initial',
|
|
162
158
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from rich.text import Text
|
|
2
|
+
from textual.app import ComposeResult
|
|
3
|
+
from textual.widget import Widget
|
|
4
|
+
from textual.widgets import Static
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Answer(Widget):
|
|
8
|
+
DEFAULT_CSS = """
|
|
9
|
+
Answer {
|
|
10
|
+
height: auto;
|
|
11
|
+
}
|
|
12
|
+
#inquirer-textual-answer {
|
|
13
|
+
color: $inquirer-textual-input-color;
|
|
14
|
+
}
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, text: str):
|
|
18
|
+
super().__init__()
|
|
19
|
+
self.text = text
|
|
20
|
+
|
|
21
|
+
def compose(self) -> ComposeResult:
|
|
22
|
+
yield Static(Text(self.text), id='inquirer-textual-answer')
|
|
@@ -4,24 +4,24 @@ from rich.text import Text
|
|
|
4
4
|
from textual.widgets import Label
|
|
5
5
|
|
|
6
6
|
from inquirer_textual.common.Choice import Choice
|
|
7
|
-
from inquirer_textual.common.
|
|
7
|
+
from inquirer_textual.common.defaults import DEFAULT_THEME, POINTER_CHARACTER
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ChoiceLabel(Label):
|
|
11
11
|
def __init__(self, item: str | Choice, pattern: str | None = None):
|
|
12
|
-
self._text =
|
|
12
|
+
self._text = self._get_text(item, pattern)
|
|
13
13
|
super().__init__(Text(' ').append_text(self._text))
|
|
14
14
|
self.item = item
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
def _get_text(cls, item: str | Choice, pattern: str | None = None) -> Text:
|
|
16
|
+
def _get_text(self, item: str | Choice, pattern: str | None = None) -> Text:
|
|
18
17
|
result = Text(item if isinstance(item, str) else item.name)
|
|
19
18
|
if pattern:
|
|
20
|
-
result.highlight_words([pattern], style=
|
|
19
|
+
result.highlight_words([pattern], style=self.app.current_theme.accent or DEFAULT_THEME.accent,
|
|
20
|
+
case_sensitive=False)
|
|
21
21
|
return result
|
|
22
22
|
|
|
23
23
|
def add_pointer(self):
|
|
24
|
-
self.update(Text(f'{
|
|
24
|
+
self.update(Text(f'{POINTER_CHARACTER} ').append_text(self._text))
|
|
25
25
|
|
|
26
26
|
def remove_pointer(self):
|
|
27
27
|
self.update(Text(' ').append_text(self._text))
|
|
@@ -4,9 +4,9 @@ from textual.widget import Widget
|
|
|
4
4
|
from textual.widgets import Static, Label
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class Prompt(Widget):
|
|
8
8
|
DEFAULT_CSS = """
|
|
9
|
-
|
|
9
|
+
Prompt {
|
|
10
10
|
width: auto;
|
|
11
11
|
height: auto;
|
|
12
12
|
}
|
|
@@ -16,7 +16,7 @@ class PromptMessage(Widget):
|
|
|
16
16
|
}
|
|
17
17
|
#prompt-message-question-mark {
|
|
18
18
|
width: auto;
|
|
19
|
-
color: $
|
|
19
|
+
color: $inquirer-textual-question-mark;
|
|
20
20
|
}
|
|
21
21
|
"""
|
|
22
22
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from textual.theme import Theme
|
|
2
|
+
|
|
3
|
+
DEFAULT_THEME = Theme(
|
|
4
|
+
name="inquirer-textual-default",
|
|
5
|
+
primary="#0178D4",
|
|
6
|
+
secondary="#004578",
|
|
7
|
+
accent="#c678dd",
|
|
8
|
+
warning="#ffa62b",
|
|
9
|
+
error="#e06c75",
|
|
10
|
+
success="#4EBF71",
|
|
11
|
+
foreground="#e0e0e0",
|
|
12
|
+
background="black",
|
|
13
|
+
surface="transparent",
|
|
14
|
+
variables={
|
|
15
|
+
'block-cursor-foreground': '#61afef',
|
|
16
|
+
'block-cursor-background': 'transparent',
|
|
17
|
+
'block-cursor-blurred-foreground': '#61afef',
|
|
18
|
+
'block-cursor-blurred-background': 'transparent',
|
|
19
|
+
'inquirer-textual-question-mark': '#e5c07b',
|
|
20
|
+
'inquirer-textual-input-color': '#98c379',
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
POINTER_CHARACTER = '\u276f'
|
inquirer_textual/prompts.py
CHANGED
|
@@ -42,7 +42,7 @@ def external(widget: InquirerWidget, clear: bool = False) -> Any:
|
|
|
42
42
|
return app.run(inline=True, inline_no_clear=not clear).value
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
def multi(widgets:
|
|
45
|
+
def multi(widgets: dict[str, InquirerWidget], clear: bool = False) -> dict[str, Any]:
|
|
46
46
|
app: InquirerApp[dict[str, Any]] = InquirerApp()
|
|
47
47
|
app.widget = InquirerMulti(widgets)
|
|
48
48
|
return app.run(inline=True, inline_no_clear=not clear).value
|
inquirer_textual/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
version = "0.
|
|
1
|
+
version = "0.4.0"
|
|
@@ -2,27 +2,19 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from textual.app import ComposeResult
|
|
4
4
|
from textual.containers import VerticalGroup, HorizontalGroup
|
|
5
|
-
from textual.widgets import ListItem, ListView
|
|
5
|
+
from textual.widgets import ListItem, ListView
|
|
6
6
|
from typing_extensions import Self
|
|
7
7
|
|
|
8
|
+
from inquirer_textual.common.Answer import Answer
|
|
8
9
|
from inquirer_textual.common.Choice import Choice
|
|
9
10
|
from inquirer_textual.common.ChoiceCheckboxLabel import ChoiceCheckboxLabel
|
|
10
|
-
from inquirer_textual.common.
|
|
11
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
11
12
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class InquirerCheckbox(InquirerWidget):
|
|
15
16
|
"""A checkbox widget that allows multiple selections from a list of choices."""
|
|
16
17
|
|
|
17
|
-
DEFAULT_CSS = """
|
|
18
|
-
#inquirer-checkbox-list-view {
|
|
19
|
-
background: transparent;
|
|
20
|
-
}
|
|
21
|
-
#inquirer-checkbox-list-view ListItem.-highlight {
|
|
22
|
-
color: $select-list-item-highlight-foreground;
|
|
23
|
-
background: transparent;
|
|
24
|
-
}
|
|
25
|
-
"""
|
|
26
18
|
BINDINGS = [
|
|
27
19
|
("space", "toggle_selected", "Toggle selection"),
|
|
28
20
|
]
|
|
@@ -81,8 +73,8 @@ class InquirerCheckbox(InquirerWidget):
|
|
|
81
73
|
def compose(self) -> ComposeResult:
|
|
82
74
|
if self.show_selected_value:
|
|
83
75
|
with HorizontalGroup():
|
|
84
|
-
yield
|
|
85
|
-
yield
|
|
76
|
+
yield Prompt(self.message)
|
|
77
|
+
yield Answer(str(self.selected_value))
|
|
86
78
|
else:
|
|
87
79
|
with VerticalGroup():
|
|
88
80
|
items: list[ListItem] = []
|
|
@@ -90,5 +82,5 @@ class InquirerCheckbox(InquirerWidget):
|
|
|
90
82
|
list_item = ListItem(ChoiceCheckboxLabel(choice))
|
|
91
83
|
items.append(list_item)
|
|
92
84
|
self.list_view = ListView(*items, id='inquirer-checkbox-list-view')
|
|
93
|
-
yield
|
|
85
|
+
yield Prompt(self.message)
|
|
94
86
|
yield self.list_view
|
|
@@ -5,7 +5,8 @@ from textual.app import ComposeResult
|
|
|
5
5
|
from textual.containers import HorizontalGroup
|
|
6
6
|
from textual.widgets import Label
|
|
7
7
|
|
|
8
|
-
from inquirer_textual.common.
|
|
8
|
+
from inquirer_textual.common.Answer import Answer
|
|
9
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
9
10
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
10
11
|
|
|
11
12
|
|
|
@@ -36,26 +37,41 @@ class InquirerConfirm(InquirerWidget):
|
|
|
36
37
|
if confirm_character.lower() == reject_character.lower():
|
|
37
38
|
raise ValueError("confirm_character and reject_character must be different")
|
|
38
39
|
self.message = message
|
|
40
|
+
self.confirm_character = confirm_character
|
|
41
|
+
self.reject_character = reject_character
|
|
39
42
|
c = confirm_character if not default else confirm_character.upper()
|
|
40
43
|
r = reject_character if default else reject_character.upper()
|
|
41
44
|
self.label = Label(f'({c}/{r})')
|
|
42
45
|
self.value: bool = default
|
|
46
|
+
self.selected_value: bool | None = None
|
|
47
|
+
self.show_selected_value: bool = False
|
|
43
48
|
|
|
44
49
|
def on_key(self, event: events.Key):
|
|
45
50
|
if event.key.lower() == 'y':
|
|
46
51
|
self.value = True
|
|
47
|
-
self.
|
|
52
|
+
self.submit_current_value()
|
|
48
53
|
elif event.key.lower() == 'n':
|
|
49
54
|
self.value = False
|
|
50
|
-
self.
|
|
55
|
+
self.submit_current_value()
|
|
51
56
|
elif event.key == 'enter':
|
|
52
57
|
event.stop()
|
|
53
|
-
self.
|
|
58
|
+
self.submit_current_value()
|
|
54
59
|
|
|
55
60
|
def current_value(self):
|
|
56
61
|
return self.value
|
|
57
62
|
|
|
63
|
+
async def set_selected_value(self, value: bool) -> None:
|
|
64
|
+
self.selected_value = value
|
|
65
|
+
self.styles.height = 1
|
|
66
|
+
self.show_selected_value = True
|
|
67
|
+
await self.recompose()
|
|
68
|
+
|
|
58
69
|
def compose(self) -> ComposeResult:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
if self.show_selected_value:
|
|
71
|
+
with HorizontalGroup():
|
|
72
|
+
yield Prompt(self.message)
|
|
73
|
+
yield Answer(self.confirm_character if self.selected_value else self.reject_character)
|
|
74
|
+
else:
|
|
75
|
+
with HorizontalGroup():
|
|
76
|
+
yield Prompt(self.message)
|
|
77
|
+
yield self.label
|
|
@@ -8,7 +8,7 @@ from textual.app import ComposeResult
|
|
|
8
8
|
from textual.containers import HorizontalGroup
|
|
9
9
|
from textual.widgets import Static
|
|
10
10
|
|
|
11
|
-
from inquirer_textual.common.
|
|
11
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
12
12
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
13
13
|
|
|
14
14
|
|
|
@@ -54,7 +54,7 @@ class InquirerEditor(InquirerWidget):
|
|
|
54
54
|
def compose(self) -> ComposeResult:
|
|
55
55
|
if self.message:
|
|
56
56
|
with HorizontalGroup():
|
|
57
|
-
yield
|
|
57
|
+
yield Prompt(self.message)
|
|
58
58
|
yield Static('[dim]Press <enter> to launch editor[/dim]')
|
|
59
59
|
else:
|
|
60
60
|
super().compose()
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
3
|
from textual.app import ComposeResult
|
|
4
|
-
from textual.widgets import ContentSwitcher
|
|
5
4
|
|
|
6
5
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
7
6
|
|
|
@@ -15,33 +14,32 @@ class InquirerMulti(InquirerWidget):
|
|
|
15
14
|
}
|
|
16
15
|
"""
|
|
17
16
|
|
|
18
|
-
def __init__(self, widgets:
|
|
17
|
+
def __init__(self, widgets: dict[str, InquirerWidget]) -> None:
|
|
19
18
|
"""
|
|
20
19
|
Args:
|
|
21
|
-
widgets (
|
|
20
|
+
widgets (dict[str, InquirerWidget]): A dictionary of InquirerWidget instances to present in sequence of definition.
|
|
22
21
|
"""
|
|
23
22
|
super().__init__()
|
|
24
23
|
self.widgets = widgets
|
|
25
24
|
self._current_widget_index = 0
|
|
26
25
|
self._return_values_dict: dict[str, Any] = {}
|
|
27
26
|
|
|
28
|
-
def
|
|
29
|
-
self.
|
|
30
|
-
self.
|
|
31
|
-
|
|
32
|
-
def on_inquirer_widget_submit(self, message: InquirerWidget.Submit) -> None:
|
|
33
|
-
current_widget = self.widgets[self._current_widget_index]
|
|
34
|
-
self._return_values_dict[current_widget[0]] = message.value
|
|
27
|
+
async def on_inquirer_widget_submit(self, message: InquirerWidget.Submit) -> None:
|
|
28
|
+
current_item = list(self.widgets.items())[self._current_widget_index]
|
|
29
|
+
self._return_values_dict[current_item[0]] = message.value
|
|
30
|
+
await current_item[1].set_selected_value(message.value)
|
|
35
31
|
self._current_widget_index += 1
|
|
36
32
|
if self._current_widget_index < len(self.widgets):
|
|
37
33
|
message.stop()
|
|
38
|
-
self.query_one(
|
|
39
|
-
|
|
34
|
+
next_widget = self.query_one(f'#widget-{self._current_widget_index}')
|
|
35
|
+
next_widget.styles.display = 'block'
|
|
36
|
+
next_widget.focus()
|
|
40
37
|
else:
|
|
41
38
|
message.value = self._return_values_dict
|
|
42
39
|
|
|
43
40
|
def compose(self) -> ComposeResult:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
for idx, item in enumerate(self.widgets.items()):
|
|
42
|
+
item[1].id = f'widget-{idx}'
|
|
43
|
+
if idx > 0:
|
|
44
|
+
item[1].styles.display = 'none'
|
|
45
|
+
yield item[1]
|
|
@@ -5,7 +5,7 @@ from textual.containers import HorizontalGroup
|
|
|
5
5
|
from textual.widgets import Input
|
|
6
6
|
from typing_extensions import Self, Literal
|
|
7
7
|
|
|
8
|
-
from inquirer_textual.common.
|
|
8
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
9
9
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
10
10
|
|
|
11
11
|
|
|
@@ -18,8 +18,7 @@ class InquirerNumber(InquirerWidget):
|
|
|
18
18
|
}
|
|
19
19
|
#inquirer-number-input {
|
|
20
20
|
border: none;
|
|
21
|
-
|
|
22
|
-
color: $input-color;
|
|
21
|
+
color: $inquirer-textual-input-color;
|
|
23
22
|
padding: 0;
|
|
24
23
|
height: 1;
|
|
25
24
|
}
|
|
@@ -58,6 +57,6 @@ class InquirerNumber(InquirerWidget):
|
|
|
58
57
|
|
|
59
58
|
def compose(self) -> ComposeResult:
|
|
60
59
|
with HorizontalGroup():
|
|
61
|
-
yield
|
|
60
|
+
yield Prompt(self.message)
|
|
62
61
|
self.input = Input(id="inquirer-number-input", type=self.input_type)
|
|
63
62
|
yield self.input
|
|
@@ -8,7 +8,7 @@ from textual.containers import HorizontalGroup
|
|
|
8
8
|
from textual.widgets import Input, Static
|
|
9
9
|
from typing_extensions import Self
|
|
10
10
|
|
|
11
|
-
from inquirer_textual.common.
|
|
11
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
12
12
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
13
13
|
|
|
14
14
|
|
|
@@ -27,13 +27,12 @@ class InquirerPath(InquirerWidget):
|
|
|
27
27
|
}
|
|
28
28
|
#inquirer-path-input {
|
|
29
29
|
border: none;
|
|
30
|
-
|
|
31
|
-
color: $input-color;
|
|
30
|
+
color: $inquirer-textual-input-color;
|
|
32
31
|
padding: 0;
|
|
33
32
|
height: 1;
|
|
34
33
|
}
|
|
35
34
|
#inquirer-path-error-message {
|
|
36
|
-
color: $error
|
|
35
|
+
color: $error;
|
|
37
36
|
height: auto;
|
|
38
37
|
}
|
|
39
38
|
"""
|
|
@@ -70,6 +69,9 @@ class InquirerPath(InquirerWidget):
|
|
|
70
69
|
if self.path_type == PathType.DIRECTORY and not path.is_dir():
|
|
71
70
|
self._show_validation_error("The specified path is not a directory.")
|
|
72
71
|
return
|
|
72
|
+
self._show_validation_error('')
|
|
73
|
+
if self.input:
|
|
74
|
+
self.input._cursor_visible = False
|
|
73
75
|
self.submit_current_value()
|
|
74
76
|
|
|
75
77
|
def _show_validation_error(self, message: str):
|
|
@@ -87,7 +89,7 @@ class InquirerPath(InquirerWidget):
|
|
|
87
89
|
|
|
88
90
|
def compose(self) -> ComposeResult:
|
|
89
91
|
with HorizontalGroup():
|
|
90
|
-
yield
|
|
92
|
+
yield Prompt(self.message)
|
|
91
93
|
self.input = Input(id="inquirer-path-input")
|
|
92
94
|
yield self.input
|
|
93
95
|
yield Static("", id="inquirer-path-error-message")
|
|
@@ -8,10 +8,11 @@ from textual.reactive import reactive
|
|
|
8
8
|
from textual.widgets import ListView, ListItem, Input, Static
|
|
9
9
|
from typing_extensions import Self
|
|
10
10
|
|
|
11
|
+
from inquirer_textual.common.Answer import Answer
|
|
11
12
|
from inquirer_textual.common.Choice import Choice
|
|
12
13
|
from inquirer_textual.common.ChoiceLabel import ChoiceLabel
|
|
13
|
-
from inquirer_textual.common.
|
|
14
|
-
from inquirer_textual.common.
|
|
14
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
15
|
+
from inquirer_textual.common.defaults import POINTER_CHARACTER
|
|
15
16
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
16
17
|
|
|
17
18
|
|
|
@@ -19,28 +20,19 @@ class InquirerPattern(InquirerWidget):
|
|
|
19
20
|
"""A select widget that allows a single selection from a list of choices with pattern filtering."""
|
|
20
21
|
|
|
21
22
|
DEFAULT_CSS = """
|
|
22
|
-
#inquirer-pattern-list-view {
|
|
23
|
-
background: transparent;
|
|
24
|
-
}
|
|
25
|
-
#inquirer-pattern-list-view ListItem.-highlight {
|
|
26
|
-
color: $select-list-item-highlight-foreground;
|
|
27
|
-
background: transparent;
|
|
28
|
-
}
|
|
29
23
|
#inquirer-pattern-query-container {
|
|
30
24
|
width: auto;
|
|
31
|
-
# border: red;
|
|
32
25
|
}
|
|
33
26
|
#inquirer-pattern-query {
|
|
34
27
|
border: none;
|
|
35
|
-
|
|
36
|
-
color: $input-color;
|
|
28
|
+
color: $inquirer-textual-input-color;
|
|
37
29
|
padding: 0;
|
|
38
30
|
height: 1;
|
|
39
31
|
width: 20;
|
|
40
32
|
}
|
|
41
33
|
#inquirer-pattern-query-pointer {
|
|
42
34
|
width: auto;
|
|
43
|
-
color: $
|
|
35
|
+
color: $accent;
|
|
44
36
|
}
|
|
45
37
|
"""
|
|
46
38
|
|
|
@@ -64,6 +56,8 @@ class InquirerPattern(InquirerWidget):
|
|
|
64
56
|
self.selected_item: str | Choice | None = None
|
|
65
57
|
self.default = default
|
|
66
58
|
self.query: Input | None = None
|
|
59
|
+
self.selected_value: str | Choice | None = None
|
|
60
|
+
self.show_selected_value: bool = False
|
|
67
61
|
|
|
68
62
|
def on_mount(self):
|
|
69
63
|
super().on_mount()
|
|
@@ -155,15 +149,27 @@ class InquirerPattern(InquirerWidget):
|
|
|
155
149
|
event.stop()
|
|
156
150
|
self.list_view.action_select_cursor()
|
|
157
151
|
|
|
152
|
+
async def set_selected_value(self, value: str | Choice) -> None:
|
|
153
|
+
self.selected_value = value
|
|
154
|
+
self.styles.height = 1
|
|
155
|
+
self.show_selected_value = True
|
|
156
|
+
await self.recompose()
|
|
157
|
+
|
|
158
158
|
def compose(self) -> ComposeResult:
|
|
159
|
-
|
|
160
|
-
self.list_view = ListView(*self._collect_list_items(), id='inquirer-pattern-list-view',
|
|
161
|
-
initial_index=self._find_initial_index())
|
|
159
|
+
if self.show_selected_value:
|
|
162
160
|
with HorizontalGroup():
|
|
163
|
-
yield
|
|
164
|
-
yield
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
self.
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
yield Prompt(self.message)
|
|
162
|
+
yield Answer(str(self.selected_value))
|
|
163
|
+
else:
|
|
164
|
+
with VerticalGroup():
|
|
165
|
+
self.list_view = ListView(*self._collect_list_items(), id='inquirer-pattern-list-view',
|
|
166
|
+
initial_index=self._find_initial_index())
|
|
167
|
+
with HorizontalGroup():
|
|
168
|
+
yield Prompt(self.message)
|
|
169
|
+
yield Static(f'[{len(self.candidates)}/{len(self.choices)}]',
|
|
170
|
+
id='inquirer-pattern-query-count-suffix')
|
|
171
|
+
with HorizontalGroup(id='inquirer-pattern-query-container'):
|
|
172
|
+
yield Static(f'{POINTER_CHARACTER} ', id='inquirer-pattern-query-pointer')
|
|
173
|
+
self.query = Input(id="inquirer-pattern-query")
|
|
174
|
+
yield self.query
|
|
175
|
+
yield self.list_view
|
|
@@ -5,7 +5,7 @@ from textual.containers import HorizontalGroup
|
|
|
5
5
|
from textual.widgets import Input
|
|
6
6
|
from typing_extensions import Self
|
|
7
7
|
|
|
8
|
-
from inquirer_textual.common.
|
|
8
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
9
9
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
10
10
|
|
|
11
11
|
|
|
@@ -18,8 +18,7 @@ class InquirerSecret(InquirerWidget):
|
|
|
18
18
|
}
|
|
19
19
|
#inquirer-secret-input {
|
|
20
20
|
border: none;
|
|
21
|
-
|
|
22
|
-
color: $input-color;
|
|
21
|
+
color: $inquirer-textual-input-color;
|
|
23
22
|
padding: 0;
|
|
24
23
|
height: 1;
|
|
25
24
|
}
|
|
@@ -48,7 +47,7 @@ class InquirerSecret(InquirerWidget):
|
|
|
48
47
|
|
|
49
48
|
def compose(self) -> ComposeResult:
|
|
50
49
|
with HorizontalGroup():
|
|
51
|
-
yield
|
|
50
|
+
yield Prompt(self.message)
|
|
52
51
|
self.input = Input(id="inquirer-secret-input")
|
|
53
52
|
self.input.password = True
|
|
54
53
|
yield self.input
|
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from textual.app import ComposeResult
|
|
4
|
-
from textual.containers import VerticalGroup
|
|
4
|
+
from textual.containers import VerticalGroup, HorizontalGroup
|
|
5
5
|
from textual.widgets import ListView, ListItem
|
|
6
6
|
from typing_extensions import Self
|
|
7
7
|
|
|
8
|
+
from inquirer_textual.common.Answer import Answer
|
|
8
9
|
from inquirer_textual.common.Choice import Choice
|
|
9
10
|
from inquirer_textual.common.ChoiceLabel import ChoiceLabel
|
|
10
|
-
from inquirer_textual.common.
|
|
11
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
11
12
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class InquirerSelect(InquirerWidget):
|
|
15
16
|
"""A select widget that allows a single selection from a list of choices."""
|
|
16
17
|
|
|
17
|
-
DEFAULT_CSS = """
|
|
18
|
-
#inquirer-select-list-view {
|
|
19
|
-
background: transparent;
|
|
20
|
-
}
|
|
21
|
-
#inquirer-select-list-view ListItem.-highlight {
|
|
22
|
-
color: $select-list-item-highlight-foreground;
|
|
23
|
-
background: transparent;
|
|
24
|
-
}
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
18
|
def __init__(self, message: str, choices: list[str | Choice], name: str | None = None,
|
|
28
19
|
default: str | Choice | None = None, mandatory: bool = True):
|
|
29
20
|
"""
|
|
@@ -40,6 +31,8 @@ class InquirerSelect(InquirerWidget):
|
|
|
40
31
|
self.selected_label: ChoiceLabel | None = None
|
|
41
32
|
self.selected_item: str | Choice | None = None
|
|
42
33
|
self.default = default
|
|
34
|
+
self.selected_value: str | Choice | None = None
|
|
35
|
+
self.show_selected_value: bool = False
|
|
43
36
|
|
|
44
37
|
def on_mount(self):
|
|
45
38
|
super().on_mount()
|
|
@@ -71,15 +64,26 @@ class InquirerSelect(InquirerWidget):
|
|
|
71
64
|
def current_value(self):
|
|
72
65
|
return self.selected_item
|
|
73
66
|
|
|
67
|
+
async def set_selected_value(self, value: str | Choice) -> None:
|
|
68
|
+
self.selected_value = value
|
|
69
|
+
self.styles.height = 1
|
|
70
|
+
self.show_selected_value = True
|
|
71
|
+
await self.recompose()
|
|
72
|
+
|
|
74
73
|
def compose(self) -> ComposeResult:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
if self.show_selected_value:
|
|
75
|
+
with HorizontalGroup():
|
|
76
|
+
yield Prompt(self.message)
|
|
77
|
+
yield Answer(str(self.selected_value))
|
|
78
|
+
else:
|
|
79
|
+
with VerticalGroup():
|
|
80
|
+
initial_index = 0
|
|
81
|
+
items: list[ListItem] = []
|
|
82
|
+
for idx, choice in enumerate(self.choices):
|
|
83
|
+
list_item = ListItem(ChoiceLabel(choice))
|
|
84
|
+
items.append(list_item)
|
|
85
|
+
if self.default and choice == self.default:
|
|
86
|
+
initial_index = idx
|
|
87
|
+
self.list_view = ListView(*items, id='inquirer-select-list-view', initial_index=initial_index)
|
|
88
|
+
yield Prompt(self.message)
|
|
89
|
+
yield self.list_view
|
|
@@ -8,7 +8,7 @@ from textual.validation import Validator
|
|
|
8
8
|
from textual.widgets import Input
|
|
9
9
|
from typing_extensions import Self
|
|
10
10
|
|
|
11
|
-
from inquirer_textual.common.
|
|
11
|
+
from inquirer_textual.common.Prompt import Prompt
|
|
12
12
|
from inquirer_textual.widgets.InquirerWidget import InquirerWidget
|
|
13
13
|
|
|
14
14
|
|
|
@@ -21,8 +21,7 @@ class InquirerText(InquirerWidget):
|
|
|
21
21
|
}
|
|
22
22
|
#inquirer-text-input {
|
|
23
23
|
border: none;
|
|
24
|
-
|
|
25
|
-
color: $input-color;
|
|
24
|
+
color: $inquirer-textual-input-color;
|
|
26
25
|
padding: 0;
|
|
27
26
|
height: 1;
|
|
28
27
|
}
|
|
@@ -65,6 +64,6 @@ class InquirerText(InquirerWidget):
|
|
|
65
64
|
|
|
66
65
|
def compose(self) -> ComposeResult:
|
|
67
66
|
with HorizontalGroup():
|
|
68
|
-
yield
|
|
67
|
+
yield Prompt(self.message)
|
|
69
68
|
self.input = Input(id="inquirer-text-input", validators=self.validators)
|
|
70
69
|
yield self.input
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: inquirer-textual
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Inquirer based on Textual
|
|
5
5
|
Project-URL: Changelog, https://github.com/robvanderleek/inquirer-textual/blob/master/CHANGELOG.md
|
|
6
6
|
Project-URL: Documentation, https://robvanderleek.github.io/inquirer-textual/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
inquirer_textual/InquirerApp.py,sha256=oOkEX0D_b5yOf67FXM7Bo7Y_ngbXy502r1YYl1ZCsdA,5863
|
|
2
|
+
inquirer_textual/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
inquirer_textual/prompts.py,sha256=QyePg_l3dF2StKANB2oz1H8z5AN3v_CqA7WhxyhONd8,4229
|
|
4
|
+
inquirer_textual/version.py,sha256=yhiWOz0HoJGRRI9-JQ2eh_0AbByy-6psK08-kpTSHJw,18
|
|
5
|
+
inquirer_textual/common/Answer.py,sha256=4d08uTd1MYxjBwIuWexAe0UOKStwxBqniPGuXc7VOJY,537
|
|
6
|
+
inquirer_textual/common/Choice.py,sha256=_0EGDbl6NGGiuOqCmfOkkmRX9IP09KQbRRmAdjPxwYs,203
|
|
7
|
+
inquirer_textual/common/ChoiceCheckboxLabel.py,sha256=BZg5vLe6_qc0ipYUaonNfygSOnHyJuEVrB8mmM6tOjw,675
|
|
8
|
+
inquirer_textual/common/ChoiceLabel.py,sha256=uJoHzMFCRE3cXCZlBLeMjADbHYHA81N03PyAfCf2y28,1009
|
|
9
|
+
inquirer_textual/common/InquirerHeader.py,sha256=txl-TRe3DKsOPcmDKy1fhfTa-YAURsjTYePDDHzcPH8,802
|
|
10
|
+
inquirer_textual/common/InquirerResult.py,sha256=2inNdfc2xUTCUFqAGazKJJv6YUQjjFzn-f3NTDxm1-M,481
|
|
11
|
+
inquirer_textual/common/Prompt.py,sha256=yv9RKFZwYkNOD_VMMhwEyPOZwmuEMIoJ85p25fyyn8Q,827
|
|
12
|
+
inquirer_textual/common/Shortcut.py,sha256=9mzLVnphImnehNo1HHU_gPMv-vFi5nXsb1G2CAbpuEY,297
|
|
13
|
+
inquirer_textual/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
inquirer_textual/common/defaults.py,sha256=JE59yeKgCi0q_Q64PreieGbwlZVFPd7hOm4e4Ks1HZ8,673
|
|
15
|
+
inquirer_textual/widgets/InquirerCheckbox.py,sha256=nlPLoEeLqhJ8gCLUFLdZsCW1A1zxu72ehDpU--XkBdY,3482
|
|
16
|
+
inquirer_textual/widgets/InquirerConfirm.py,sha256=bpub1HiXIPrdNkk9FQbm8i_U6_CguN1LS2Hje_Vgzsc,3026
|
|
17
|
+
inquirer_textual/widgets/InquirerEditor.py,sha256=f9H5iCevPOzJCYVIplAvedOgkmf-YVoBFwLiXn4u_58,1978
|
|
18
|
+
inquirer_textual/widgets/InquirerMulti.py,sha256=5xwkDA9T9wZB3OOh6w7ZUiW689-bASndpCXIowfOPU0,1616
|
|
19
|
+
inquirer_textual/widgets/InquirerNumber.py,sha256=6fH5V9tBj1G5BvTLWVpECLfGYRGbWCGMUHHK8g3BVVA,2083
|
|
20
|
+
inquirer_textual/widgets/InquirerPath.py,sha256=K862dhAc_F36w7cJgv3HxGdvOq44bbsISjPq-xw5NJQ,3158
|
|
21
|
+
inquirer_textual/widgets/InquirerPattern.py,sha256=z9EnwN6AawU0IH_e86Fpf-arkpyTl8nLMjsj1G5nBOc,6713
|
|
22
|
+
inquirer_textual/widgets/InquirerSecret.py,sha256=Auysoj98l6Km__fUAsTOMtq4EN_LJyYuye8cf04UXN8,1629
|
|
23
|
+
inquirer_textual/widgets/InquirerSelect.py,sha256=jLzww7O0ezf9OCBevAyeCih9KjUJHWZ7N-Uw2sGfa4E,3541
|
|
24
|
+
inquirer_textual/widgets/InquirerText.py,sha256=69xnsrmgcE1xKb_lmtQVWSFLlomvd0Fttk48kLF6_os,2279
|
|
25
|
+
inquirer_textual/widgets/InquirerWidget.py,sha256=TUU68Bef4A-S1bomgR0uFiVcQbfudrH-Vp9_h3WJgDg,1060
|
|
26
|
+
inquirer_textual/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
inquirer_textual-0.4.0.dist-info/METADATA,sha256=tsJd4eF71LuYH7XXIZL8_sr3M5UuP4Kmt3XzGYmfYQ4,2410
|
|
28
|
+
inquirer_textual-0.4.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
29
|
+
inquirer_textual-0.4.0.dist-info/licenses/LICENSE,sha256=fJuRou64yfkof3ZFdeHcgk7K8pqxis6SBr-vtUEgBuA,1073
|
|
30
|
+
inquirer_textual-0.4.0.dist-info/RECORD,,
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
inquirer_textual/InquirerApp.py,sha256=ohFn5KpnZmd0AQVNRC3Ll3EMrXn-nwmedReb8sBRRsY,5979
|
|
2
|
-
inquirer_textual/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
inquirer_textual/prompts.py,sha256=lEVWbel8GvqRCgxGcp5ki_tSNMgVD84eaqawwySqwr4,4236
|
|
4
|
-
inquirer_textual/version.py,sha256=EqIccytbgmIh3EOfv7QIiksdjJSlB-o2LbyXxRtoMGs,18
|
|
5
|
-
inquirer_textual/common/AppConfig.py,sha256=z4PN75ABDQBg8QpRrJrWwL_PD5KEdx2lV1mlp6PEm7I,187
|
|
6
|
-
inquirer_textual/common/Choice.py,sha256=_0EGDbl6NGGiuOqCmfOkkmRX9IP09KQbRRmAdjPxwYs,203
|
|
7
|
-
inquirer_textual/common/ChoiceCheckboxLabel.py,sha256=BZg5vLe6_qc0ipYUaonNfygSOnHyJuEVrB8mmM6tOjw,675
|
|
8
|
-
inquirer_textual/common/ChoiceLabel.py,sha256=23ZtQ4FKPD4EdiuRPtTYPB4TOcQmNGq1JfoOlGowYZg,970
|
|
9
|
-
inquirer_textual/common/InquirerHeader.py,sha256=txl-TRe3DKsOPcmDKy1fhfTa-YAURsjTYePDDHzcPH8,802
|
|
10
|
-
inquirer_textual/common/InquirerResult.py,sha256=2inNdfc2xUTCUFqAGazKJJv6YUQjjFzn-f3NTDxm1-M,481
|
|
11
|
-
inquirer_textual/common/PromptMessage.py,sha256=MCXdsE9j0XlqVKjWUhXB-9qZ24Lk7dA5QWRgUWTdF8o,831
|
|
12
|
-
inquirer_textual/common/Shortcut.py,sha256=9mzLVnphImnehNo1HHU_gPMv-vFi5nXsb1G2CAbpuEY,297
|
|
13
|
-
inquirer_textual/common/StandardTheme.py,sha256=4y0HWIqKDTl1xT9i3TdzRWcDo1oDjvI6Wbzt_XBz2jI,233
|
|
14
|
-
inquirer_textual/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
inquirer_textual/widgets/InquirerCheckbox.py,sha256=84DoTtTLBL61dxJRTq23KPRZYPMcYF6rfT2B41A1gNA,3785
|
|
16
|
-
inquirer_textual/widgets/InquirerConfirm.py,sha256=oJSssC8L7_fWUqBJ46KLxwXajo8ZRVAdTNuxgWq-zvY,2432
|
|
17
|
-
inquirer_textual/widgets/InquirerEditor.py,sha256=n6SfKcaE2sNz8r_jvc9FvCWRyM8bHJcGj8Z5bQkgdnw,1999
|
|
18
|
-
inquirer_textual/widgets/InquirerMulti.py,sha256=wgrngSbbmJ4aTDig0_RTopYH8brTM4jPNvAKL7UZpZs,1754
|
|
19
|
-
inquirer_textual/widgets/InquirerNumber.py,sha256=mS5h0vi0W3q0JJwQxZEjAfoH-ARLoxMdrcffy9ANCSY,2120
|
|
20
|
-
inquirer_textual/widgets/InquirerPath.py,sha256=qiKkoWMS8yOVyOA82oezbrSvpUU4xIZxkOJMRR59FmY,3091
|
|
21
|
-
inquirer_textual/widgets/InquirerPattern.py,sha256=uyN6PchvPKOvQ7sSwYHnmDaplJMZwAVc7qnG7P0zCVo,6428
|
|
22
|
-
inquirer_textual/widgets/InquirerSecret.py,sha256=K2gZ-KsSjYZD-xPQa9PVqtlvIiQ17_X0ujGMnfBhWmo,1666
|
|
23
|
-
inquirer_textual/widgets/InquirerSelect.py,sha256=IsCDwLXTbzKMfwd-jjBdeRY3_734QOjoaJrjbGy3lMU,3237
|
|
24
|
-
inquirer_textual/widgets/InquirerText.py,sha256=xc21nreIFH-8YkuQfanQPsiLbLATfHVK7ggtTuWYU7Y,2316
|
|
25
|
-
inquirer_textual/widgets/InquirerWidget.py,sha256=TUU68Bef4A-S1bomgR0uFiVcQbfudrH-Vp9_h3WJgDg,1060
|
|
26
|
-
inquirer_textual/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
inquirer_textual-0.3.0.dist-info/METADATA,sha256=xdacOD3xrAWACJBJkN_jhPT4UNfGCGFW7v-Jz1Fhaps,2410
|
|
28
|
-
inquirer_textual-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
29
|
-
inquirer_textual-0.3.0.dist-info/licenses/LICENSE,sha256=fJuRou64yfkof3ZFdeHcgk7K8pqxis6SBr-vtUEgBuA,1073
|
|
30
|
-
inquirer_textual-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|