rework max_lines/cols detection to support line wrapping (#15 part 1)