truncateText truncates text to maxWidth and adds ellipsis if needed
(text string, maxWidth int)
| 208 | |
| 209 | // truncateText truncates text to maxWidth and adds ellipsis if needed |
| 210 | func truncateText(text string, maxWidth int) string { |
| 211 | if maxWidth <= 0 { |
| 212 | return text |
| 213 | } |
| 214 | |
| 215 | runes := []rune(text) |
| 216 | if len(runes) <= maxWidth { |
| 217 | return text |
| 218 | } |
| 219 | |
| 220 | // Reserve 3 characters for ellipsis |
| 221 | if maxWidth <= 3 { |
| 222 | return string(runes[:maxWidth]) |
| 223 | } |
| 224 | |
| 225 | return string(runes[:maxWidth-3]) + "..." |
| 226 | } |
| 227 | |
| 228 | // getColumnMaxWidth determines the maximum width for a column |
| 229 | func getColumnMaxWidth(colIndex int) int { |
no outgoing calls