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

Allow loop cycling through Bullet items #53

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 12 additions & 8 deletions bullet/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,27 +171,31 @@ def printBullet(self, idx):

@keyhandler.register(ARROW_UP_KEY)
def moveUp(self):
utils.clearLine()
old_pos = self.pos
if self.pos - 1 < 0:
return
self.pos = len(self.choices) - 1
self.printBullet(old_pos)
utils.moveCursorDown(len(self.choices) - 1)
else:
utils.clearLine()
old_pos = self.pos
self.pos -= 1
self.printBullet(old_pos)
utils.moveCursorUp(1)
self.printBullet(self.pos)
self.printBullet(self.pos)

@keyhandler.register(ARROW_DOWN_KEY)
def moveDown(self):
utils.clearLine()
old_pos = self.pos
if self.pos + 1 >= len(self.choices):
return
self.pos = 0
self.printBullet(old_pos)
utils.moveCursorUp(len(self.choices) - 1)
else:
utils.clearLine()
old_pos = self.pos
self.pos += 1
self.printBullet(old_pos)
utils.moveCursorDown(1)
self.printBullet(self.pos)
self.printBullet(self.pos)

@keyhandler.register(NEWLINE_KEY)
def accept(self):
Expand Down