(text)
| 27 | |
| 28 | |
| 29 | def get_text_length(text): |
| 30 | # `len(unichar)` measures the number of characters, so we use |
| 31 | # `unicodedata.east_asian_width` to measure the length of characters. |
| 32 | # Following responses are considered to be full-width length. |
| 33 | # * A(Ambiguous) |
| 34 | # * F(Fullwidth) |
| 35 | # * W(Wide) |
| 36 | text = str(text) |
| 37 | return sum( |
| 38 | 2 if unicodedata.east_asian_width(char) in 'WFA' else 1 |
| 39 | for char in text |
| 40 | ) |
| 41 | |
| 42 | |
| 43 | def determine_terminal_width(default_width=80): |
no outgoing calls
no test coverage detected