Compare commits

...

10 commits

Author SHA1 Message Date
364cd0c2d6
Merge pull request #16 from jepler/fix-keys2
Properly fix the bindings that call actions on the app
2025-04-21 17:37:12 +02:00
ecf8c3f09b Properly fix the bindings that call actions on the app
h/t @ddkasa on discord for the suggested fix
2025-04-21 17:29:29 +02:00
aa3efe3ce3
Merge pull request #15 from jepler/fix-keys
Fix actions on sub widgets
2025-04-21 08:55:29 +02:00
9f35490cd5 Fix actions on sub widgets
this also broke somewhere along the line. I couldn't find it spelled
out in CHANGELOG and this feels like a workaround, but that's all I
got right now.

hey at least I could get rid of the escape-key workaround!
2025-04-21 08:49:54 +02:00
c7c09ececc
Merge pull request #14 from jepler/bump-requirements
overflow in css requires a newer textual (which one? idk)
2025-04-19 17:33:42 +02:00
82b2e979f0 this requires a newer textual (which one? idk) 2025-04-19 17:31:41 +02:00
715ab18902
Merge pull request #13 from jepler/modernize-remove-codeql
Adapt to upstream textual changes
2025-04-19 17:29:31 +02:00
453d78dee4 churn 2025-04-19 17:28:27 +02:00
7853bbf723 this workflow is not offering me any value 2025-04-19 17:27:03 +02:00
40caa3b945 Adapt to upstream textual changes
(yay mypy for alerting me to it!)
2025-04-19 17:26:20 +02:00
4 changed files with 17 additions and 75 deletions

View file

@ -1,48 +0,0 @@
# SPDX-FileCopyrightText: 2022 Jeff Epler
#
# SPDX-License-Identifier: CC0-1.0
name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: "53 3 * * 5"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ python ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Dependencies (python)
run: pip3 install -r requirements-dev.txt
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"

View file

@ -33,7 +33,7 @@ jobs:
- name: Upload patch
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: patch
path: ~/pre-commit.patch
@ -58,7 +58,7 @@ jobs:
run: python -mbuild
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*

View file

@ -6,4 +6,4 @@ click
platformdirs
pyotp
pyperclip
textual
textual >= 3.1.0

View file

@ -30,8 +30,6 @@ 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
@ -54,12 +52,6 @@ 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:
"""
@ -134,22 +126,22 @@ def parse_uri(uri: str) -> pyotp.TOTP:
default_conffile = platformdirs.user_config_path("ttotp") / "settings.toml"
class TOTPLabel(Label, can_focus=True):
class TOTPLabel(Label, can_focus=True, inherit_bindings=True):
otp: "TOTPData"
BINDINGS = [
Binding("c", "copy", "Copy code", show=True),
Binding("s", "show", "Show code", show=True),
Binding("up", "focus_previous", show=False),
Binding("down", "focus_next", show=False),
Binding("k", "focus_previous", show=False),
Binding("j", "focus_next", show=False),
Binding("c", "app.copy", "Copy code", show=True),
Binding("s", "app.show", "Show code", show=True),
Binding("up", "app.focus_previous", show=False),
Binding("down", "app.focus_next", show=False),
Binding("k", "app.focus_previous", show=False),
Binding("j", "app.focus_next", show=False),
]
def __init__(self, otp: "TOTPData") -> None:
self.otp = otp
super().__init__(
rich.text.Text(otp.name, overflow="ellipsis", no_wrap=True),
rich.text.Text(otp.name),
classes=f"otp-name otp-name-{otp.id} otp-{otp.id}",
expand=True,
)
@ -181,10 +173,10 @@ class TOTPLabel(Label, can_focus=True):
class SearchInput(Input, can_focus=False):
BINDINGS = [
Binding("up", "focus_previous", show=False),
Binding("down", "focus_next", show=False),
Binding("up", "app.focus_previous", show=False),
Binding("down", "app.focus_next", show=False),
Binding("ctrl+a", "clear_search", "Show all", show=True),
Binding("F9", "clear_search", show=True),
Binding("escape", "clear_search", show=True),
]
def on_focus(self) -> None:
@ -274,6 +266,8 @@ class TTOTP(App[None]):
.otp-progress { width: 12; }
.otp-value { width: 9; }
.otp-hidden { display: none; }
.otp-name { text-wrap: nowrap; text-overflow: ellipsis; }
.otp-name:focus { background: red; }
TOTPLabel { width: 1fr; height: 1; padding: 0 1; }
Horizontal:focus-within { background: $primary-background; }
Bar > .bar--bar { color: $success; }
@ -396,9 +390,7 @@ class TTOTP(App[None]):
parent = name_widget.parent
assert parent is not None
parent.remove_class("otp-hidden")
name_widget.update(
rich.text.Text(otp.name, overflow="ellipsis", no_wrap=True)
)
name_widget.update(rich.text.Text(otp.name))
return
matcher = Matcher(needle)
@ -409,8 +401,6 @@ class TTOTP(App[None]):
score = matcher.match(otp.name)
if score > 0:
highlighted = matcher.highlight(otp.name)
highlighted.overflow = "ellipsis"
highlighted.no_wrap = True
name_widget.update(highlighted)
parent.remove_class("otp-hidden")
else: