Compare commits

...

3 commits

Author SHA1 Message Date
cd0a7912bb
Merge pull request #12 from jepler/cancel-search-etc
Cancel search on F9 or Esc press
2024-05-23 07:40:09 -04:00
b42a8c08cd ESC and F9 clear any in-progress search 2024-05-23 07:31:29 -04:00
9d8ff015c6 Perform releases only within the 'release' environment
this is recommended by pypi for trusted publishers
2024-05-23 07:27:43 -04:00
2 changed files with 12 additions and 2 deletions

View file

@ -12,6 +12,7 @@ jobs:
release:
runs-on: ubuntu-22.04
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

View file

@ -30,6 +30,10 @@ import pyotp
import platformdirs
import tomllib
from textual._ansi_sequences import ANSI_SEQUENCES_KEYS
from textual.keys import Keys
from typing import TypeGuard # use `typing_extensions` for Python 3.9 and below
# workaround for pyperclip being un-typed
if TYPE_CHECKING:
@ -42,8 +46,6 @@ else:
from pyperclip import paste as pyperclip_paste
from pyperclip import copy as pyperclip_copy
from typing import TypeGuard # use `typing_extensions` for Python 3.9 and below
def is_str_list(val: Any) -> TypeGuard[list[str]]:
"""Determines whether all objects in the list are strings"""
@ -52,6 +54,12 @@ def is_str_list(val: Any) -> TypeGuard[list[str]]:
return all(isinstance(x, str) for x in val)
# Monkeypatch escape key as meaning "F9", WFM
# ignore typing here because ANSI_SEQUENCES_KEYS is a Mapping[] which is read-only as
# far as mypy is concerned.
ANSI_SEQUENCES_KEYS["\x1b\x1b"] = (Keys.F9,) # type: ignore
# Copied from pyotp with the issuer mismatch check removed and HTOP support removed
def parse_uri(uri: str) -> pyotp.TOTP:
"""
@ -176,6 +184,7 @@ class SearchInput(Input, can_focus=False):
Binding("up", "focus_previous", show=False),
Binding("down", "focus_next", show=False),
Binding("ctrl+a", "clear_search", "Show all", show=True),
Binding("F9", "clear_search", show=True),
]
def on_focus(self) -> None: