Return a function to calculate visible cell width.
(has_invisible, enable_widechars, is_multiline)
| 1152 | |
| 1153 | |
| 1154 | def _choose_width_fn(has_invisible, enable_widechars, is_multiline): |
| 1155 | """Return a function to calculate visible cell width.""" |
| 1156 | if has_invisible: |
| 1157 | line_width_fn = _visible_width |
| 1158 | elif enable_widechars: # optional wide-character support if available |
| 1159 | line_width_fn = wcwidth.wcswidth |
| 1160 | else: |
| 1161 | line_width_fn = len |
| 1162 | if is_multiline: |
| 1163 | width_fn = lambda s: _multiline_width(s, line_width_fn) # noqa: E731 |
| 1164 | else: |
| 1165 | width_fn = line_width_fn |
| 1166 | return width_fn |
| 1167 | |
| 1168 | |
| 1169 | def _align_column_choose_padfn(strings, alignment, has_invisible, preserve_whitespace): |
no test coverage detected