Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 364cd0c

Browse files
authored
Merge pull request #16 from jepler/fix-keys2
Properly fix the bindings that call actions on the app
2 parents aa3efe3 + ecf8c3f commit 364cd0c

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

src/ttotp/__main__.py

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -126,35 +126,16 @@ def parse_uri(uri: str) -> pyotp.TOTP:
126126
default_conffile = platformdirs.user_config_path("ttotp") / "settings.toml"
127127

128128

129-
class _common_actions:
130-
app: Any # avoid mypy diagnostics about properties of self.app
131-
132-
def action_focus_next(self) -> None:
133-
self.app.screen.focus_next()
134-
135-
def action_focus_previous(self) -> None:
136-
self.app.screen.focus_previous()
137-
138-
def action_copy(self) -> None:
139-
self.app.action_copy()
140-
141-
def action_show(self) -> None:
142-
self.app.action_show()
143-
144-
def action_clear_search(self) -> None:
145-
self.app.action_clear_search()
146-
147-
148-
class TOTPLabel(_common_actions, Label, can_focus=True, inherit_bindings=True):
129+
class TOTPLabel(Label, can_focus=True, inherit_bindings=True):
149130
otp: "TOTPData"
150131

151132
BINDINGS = [
152-
Binding("c", "copy", "Copy code", show=True),
153-
Binding("s", "show", "Show code", show=True),
154-
Binding("up", "focus_previous", show=False),
155-
Binding("down", "focus_next", show=False),
156-
Binding("k", "focus_previous", show=False),
157-
Binding("j", "focus_next", show=False),
133+
Binding("c", "app.copy", "Copy code", show=True),
134+
Binding("s", "app.show", "Show code", show=True),
135+
Binding("up", "app.focus_previous", show=False),
136+
Binding("down", "app.focus_next", show=False),
137+
Binding("k", "app.focus_previous", show=False),
138+
Binding("j", "app.focus_next", show=False),
158139
]
159140

160141
def __init__(self, otp: "TOTPData") -> None:
@@ -190,10 +171,10 @@ def on_blur(self) -> None:
190171
self.shown = False
191172

192173

193-
class SearchInput(_common_actions, Input, can_focus=False):
174+
class SearchInput(Input, can_focus=False):
194175
BINDINGS = [
195-
Binding("up", "focus_previous", show=False),
196-
Binding("down", "focus_next", show=False),
176+
Binding("up", "app.focus_previous", show=False),
177+
Binding("down", "app.focus_next", show=False),
197178
Binding("ctrl+a", "clear_search", "Show all", show=True),
198179
Binding("escape", "clear_search", show=True),
199180
]

0 commit comments

Comments
 (0)