Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added ability to quit early #126

Merged
merged 10 commits into from
Jun 27, 2024
9 changes: 7 additions & 2 deletions src/pick/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class Option:
description: Optional[str] = None


KEY_CTRL_C = 3
KEY_ESCAPE = 27
KEYS_QUIT = (KEY_CTRL_C, KEY_ESCAPE, ord("q"))
KEYS_ENTER = (curses.KEY_ENTER, ord("\n"), ord("\r"))
KEYS_UP = (curses.KEY_UP, ord("k"))
KEYS_DOWN = (curses.KEY_DOWN, ord("j"))
Expand Down Expand Up @@ -182,7 +185,9 @@ def run_loop(
while True:
self.draw(screen)
c = screen.getch()
if c in KEYS_UP:
if c in KEYS_QUIT:
return None, -1
Henri-ColibrITD marked this conversation as resolved.
Show resolved Hide resolved
elif c in KEYS_UP:
self.move_up()
elif c in KEYS_DOWN:
self.move_down()
Expand Down Expand Up @@ -231,7 +236,7 @@ def pick(
min_selection_count: int = 0,
screen: Optional["curses._CursesWindow"] = None,
position: Position = Position(0, 0),
clear_screen = True,
clear_screen: bool = True,
):
picker: Picker = Picker(
options,
Expand Down
Loading