in src/pathpicker/line_format.py [0:0]
def output(self, printer: ColorPrinter) -> None:
assert self.controller is not None
(min_x, min_y, max_x, max_y) = self.controller.get_chrome_boundaries()
y_pos = min_y + self.index + self.controller.get_scroll_offset()
if y_pos < min_y or y_pos >= max_y:
# wont be displayed!
return
# we dont care about the after text, but we should be able to see
# all of the decorated match (which means we need to see up to
# the end of the decoratedMatch, aka include beforeText)
important_text_length = len(str(self.before_text)) + len(
str(self.decorated_match)
)
space_for_printing = max_x - min_x
if important_text_length > space_for_printing:
# hrm, we need to update our decorated match to show
# a truncated version since right now we will print off
# the screen. lets also dump the beforeText for more
# space
self.update_decorated_match(max_len=space_for_printing)
self.is_truncated = True
else:
# first check what our expanded size would be:
expanded_size = len(str(self.before_text)) + len(self.get_match())
if expanded_size < space_for_printing and self.is_truncated:
# if the screen gets resized, we might be truncated
# from a previous render but **now** we have room.
# in that case lets expand back out
self.update_decorated_match()
self.is_truncated = False
max_len = max_x - min_x
so_far = (min_x, max_len)
so_far = self.print_up_to(self.before_text, printer, y_pos, *so_far)
so_far = self.print_up_to(self.decorated_match, printer, y_pos, *so_far)
so_far = self.print_up_to(self.after_text, printer, y_pos, *so_far)