* DrawHelper A utility class for safe and bounded terminal drawing using a local coordinate system. Supports sub-regions, colors, and drawing of text, boxes, and lines. ** Constructor #+BEGIN_SRC python DrawHelper(screen, x: int, y: int, width: int, height: int) #+END_SRC - `screen`: curses window to draw on. - `x`, `y`: Top-left corner of the region in parent coordinates. - `width`, `height`: Size of the drawing region. ** Color - `set_color(color_pair: int)` Set the active color pair for subsequent drawing. ** Drawing Primitives - `put_char(x: int, y: int, char: str, attrs=0)` Draw a single character at `(x, y)` within bounds. - `put_string(x: int, y: int, text: str, attrs=0)` Draw a string at `(x, y)`, clamped to fit the width. - `draw_line(x: int, y: int, length: int, char: str, horizontal=True, attrs=0, ender=None)` Draw a horizontal or vertical line using the given character. Optional `ender` is placed at both ends. - `filled_rectangle(x: int, y: int, width: int, height: int, char: str = ' ')` Draw a filled rectangle using the given character. - `rectangle(x: int, y: int, width: int, height: int)` Draw an outlined rectangle using Unicode box-drawing characters. ** Text Utilities - `multiline_text(x: int, y: int, text: str) -> int` Render multiline text starting at `(x, y)`. Returns the number of lines drawn. - `header_line(y: int, text: str, char: str = '─', attrs=0)` Draw a horizontal line with centered `text` at row `y`. - `info_line(row: int, start: int, end: int, strings: List[str], margin=1, attrs=0)` Display a pipe-separated list of `strings` between `start` and `end` at `row`. ** Region Management - `sub_region(x: int, y: int, width: int, height: int)` Context manager that yields a nested `DrawHelper` with its own local coordinates. #+BEGIN_SRC python with helper.sub_region(x, y, w, h) as sub: sub.put_string(0, 0, "Inside sub-region") #+END_SRC ** Notes - Coordinates are relative to the helper’s own region. - Drawing outside bounds is silently ignored. - Drawing operations use safe wrappers to suppress `curses.error`.