Files
barnard/uiterm/view.go
T
Brandon McGintyandClaude Opus 5 17a4662c6c strip terminal control sequences from server-supplied text
Remove control, DEL, and bidi characters before display.
HTML escaping was the only filter, which leaves ANSI and OSC escape
sequences intact. A remote user could move the cursor, recolour the
screen, or reorder what was shown by putting escape codes in a
message, a nickname, or a channel name. Names rendered in the channel
tree go through the same filter now.

Keep the text box cursor and the prompt on rune boundaries.
Both indexed by byte, so editing a line containing multi-byte
characters could split one and render replacement characters.

Handle text view lines that carry no timestamp.
Toggling timestamps assumed every stored line had one and sliced past
the end of lines that did not.

Ignore key events on an empty tree.
The handlers indexed the item list before checking that it had any
items.

Remove the beep helpers.
They shelled out to an optional "beep" binary and panicked when it was
absent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00

23 lines
502 B
Go

package uiterm
import "unicode"
// safeRune prevents text supplied by a server or another user from being
// interpreted as a terminal control sequence when termbox flushes its cells.
func safeRune(r rune) rune {
if unicode.IsControl(r) || unicode.Is(unicode.Bidi_Control, r) {
return ' '
}
return r
}
type View interface {
uiInitialize(ui *Ui)
uiSetActive(active bool)
uiSetBounds(x0, y0, x1, y1 int)
uiDraw()
uiKeyEvent(key Key)
uiCharacterEvent(ch rune)
// commandEvent(cmd string)
}