Merge branch 'main' into bug/1342/inherited-movement-keys

This commit is contained in:
Dave Pearson
2022-12-15 14:28:03 +00:00
7 changed files with 79 additions and 66 deletions

View File

@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased
### Fixed
- Ensure only printable characters are used as key_display https://github.com/Textualize/textual/pull/1361
## [0.6.0] - 2022-12-11

View File

@@ -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),
]

View File

@@ -166,10 +166,10 @@ class Game(Screen):
Binding("n", "new_game", "New Game"),
Binding("question_mark", "push_screen('help')", "Help", key_display="?"),
Binding("q", "quit", "Quit"),
Binding("up,w,k", "navigate(-1,0)", "Move Up", False),
Binding("down,s,j", "navigate(1,0)", "Move Down", False),
Binding("left,a,h", "navigate(0,-1)", "Move Left", False),
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),
Binding("space", "move", "Toggle", False),
]
"""The bindings for the main game grid."""

View File

@@ -9,3 +9,5 @@ if sys.version_info >= (3, 8):
from typing import Final, Literal, Protocol, TypedDict
else:
from typing_extensions import Final, Literal, Protocol, TypedDict
__all__ = ["TypeAlias", "Final", "Literal", "Protocol", "TypedDict"]

View File

@@ -93,7 +93,7 @@ class Bindings:
@classmethod
def merge(cls, bindings: Iterable[Bindings]) -> Bindings:
"""Merge a bindings. Subsequence bound keys override initial keys.
"""Merge a bindings. Subsequent bound keys override initial keys.
Args:
bindings (Iterable[Bindings]): A number of bindings.

View File

@@ -245,9 +245,14 @@ def _get_key_display(key: str) -> str:
return display_alias
original_key = REPLACED_KEYS.get(key, key)
upper_original = original_key.upper().replace("_", " ")
try:
unicode_character = unicodedata.lookup(original_key.upper().replace("_", " "))
unicode_character = unicodedata.lookup(upper_original)
except KeyError:
return original_key.upper()
return upper_original
return unicode_character
# Check if printable. `delete` for example maps to a control sequence
# which we don't want to write to the terminal.
if unicode_character.isprintable():
return unicode_character
return upper_original

View File

@@ -5104,134 +5104,134 @@
font-weight: 700;
}
.terminal-1908614482-matrix {
.terminal-1971839132-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
.terminal-1908614482-title {
.terminal-1971839132-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
.terminal-1908614482-r1 { fill: #e1e1e1 }
.terminal-1908614482-r2 { fill: #c5c8c6 }
.terminal-1908614482-r3 { fill: #dde8f3;font-weight: bold }
.terminal-1908614482-r4 { fill: #ddedf9 }
.terminal-1971839132-r1 { fill: #e1e1e1 }
.terminal-1971839132-r2 { fill: #c5c8c6 }
.terminal-1971839132-r3 { fill: #dde8f3;font-weight: bold }
.terminal-1971839132-r4 { fill: #ddedf9 }
</style>
<defs>
<clipPath id="terminal-1908614482-clip-terminal">
<clipPath id="terminal-1971839132-clip-terminal">
<rect x="0" y="0" width="975.0" height="584.5999999999999" />
</clipPath>
<clipPath id="terminal-1908614482-line-0">
<clipPath id="terminal-1971839132-line-0">
<rect x="0" y="1.5" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-1">
<clipPath id="terminal-1971839132-line-1">
<rect x="0" y="25.9" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-2">
<clipPath id="terminal-1971839132-line-2">
<rect x="0" y="50.3" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-3">
<clipPath id="terminal-1971839132-line-3">
<rect x="0" y="74.7" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-4">
<clipPath id="terminal-1971839132-line-4">
<rect x="0" y="99.1" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-5">
<clipPath id="terminal-1971839132-line-5">
<rect x="0" y="123.5" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-6">
<clipPath id="terminal-1971839132-line-6">
<rect x="0" y="147.9" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-7">
<clipPath id="terminal-1971839132-line-7">
<rect x="0" y="172.3" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-8">
<clipPath id="terminal-1971839132-line-8">
<rect x="0" y="196.7" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-9">
<clipPath id="terminal-1971839132-line-9">
<rect x="0" y="221.1" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-10">
<clipPath id="terminal-1971839132-line-10">
<rect x="0" y="245.5" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-11">
<clipPath id="terminal-1971839132-line-11">
<rect x="0" y="269.9" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-12">
<clipPath id="terminal-1971839132-line-12">
<rect x="0" y="294.3" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-13">
<clipPath id="terminal-1971839132-line-13">
<rect x="0" y="318.7" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-14">
<clipPath id="terminal-1971839132-line-14">
<rect x="0" y="343.1" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-15">
<clipPath id="terminal-1971839132-line-15">
<rect x="0" y="367.5" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-16">
<clipPath id="terminal-1971839132-line-16">
<rect x="0" y="391.9" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-17">
<clipPath id="terminal-1971839132-line-17">
<rect x="0" y="416.3" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-18">
<clipPath id="terminal-1971839132-line-18">
<rect x="0" y="440.7" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-19">
<clipPath id="terminal-1971839132-line-19">
<rect x="0" y="465.1" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-20">
<clipPath id="terminal-1971839132-line-20">
<rect x="0" y="489.5" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-21">
<clipPath id="terminal-1971839132-line-21">
<rect x="0" y="513.9" width="976" height="24.65"/>
</clipPath>
<clipPath id="terminal-1908614482-line-22">
<clipPath id="terminal-1971839132-line-22">
<rect x="0" y="538.3" width="976" height="24.65"/>
</clipPath>
</defs>
<rect fill="#292929" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="1" y="1" width="992" height="633.6" rx="8"/><text class="terminal-1908614482-title" fill="#c5c8c6" text-anchor="middle" x="496" y="27">FooterApp</text>
<rect fill="#292929" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="1" y="1" width="992" height="633.6" rx="8"/><text class="terminal-1971839132-title" fill="#c5c8c6" text-anchor="middle" x="496" y="27">FooterApp</text>
<g transform="translate(26,22)">
<circle cx="0" cy="0" r="7" fill="#ff5f57"/>
<circle cx="22" cy="0" r="7" fill="#febc2e"/>
<circle cx="44" cy="0" r="7" fill="#28c840"/>
</g>
<g transform="translate(9, 41)" clip-path="url(#terminal-1908614482-clip-terminal)">
<rect fill="#1e1e1e" x="0" y="1.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="25.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="50.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="74.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="99.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="123.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="147.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="172.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="196.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="221.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="245.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="269.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="294.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="318.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="343.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="367.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="391.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="416.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="440.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="465.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="489.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="513.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="538.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="0" y="562.7" width="36.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0178d4" x="36.6" y="562.7" width="170.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="207.4" y="562.7" width="36.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0178d4" x="244" y="562.7" width="219.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0178d4" x="463.6" y="562.7" width="512.4" height="24.65" shape-rendering="crispEdges"/>
<g class="terminal-1908614482-matrix">
<text class="terminal-1908614482-r2" x="976" y="20" textLength="12.2" clip-path="url(#terminal-1908614482-line-0)">
</text><text class="terminal-1908614482-r2" x="976" y="44.4" textLength="12.2" clip-path="url(#terminal-1908614482-line-1)">
</text><text class="terminal-1908614482-r2" x="976" y="68.8" textLength="12.2" clip-path="url(#terminal-1908614482-line-2)">
</text><text class="terminal-1908614482-r2" x="976" y="93.2" textLength="12.2" clip-path="url(#terminal-1908614482-line-3)">
</text><text class="terminal-1908614482-r2" x="976" y="117.6" textLength="12.2" clip-path="url(#terminal-1908614482-line-4)">
</text><text class="terminal-1908614482-r2" x="976" y="142" textLength="12.2" clip-path="url(#terminal-1908614482-line-5)">
</text><text class="terminal-1908614482-r2" x="976" y="166.4" textLength="12.2" clip-path="url(#terminal-1908614482-line-6)">
</text><text class="terminal-1908614482-r2" x="976" y="190.8" textLength="12.2" clip-path="url(#terminal-1908614482-line-7)">
</text><text class="terminal-1908614482-r2" x="976" y="215.2" textLength="12.2" clip-path="url(#terminal-1908614482-line-8)">
</text><text class="terminal-1908614482-r2" x="976" y="239.6" textLength="12.2" clip-path="url(#terminal-1908614482-line-9)">
</text><text class="terminal-1908614482-r2" x="976" y="264" textLength="12.2" clip-path="url(#terminal-1908614482-line-10)">
</text><text class="terminal-1908614482-r2" x="976" y="288.4" textLength="12.2" clip-path="url(#terminal-1908614482-line-11)">
</text><text class="terminal-1908614482-r2" x="976" y="312.8" textLength="12.2" clip-path="url(#terminal-1908614482-line-12)">
</text><text class="terminal-1908614482-r2" x="976" y="337.2" textLength="12.2" clip-path="url(#terminal-1908614482-line-13)">
</text><text class="terminal-1908614482-r2" x="976" y="361.6" textLength="12.2" clip-path="url(#terminal-1908614482-line-14)">
</text><text class="terminal-1908614482-r2" x="976" y="386" textLength="12.2" clip-path="url(#terminal-1908614482-line-15)">
</text><text class="terminal-1908614482-r2" x="976" y="410.4" textLength="12.2" clip-path="url(#terminal-1908614482-line-16)">
</text><text class="terminal-1908614482-r2" x="976" y="434.8" textLength="12.2" clip-path="url(#terminal-1908614482-line-17)">
</text><text class="terminal-1908614482-r2" x="976" y="459.2" textLength="12.2" clip-path="url(#terminal-1908614482-line-18)">
</text><text class="terminal-1908614482-r2" x="976" y="483.6" textLength="12.2" clip-path="url(#terminal-1908614482-line-19)">
</text><text class="terminal-1908614482-r2" x="976" y="508" textLength="12.2" clip-path="url(#terminal-1908614482-line-20)">
</text><text class="terminal-1908614482-r2" x="976" y="532.4" textLength="12.2" clip-path="url(#terminal-1908614482-line-21)">
</text><text class="terminal-1908614482-r2" x="976" y="556.8" textLength="12.2" clip-path="url(#terminal-1908614482-line-22)">
</text><text class="terminal-1908614482-r3" x="0" y="581.2" textLength="36.6" clip-path="url(#terminal-1908614482-line-23)">&#160;Q&#160;</text><text class="terminal-1908614482-r4" x="36.6" y="581.2" textLength="170.8" clip-path="url(#terminal-1908614482-line-23)">&#160;Quit&#160;the&#160;app&#160;</text><text class="terminal-1908614482-r3" x="207.4" y="581.2" textLength="36.6" clip-path="url(#terminal-1908614482-line-23)">&#160;?&#160;</text><text class="terminal-1908614482-r4" x="244" y="581.2" textLength="219.6" clip-path="url(#terminal-1908614482-line-23)">&#160;Show&#160;help&#160;screen&#160;</text>
<g transform="translate(9, 41)" clip-path="url(#terminal-1971839132-clip-terminal)">
<rect fill="#1e1e1e" x="0" y="1.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="25.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="50.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="74.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="99.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="123.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="147.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="172.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="196.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="221.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="245.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="269.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="294.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="318.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="343.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="367.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="391.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="416.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="440.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="465.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="489.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="513.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="538.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="0" y="562.7" width="36.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0178d4" x="36.6" y="562.7" width="170.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="207.4" y="562.7" width="36.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0178d4" x="244" y="562.7" width="219.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0053aa" x="463.6" y="562.7" width="97.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0178d4" x="561.2" y="562.7" width="219.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#0178d4" x="780.8" y="562.7" width="195.2" height="24.65" shape-rendering="crispEdges"/>
<g class="terminal-1971839132-matrix">
<text class="terminal-1971839132-r2" x="976" y="20" textLength="12.2" clip-path="url(#terminal-1971839132-line-0)">
</text><text class="terminal-1971839132-r2" x="976" y="44.4" textLength="12.2" clip-path="url(#terminal-1971839132-line-1)">
</text><text class="terminal-1971839132-r2" x="976" y="68.8" textLength="12.2" clip-path="url(#terminal-1971839132-line-2)">
</text><text class="terminal-1971839132-r2" x="976" y="93.2" textLength="12.2" clip-path="url(#terminal-1971839132-line-3)">
</text><text class="terminal-1971839132-r2" x="976" y="117.6" textLength="12.2" clip-path="url(#terminal-1971839132-line-4)">
</text><text class="terminal-1971839132-r2" x="976" y="142" textLength="12.2" clip-path="url(#terminal-1971839132-line-5)">
</text><text class="terminal-1971839132-r2" x="976" y="166.4" textLength="12.2" clip-path="url(#terminal-1971839132-line-6)">
</text><text class="terminal-1971839132-r2" x="976" y="190.8" textLength="12.2" clip-path="url(#terminal-1971839132-line-7)">
</text><text class="terminal-1971839132-r2" x="976" y="215.2" textLength="12.2" clip-path="url(#terminal-1971839132-line-8)">
</text><text class="terminal-1971839132-r2" x="976" y="239.6" textLength="12.2" clip-path="url(#terminal-1971839132-line-9)">
</text><text class="terminal-1971839132-r2" x="976" y="264" textLength="12.2" clip-path="url(#terminal-1971839132-line-10)">
</text><text class="terminal-1971839132-r2" x="976" y="288.4" textLength="12.2" clip-path="url(#terminal-1971839132-line-11)">
</text><text class="terminal-1971839132-r2" x="976" y="312.8" textLength="12.2" clip-path="url(#terminal-1971839132-line-12)">
</text><text class="terminal-1971839132-r2" x="976" y="337.2" textLength="12.2" clip-path="url(#terminal-1971839132-line-13)">
</text><text class="terminal-1971839132-r2" x="976" y="361.6" textLength="12.2" clip-path="url(#terminal-1971839132-line-14)">
</text><text class="terminal-1971839132-r2" x="976" y="386" textLength="12.2" clip-path="url(#terminal-1971839132-line-15)">
</text><text class="terminal-1971839132-r2" x="976" y="410.4" textLength="12.2" clip-path="url(#terminal-1971839132-line-16)">
</text><text class="terminal-1971839132-r2" x="976" y="434.8" textLength="12.2" clip-path="url(#terminal-1971839132-line-17)">
</text><text class="terminal-1971839132-r2" x="976" y="459.2" textLength="12.2" clip-path="url(#terminal-1971839132-line-18)">
</text><text class="terminal-1971839132-r2" x="976" y="483.6" textLength="12.2" clip-path="url(#terminal-1971839132-line-19)">
</text><text class="terminal-1971839132-r2" x="976" y="508" textLength="12.2" clip-path="url(#terminal-1971839132-line-20)">
</text><text class="terminal-1971839132-r2" x="976" y="532.4" textLength="12.2" clip-path="url(#terminal-1971839132-line-21)">
</text><text class="terminal-1971839132-r2" x="976" y="556.8" textLength="12.2" clip-path="url(#terminal-1971839132-line-22)">
</text><text class="terminal-1971839132-r3" x="0" y="581.2" textLength="36.6" clip-path="url(#terminal-1971839132-line-23)">&#160;Q&#160;</text><text class="terminal-1971839132-r4" x="36.6" y="581.2" textLength="170.8" clip-path="url(#terminal-1971839132-line-23)">&#160;Quit&#160;the&#160;app&#160;</text><text class="terminal-1971839132-r3" x="207.4" y="581.2" textLength="36.6" clip-path="url(#terminal-1971839132-line-23)">&#160;?&#160;</text><text class="terminal-1971839132-r4" x="244" y="581.2" textLength="219.6" clip-path="url(#terminal-1971839132-line-23)">&#160;Show&#160;help&#160;screen&#160;</text><text class="terminal-1971839132-r3" x="463.6" y="581.2" textLength="97.6" clip-path="url(#terminal-1971839132-line-23)">&#160;DELETE&#160;</text><text class="terminal-1971839132-r4" x="561.2" y="581.2" textLength="219.6" clip-path="url(#terminal-1971839132-line-23)">&#160;Delete&#160;the&#160;thing&#160;</text>
</g>
</g>
</svg>