Skip to content

Commit

Permalink
Fix loop arrows buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
rbonghi committed May 10, 2020
1 parent 4dfdd21 commit 415a2b7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions jtop/gui/jtopgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ def increase(self, loop=False):
# Fix set new page
self.set(idx + 1)

def decrease(self):
idx = self.n_page + 1
def decrease(self, loop=False):
# check reset
if loop and self.n_page <= 0:
idx = len(self.pages) + 1
else:
idx = self.n_page + 1
self.set(idx - 1)

def set(self, idx):
Expand Down Expand Up @@ -256,12 +260,10 @@ def keyboard(self, event):
self.key = event
if self.old_key != self.key:
# keyboard check list
if self.key == ord('\t'):
if self.key == curses.KEY_LEFT:
self.decrease(loop=True)
elif self.key == curses.KEY_RIGHT or self.key == ord('\t'):
self.increase(loop=True)
elif self.key == curses.KEY_LEFT:
self.decrease()
elif self.key == curses.KEY_RIGHT:
self.increase()
elif self.key in [ord(str(n)) for n in range(10)]:
num = int(chr(self.key))
self.set(num)
Expand Down

0 comments on commit 415a2b7

Please sign in to comment.