Download progress bar scrolls uncontrollably when filenames contain CJK characters
Describe the bug
## Environment
- tdl version: 0.20.4 (commit 9d7d49e)
- OS: Windows 11
- Terminal: Windows Terminal and legacy conhost (reproduced on both)
## Problem
When downloading media whose filenames contain CJK characters (e.g. Chinese),
the progress display scrolls the terminal instead of staying in place. Every
refresh pushes the whole block down by one or more lines, eventually wiping
previous output. Pure-ASCII filenames do not trigger it.
Manually widening the terminal window stops the scrolling, which points to a
line-width calculation issue.
## Steps to reproduce
1. `tdl dl -f <export.json> -d <dir>` against a chat whose media names contain
Chinese characters.
2. Keep the terminal at its default width (~80 columns).
3. Watch the progress block: it scrolls continuously.
## Root cause
The per-tracker progress line is rendered wider than the terminal because
`github.com/jedib0t/go-pretty/v6` (v6.5.0) truncates the tracker message by
**rune count** instead of **display width**.
Flow:
- tdl's `pkg/prog/prog.go` calls `SetMessageWidth(width * 3 / 5)`.
- go-pretty's `progress.renderTracker` shortens long messages via `text.Snip(...)`.
- `text.Snip` measures width correctly with `RuneWidthWithoutEscSequences`,
but then delegates the actual cutting to `text.Trim`.
- `text.Trim` increments a counter by one per rune:
```go
func Trim(str string, maxLen int) string {
// ...
if outLen < maxLen {
outLen++ // counts runes, not columns
out.WriteRune(sChr)
continue
}
// ...
}A CJK character occupies 2 terminal columns, so a message "truncated" to
maxLen runes ends up up to ~2× maxLen columns wide. The rendered line then
exceeds the terminal width, soft-wraps onto a second row, and
progress.moveCursorToTheTop (which moves up len(trackersActive) rows,
assuming one row per tracker) under-counts — hence the scrolling.
Note: LongestLineLen and InsertEveryN in the same text/string.go already
accumulate width correctly (outLen += RuneWidth(c)); only Trim is
inconsistent.
Suggested fix
In text.Trim, accumulate display width instead of rune count:
if outLen < maxLen {
outLen += RuneWidth(sChr)
out.WriteRune(sChr)
continue
}This makes SetMessageWidth / Snip truncate to the requested number of
columns, so lines never exceed the terminal width and the progress display
stays in place.
Workaround
Widen the terminal window so messageWidth is large enough that the message is
never truncated (the bug only manifests on the truncation path).
### To Reproduce
run download with CJK characters
### Expected behavior
normal display
### Version
Version: 0.20.4
Commit: 9d7d49e
Date: 2026-08-23T17:15:46Z
go1.25.8 windows/amd64
### Which OS are you running tdl on?
Windows
### Additional context
_No response_Source: iyear/tdl