clampSpinnerMessage bounds msg so the rendered spinner line (message + "... " + glyph) never exceeds one terminal row. Rune-aware so multibyte labels (paths, queries, emoji) truncate cleanly.
(msg string, cols int)
| 122 | // "... " + glyph) never exceeds one terminal row. Rune-aware so multibyte |
| 123 | // labels (paths, queries, emoji) truncate cleanly. |
| 124 | func clampSpinnerMessage(msg string, cols int) string { |
| 125 | const reserved = 8 // "... " + glyph + right margin |
| 126 | limit := cols - reserved |
| 127 | if limit < 16 { |
| 128 | limit = 16 |
| 129 | } |
| 130 | r := []rune(msg) |
| 131 | if len(r) <= limit { |
| 132 | return msg |
| 133 | } |
| 134 | return string(r[:limit-1]) + "…" |
| 135 | } |
| 136 | |
| 137 | // UpdateMessage atualiza a mensagem sem parar e reiniciar a animação |
| 138 | func (am *AnimationManager) UpdateMessage(message string) { |
no outgoing calls