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

WIP: feat: vim + emacs (mac) shortcuts for selections #103

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ runtests.py
.cache
*.swp
.ropeproject/
/.vscode/
8 changes: 4 additions & 4 deletions inquirer/render/console/_checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def get_options(self):
yield choice, selector + ' ' + symbol, color

def process_input(self, pressed):
if pressed == key.UP:
if pressed == key.UP or pressed == 'k' or pressed == '\x10':
self.current = max(0, self.current - 1)
return
elif pressed == key.DOWN:
elif pressed == key.DOWN or pressed == 'j' or pressed == '\x0e':
self.current = min(len(self.question.choices) - 1,
self.current + 1)
return
Expand All @@ -75,10 +75,10 @@ def process_input(self, pressed):
self.selection.remove(self.current)
else:
self.selection.append(self.current)
elif pressed == key.LEFT:
elif pressed == key.LEFT or pressed == 'h' or pressed == key.CTRL_B:
if self.current in self.selection:
self.selection.remove(self.current)
elif pressed == key.RIGHT:
elif pressed == key.RIGHT or pressed == 'l' or pressed == key.CTRL_F:
if self.current not in self.selection:
self.selection.append(self.current)
elif pressed == key.ENTER:
Expand Down
4 changes: 2 additions & 2 deletions inquirer/render/console/_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ def get_options(self):

def process_input(self, pressed):
question = self.question
if pressed == key.UP:
if pressed == key.UP or pressed == 'k' or pressed == '\x10':
if question.carousel and self.current == 0:
self.current = len(question.choices) - 1
else:
self.current = max(0, self.current - 1)
return
if pressed == key.DOWN:
if pressed == key.DOWN or pressed == 'j' or pressed == '\x0e':
if question.carousel and self.current == len(question.choices) - 1:
self.current = 0
else:
Expand Down