From 5039d192949a3031511b42222ba4c6239f87c5a8 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Fri, 29 Mar 2024 07:57:44 -0400 Subject: [PATCH] fix: tab stops --- ansi.go | 7 ++++++- main.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ansi.go b/ansi.go index 24701c2..28e8ceb 100644 --- a/ansi.go +++ b/ansi.go @@ -48,7 +48,12 @@ func (p *dispatcher) Print(r rune) { } func (p *dispatcher) Execute(code byte) { - if code == 0x0A { + if code == '\t' { + for p.col%16 != 0 { + p.Print(' ') + } + } + if code == '\n' { p.endBackground() p.row++ p.col = 0 diff --git a/main.go b/main.go index b5b6c83..13c26ff 100644 --- a/main.go +++ b/main.go @@ -298,7 +298,7 @@ func main() { } if autoWidth { - longestLine := lipgloss.Width(strings.ReplaceAll(strippedInput, "\t", " ")) + longestLine := lipgloss.Width(strings.ReplaceAll(strippedInput, "\t", " ")) terminalWidth = float64(longestLine+1) * (config.Font.Size / fontHeightToWidthRatio) terminalWidth *= scale terminalWidth += hPadding