def display_results(self): result_vertical_pos = self.RESULTS_OFFSET_V result_pos_direction = 1 if self.results_top_down else -1 results_in_page = islice(enumerate( self.model.results), self.absolute_page_head, self.absolute_page_tail) try: for cand_nth, result in results_in_page: try: self.display_result(result_vertical_pos, result, is_current=cand_nth == self.model.index, is_marked=self.model.get_is_marked(cand_nth)) except curses.error as e: debug.log("display_results", str(e)) result_vertical_pos += result_pos_direction except Exception as e: # debug.log("display_results", str(e)) debug.log("display_results", six.text_type(" | ".join( map(lambda key: six.text_type(key) + ": " + six.text_type(e.__getattribute__(key)), dir(e) )) )) exception_raw_string = str(e).decode( self.percol.encoding) if six.PY2 else str(e) # self.display_error_message( # "Error at line " + str(cand_nth) + ": " + exception_raw_string) raise e
def display_result(self, y, result, is_current=False, is_marked=False): line, find_info, abs_idx, filename, position = result if is_current: line_style = self.CANDIDATES_LINE_SELECTED elif is_marked: line_style = self.CANDIDATES_LINE_MARKED else: line_style = self.CANDIDATES_LINE_BASIC keyword_style = self.CANDIDATES_LINE_QUERY + line_style self.display_line(y, 0, line, style=line_style) if find_info is None: return for (subq, match_info) in find_info: for x_offset, subq_len in match_info: try: x_offset_real = display.screen_len( line, beg=0, end=x_offset) self.display.add_string(line[x_offset:x_offset + subq_len], pos_y=y, pos_x=x_offset_real, style=keyword_style) except curses.error as e: debug.log("addnstr", str(e) + " ({0})".format(y))
def execute_action(self): selected_actions = self.model.get_selected_results_with_index() try: action = self.actions if action: action.act(selected_actions, self) except Exception as e: debug.log("execute_action", e)