MCPcopy Create free account
hub / github.com/facebook/PathPicker / print_text

Method print_text

src/pathpicker/formatted_text.py:77–95  ·  view source on GitHub ↗

Print out using ncurses. Note that if any formatting changes occur, the attribute set is changed and not restored

(
        self, y_pos: int, x_pos: int, printer: ColorPrinter, max_len: int
    )

Source from the content-addressed store, hash-verified

75 )
76
77 def print_text(
78 self, y_pos: int, x_pos: int, printer: ColorPrinter, max_len: int
79 ) -> None:
80 """Print out using ncurses. Note that if any formatting changes
81 occur, the attribute set is changed and not restored"""
82 printed_so_far = 0
83 for index, val in enumerate(self.segments):
84 if printed_so_far >= max_len:
85 break
86 if index % 2 == 1:
87 # text
88 to_print = val[0 : max_len - printed_so_far]
89 printer.addstr(
90 y_pos, x_pos + printed_so_far, to_print, ColorPrinter.CURRENT_COLORS
91 )
92 printed_so_far += len(to_print)
93 else:
94 # formatting
95 printer.set_attributes(*self.parse_formatting(val))
96
97 def find_segment_place(self, to_go: int) -> Tuple[int, int]:
98 index = 1

Callers 2

outputMethod · 0.80
print_up_toMethod · 0.80

Calls 3

parse_formattingMethod · 0.95
set_attributesMethod · 0.80
addstrMethod · 0.45

Tested by

no test coverage detected