We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2b8b7c1 + b9f2382 commit 14a4ad4Copy full SHA for 14a4ad4
CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
10
### Fixed
11
12
- Fixed validator not running on first reactive set https://github.com/Textualize/textual/pull/1359
13
+- Ensure only printable characters are used as key_display https://github.com/Textualize/textual/pull/1361
14
15
## [0.6.0] - 2022-12-11
16
docs/examples/widgets/footer.py
@@ -12,6 +12,7 @@ class FooterApp(App):
description="Show help screen",
key_display="?",
),
+ Binding(key="delete", action="delete", description="Delete the thing"),
Binding(key="j", action="down", description="Scroll down", show=False),
17
]
18
examples/five_by_five.py
@@ -166,10 +166,10 @@ class Game(Screen):
166
Binding("n", "new_game", "New Game"),
167
Binding("question_mark", "push_screen('help')", "Help", key_display="?"),
168
Binding("q", "quit", "Quit"),
169
- Binding("up,w,k", "navigate(-1,0)", "Move Up", False),
170
- Binding("down,s,j", "navigate(1,0)", "Move Down", False),
171
- Binding("left,a,h", "navigate(0,-1)", "Move Left", False),
172
- Binding("right,d,l", "navigate(0,1)", "Move Right", False),
+ Binding("up,w,k", "navigate(-1,0)", "Move Up", False, universal=True),
+ Binding("down,s,j", "navigate(1,0)", "Move Down", False, universal=True),
+ Binding("left,a,h", "navigate(0,-1)", "Move Left", False, universal=True),
+ Binding("right,d,l", "navigate(0,1)", "Move Right", False, universal=True),
173
Binding("space", "move", "Toggle", False),
174
175
"""The bindings for the main game grid."""
src/textual/_typing.py
@@ -9,3 +9,5 @@
9
from typing import Final, Literal, Protocol, TypedDict
else:
from typing_extensions import Final, Literal, Protocol, TypedDict
+
+__all__ = ["TypeAlias", "Final", "Literal", "Protocol", "TypedDict"]
src/textual/app.py
@@ -63,7 +63,7 @@
63
from .reactive import Reactive
64
from .renderables.blank import Blank
65
from .screen import Screen
66
-from .widget import AwaitMount, MountError, Widget
+from .widget import AwaitMount, Widget
67
68
69
if TYPE_CHECKING:
src/textual/binding.py
@@ -75,7 +75,7 @@ def __rich_repr__(self) -> rich.repr.Result:
75
76
@classmethod
77
def merge(cls, bindings: Iterable[Bindings]) -> Bindings:
78
- """Merge a bindings. Subsequence bound keys override initial keys.
+ """Merge a bindings. Subsequent bound keys override initial keys.
79
80
Args:
81
bindings (Iterable[Bindings]): A number of bindings.
src/textual/keys.py
@@ -245,9 +245,14 @@ def _get_key_display(key: str) -> str:
245
return display_alias
246
247
original_key = REPLACED_KEYS.get(key, key)
248
+ upper_original = original_key.upper().replace("_", " ")
249
try:
- unicode_character = unicodedata.lookup(original_key.upper().replace("_", " "))
250
+ unicode_character = unicodedata.lookup(upper_original)
251
except KeyError:
- return original_key.upper()
252
+ return upper_original
253
- return unicode_character
254
+ # Check if printable. `delete` for example maps to a control sequence
255
+ # which we don't want to write to the terminal.
256
+ if unicode_character.isprintable():
257
+ return unicode_character
258
tests/snapshot_tests/__snapshots__/test_snapshots.ambr
0 commit comments