Skip to content

Commit 5b60fa8

Browse files
authored
feat: persistent elements (#103)
* feat: persistent elements * chore: updating dependencies
1 parent ba6673d commit 5b60fa8

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

beaupy/_beaupy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ class Config:
7979
raise_on_escape(bool): If True, functions will raise Abort whenever the escape key is encountered when waiting for input, otherwise,
8080
they will return some sane alternative to their usual return. For `select`, `prompt` and `confirm` this means `None`, while for
8181
`select_multiple` it means an empty list - `[]`. Defaults to False.
82+
transient(bool): If False, elements will remain displayed after its context has ended. Defaults to True.
8283
"""
8384

8485
raise_on_interrupt: bool = False
8586
raise_on_escape: bool = False
87+
transient: bool = False
8688

8789

8890
_navigation_keys = [DefaultKeys.up, DefaultKeys.down, DefaultKeys.right, DefaultKeys.left, DefaultKeys.home, DefaultKeys.end]
@@ -212,6 +214,7 @@ def prompt(
212214
cursor_position=len(initial_value or ''),
213215
),
214216
renderer=renderer,
217+
transient=Config.transient
215218
)
216219

217220
with element.displayed():
@@ -304,6 +307,7 @@ def select(
304307
page_size=page_size,
305308
),
306309
renderer=renderer,
310+
transient=Config.transient
307311
)
308312

309313
with element.displayed():
@@ -397,6 +401,7 @@ def select_multiple(
397401
page_size=page_size,
398402
),
399403
renderer=renderer,
404+
transient=Config.transient
400405
)
401406

402407
with element.displayed():
@@ -445,7 +450,7 @@ def confirm(
445450
Optional[bool]
446451
"""
447452
rendered = ''
448-
with _cursor_hidden(console), Live(rendered, console=console, auto_refresh=False, transient=True) as live:
453+
with _cursor_hidden(console), Live(rendered, console=console, auto_refresh=False, transient=Config.transient) as live:
449454
if cursor_style in ['', None]:
450455
warnings.warn('`cursor_style` should be a valid style, defaulting to `white`')
451456
cursor_style = 'white'

poetry.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = 'beaupy'
3-
version = '3.8.3.post1'
3+
version = '3.9.0'
44
description = 'A library of elements for interactive TUIs in Python'
55
authors = ['Peter Vyboch <[email protected]>']
66
license = 'MIT'
@@ -40,7 +40,7 @@ python = ">=3.7.8,<4.0.0"
4040
rich = ">=12.2.0"
4141
emoji = "^2.0.0"
4242
python-yakh = "0.3.2"
43-
questo = "^0.2.3"
43+
questo = "^0.3.0"
4444

4545
[tool.mypy]
4646
files = ["src"]

0 commit comments

Comments
 (0)