Compare commits
10 commits
cd0a7912bb
...
364cd0c2d6
| Author | SHA1 | Date | |
|---|---|---|---|
| 364cd0c2d6 | |||
| ecf8c3f09b | |||
| aa3efe3ce3 | |||
| 9f35490cd5 | |||
| c7c09ececc | |||
| 82b2e979f0 | |||
| 715ab18902 | |||
| 453d78dee4 | |||
| 7853bbf723 | |||
| 40caa3b945 |
4 changed files with 17 additions and 75 deletions
48
.github/workflows/codeql.yml
vendored
48
.github/workflows/codeql.yml
vendored
|
|
@ -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 }}"
|
||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -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/*
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ click
|
|||
platformdirs
|
||||
pyotp
|
||||
pyperclip
|
||||
textual
|
||||
textual >= 3.1.0
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue