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 75c9fba + b9f2382 commit 4310531Copy full SHA for 4310531
CHANGELOG.md
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
and this project adheres to [Semantic Versioning](http://semver.org/).
7
8
+## Unreleased
9
+
10
+### Fixed
11
12
+- Ensure only printable characters are used as key_display https://github.com/Textualize/textual/pull/1361
13
14
## [0.6.0] - 2022-12-11
15
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"),
16
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 @@
from typing import Final, Literal, Protocol, TypedDict
else:
from typing_extensions import Final, Literal, Protocol, TypedDict
+__all__ = ["TypeAlias", "Final", "Literal", "Protocol", "TypedDict"]
src/textual/binding.py
@@ -93,7 +93,7 @@ def __rich_repr__(self) -> rich.repr.Result:
93
94
@classmethod
95
def merge(cls, bindings: Iterable[Bindings]) -> Bindings:
96
- """Merge a bindings. Subsequence bound keys override initial keys.
+ """Merge a bindings. Subsequent bound keys override initial keys.
97
98
Args:
99
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