Pad string header to width chars given known visible_width of the header.
(
header, alignment, width, visible_width, is_multiline=False, width_fn=None
)
| 1386 | |
| 1387 | |
| 1388 | def _align_header( |
| 1389 | header, alignment, width, visible_width, is_multiline=False, width_fn=None |
| 1390 | ): |
| 1391 | "Pad string header to width chars given known visible_width of the header." |
| 1392 | if is_multiline: |
| 1393 | header_lines = re.split(_multiline_codes, header) |
| 1394 | padded_lines = [ |
| 1395 | _align_header(h, alignment, width, width_fn(h)) for h in header_lines |
| 1396 | ] |
| 1397 | return "\n".join(padded_lines) |
| 1398 | # else: not multiline |
| 1399 | ninvisible = len(header) - visible_width |
| 1400 | width += ninvisible |
| 1401 | if alignment == "left": |
| 1402 | return _padright(width, header) |
| 1403 | elif alignment == "center": |
| 1404 | return _padboth(width, header) |
| 1405 | elif not alignment: |
| 1406 | return f"{header}" |
| 1407 | else: |
| 1408 | return _padleft(width, header) |
| 1409 | |
| 1410 | |
| 1411 | def _remove_separating_lines(rows): |