setWidth method
Updates the known terminal width (column count) and repaints, so wrapped
lines reflow. Pass 0 when the width is unknown (single-row fallback).
Implementation
void setWidth(int cols) {
if (cols == _width) return;
_width = cols;
if (interactive && !_passthrough) _refresh();
}