Skip to content

Commit

Permalink
Merge branch 'JustBobinAround-2.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
thehunmonkgroup committed Oct 26, 2022
2 parents 6fde4c4 + ca22056 commit 97626f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
27 changes: 14 additions & 13 deletions vit/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,21 @@ def search_rows(self, term, start_index=0, reverse=False):
rows = self.table.rows
current_index = start_index
last_index = len(rows) - 1
start_matches = self.search_row_has_search_term(rows[start_index], search_regex)
current_index = self.search_increment_index(current_index, reverse)
while True:
if reverse and current_index < 0:
self.search_loop_warning('TOP', reverse)
current_index = last_index
elif not reverse and current_index > last_index:
self.search_loop_warning('BOTTOM', reverse)
current_index = 0
if self.search_row_has_search_term(rows[current_index], search_regex):
return current_index
if current_index == start_index:
return start_index if start_matches else None
if len(rows) > 0:
start_matches = self.search_row_has_search_term(rows[start_index], search_regex)
current_index = self.search_increment_index(current_index, reverse)
while True:
if reverse and current_index < 0:
self.search_loop_warning('TOP', reverse)
current_index = last_index
elif not reverse and current_index > last_index:
self.search_loop_warning('BOTTOM', reverse)
current_index = 0
if self.search_row_has_search_term(rows[current_index], search_regex):
return current_index
if current_index == start_index:
return start_index if start_matches else None
current_index = self.search_increment_index(current_index, reverse)

def search_increment_index(self, current_index, reverse=False):
return current_index + (-1 if reverse else 1)
Expand Down
13 changes: 8 additions & 5 deletions vit/base_list_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ def keypress_page_down(self, size):
self.keypress(size, '<Page Down>')

def keypress_home(self, size):
self.set_focus(0)
if len(self.body) > 0:
self.set_focus(0)

def keypress_end(self, size):
self.set_focus(len(self.body) - 1)
self.set_focus_valign('bottom')
if len(self.body) > 0:
self.set_focus(len(self.body) - 1)
self.set_focus_valign('bottom')

def keypress_screen_top(self, size):
top, _, _ = self.get_top_middle_bottom_rows(size)
Expand All @@ -93,8 +95,9 @@ def keypress_screen_bottom(self, size):
self.set_focus(bottom.position)

def keypress_focus_valign_center(self, size):
self.set_focus(self.focus_position)
self.set_focus_valign('middle')
if len(self.body) > 0:
self.set_focus(self.focus_position)
self.set_focus_valign('middle')

def transform_special_keys(self, key):
# NOTE: These are special key presses passed to allow navigation
Expand Down

0 comments on commit 97626f7

Please sign in to comment.