Split line of text into words (but not within quoted groups).
(msg: str)
| 508 | |
| 509 | |
| 510 | def split_words(msg: str) -> list[str]: |
| 511 | """Split line of text into words (but not within quoted groups).""" |
| 512 | next_word = "" |
| 513 | res: list[str] = [] |
| 514 | allow_break = True |
| 515 | for c in msg: |
| 516 | if c == " " and allow_break: |
| 517 | res.append(next_word) |
| 518 | next_word = "" |
| 519 | continue |
| 520 | if c == '"': |
| 521 | allow_break = not allow_break |
| 522 | next_word += c |
| 523 | res.append(next_word) |
| 524 | return res |
| 525 | |
| 526 | |
| 527 | def get_terminal_width() -> int: |
searching dependent graphs…