1
1
mirror of https://github.com/walles/moar.git synced 2024-11-26 13:46:16 +03:00

Be smarter about line endings

Doesn't help Kitty though, don't know why.
This commit is contained in:
Johan Walles 2023-10-09 19:52:01 +02:00
parent cd95996e8e
commit d7c104e80a

View File

@ -470,17 +470,23 @@ func renderLine(row []Cell) (string, int) {
builder.WriteRune(runeToWrite)
}
if trailerLength > 0 {
// Set trailer attributes
trailerStyle := lastStyle.WithHyperlink(nil)
builder.WriteString(trailerStyle.RenderUpdateFrom(lastStyle))
lastStyle = trailerStyle
} else {
builder.WriteString(StyleDefault.RenderUpdateFrom(lastStyle))
lastStyle = StyleDefault
}
// Clear to end of line
// https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences
builder.WriteString("\x1b[K")
if trailerStyle != StyleDefault {
if lastStyle != StyleDefault {
// Reset style after each line
builder.WriteString("\x1b[m")
builder.WriteString(StyleDefault.RenderUpdateFrom(lastStyle))
}
return builder.String(), headerLength