def fillSearchBox(fltr, key): global channels global searchPos global main_window global list_win max_row = list_win.getmaxyx()[0] - 2 filtered = Search.filter_out(fltr, channels) if (len(filtered) - 1) < max_row: max_row = len(filtered) + 1 if key == 0 and searchPos >= 2: searchPos -= 1 if key == 1 and searchPos < max_row: searchPos += 1 if searchPos > max_row - 1: searchPos = max_row - 1 clearListWin(Strings.search_bx) for i in range(1, max_row): channel = filtered[i - 1] outstr = getRowText(channel) if (i == searchPos): list_win.addstr(i, 1, outstr, curses.A_REVERSE) else: list_win.addstr(i, 1, outstr) list_win.refresh()
def getSelectedRow(): global channels if Search.text == "": return channels[curPos] else: return Search.filter_out(Search.text, channels)[searchPos]