fix for point key and keys in screenshot

This commit is contained in:
Will McGugan
2022-10-21 10:15:41 +01:00
parent c035af3054
commit 2358d9d568
3 changed files with 13 additions and 1 deletions

View File

@@ -2,4 +2,7 @@
{% block extrahead %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/fira_code.min.css" integrity="sha512-MbysAYimH1hH2xYzkkMHB6MqxBqfP0megxsCLknbYqHVwXTCg9IqHbk+ZP/vnhO8UEW6PaXAkKe2vQ+SWACxxA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Fathom - beautiful, simple website analytics -->
<script src="https://cdn.usefathom.com/script.js" data-site="TAUKXRLQ" defer></script>
<!-- / Fathom -->
{% endblock %}

View File

@@ -24,6 +24,7 @@ class CalculatorApp(App):
"asterisk": "multiply",
"slash": "divide",
"underscore": "plus-minus",
"full_stop": "point",
"plus_minus_sign": "plus-minus",
"percent_sign": "percent",
"equals_sign": "equals",

View File

@@ -612,6 +612,13 @@ class App(Generic[ReturnType], DOMNode):
print(f"(pause {wait_ms}ms)")
await asyncio.sleep(float(wait_ms) / 1000)
else:
if len(key) == 1 and not key.isalnum():
key = (
unicodedata.name(key)
.lower()
.replace("-", "_")
.replace(" ", "_")
)
original_key = REPLACED_KEYS.get(key, key)
try:
char = unicodedata.lookup(
@@ -620,7 +627,8 @@ class App(Generic[ReturnType], DOMNode):
except KeyError:
char = key if len(key) == 1 else None
print(f"press {key!r} (char={char!r})")
driver.send_event(events.Key(self, key, char))
key_event = events.Key(self, key, char)
driver.send_event(key_event)
await asyncio.sleep(0.01)
await app._animator.wait_for_idle()