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
)
| 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 |
no test coverage detected