Skip to content

Commit 14a4ad4

Browse files
authored
Merge branch 'main' into validator-first-set
2 parents 2b8b7c1 + b9f2382 commit 14a4ad4

File tree

8 files changed

+76
-67
lines changed

8 files changed

+76
-67
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111

1212
- 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
1314

1415
## [0.6.0] - 2022-12-11
1516

docs/examples/widgets/footer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class FooterApp(App):
1212
description="Show help screen",
1313
key_display="?",
1414
),
15+
Binding(key="delete", action="delete", description="Delete the thing"),
1516
Binding(key="j", action="down", description="Scroll down", show=False),
1617
]
1718

examples/five_by_five.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ class Game(Screen):
166166
Binding("n", "new_game", "New Game"),
167167
Binding("question_mark", "push_screen('help')", "Help", key_display="?"),
168168
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),
169+
Binding("up,w,k", "navigate(-1,0)", "Move Up", False, universal=True),
170+
Binding("down,s,j", "navigate(1,0)", "Move Down", False, universal=True),
171+
Binding("left,a,h", "navigate(0,-1)", "Move Left", False, universal=True),
172+
Binding("right,d,l", "navigate(0,1)", "Move Right", False, universal=True),
173173
Binding("space", "move", "Toggle", False),
174174
]
175175
"""The bindings for the main game grid."""

src/textual/_typing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
from typing import Final, Literal, Protocol, TypedDict
1010
else:
1111
from typing_extensions import Final, Literal, Protocol, TypedDict
12+
13+
__all__ = ["TypeAlias", "Final", "Literal", "Protocol", "TypedDict"]

src/textual/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
from .reactive import Reactive
6464
from .renderables.blank import Blank
6565
from .screen import Screen
66-
from .widget import AwaitMount, MountError, Widget
66+
from .widget import AwaitMount, Widget
6767

6868

6969
if TYPE_CHECKING:

src/textual/binding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __rich_repr__(self) -> rich.repr.Result:
7575

7676
@classmethod
7777
def merge(cls, bindings: Iterable[Bindings]) -> Bindings:
78-
"""Merge a bindings. Subsequence bound keys override initial keys.
78+
"""Merge a bindings. Subsequent bound keys override initial keys.
7979
8080
Args:
8181
bindings (Iterable[Bindings]): A number of bindings.

src/textual/keys.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,14 @@ def _get_key_display(key: str) -> str:
245245
return display_alias
246246

247247
original_key = REPLACED_KEYS.get(key, key)
248+
upper_original = original_key.upper().replace("_", " ")
248249
try:
249-
unicode_character = unicodedata.lookup(original_key.upper().replace("_", " "))
250+
unicode_character = unicodedata.lookup(upper_original)
250251
except KeyError:
251-
return original_key.upper()
252+
return upper_original
252253

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+
return upper_original

tests/snapshot_tests/__snapshots__/test_snapshots.ambr

Lines changed: 58 additions & 58 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)