| 519 | |
| 520 | |
| 521 | class _TextAdjustment: |
| 522 | def __init__(self) -> None: |
| 523 | self.encoding = get_option("display.encoding") |
| 524 | |
| 525 | def len(self, text: str) -> int: |
| 526 | return len(text) |
| 527 | |
| 528 | def justify(self, texts: Any, max_len: int, mode: str = "right") -> list[str]: |
| 529 | """ |
| 530 | Perform ljust, center, rjust against string or list-like |
| 531 | """ |
| 532 | if mode == "left": |
| 533 | return [x.ljust(max_len) for x in texts] |
| 534 | elif mode == "center": |
| 535 | return [x.center(max_len) for x in texts] |
| 536 | else: |
| 537 | return [x.rjust(max_len) for x in texts] |
| 538 | |
| 539 | def adjoin(self, space: int, *lists: Any, **kwargs: Any) -> str: |
| 540 | return adjoin(space, *lists, strlen=self.len, justfunc=self.justify, **kwargs) |
| 541 | |
| 542 | |
| 543 | class _EastAsianTextAdjustment(_TextAdjustment): |