diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-20 22:53:21 +0300 |
|---|---|---|
| committer | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-20 22:53:21 +0300 |
| commit | 42449043cf1903e0e72295b096274d26187a61b8 (patch) | |
| tree | a709214f2e647ae086bb355a1c868b03e70dffcb /internal/atable/table.go | |
| parent | 6a8198237706c47013c68f1036a307001f77cfa5 (diff) | |
Space separated tags and table column spacing
Diffstat (limited to 'internal/atable/table.go')
| -rw-r--r-- | internal/atable/table.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/internal/atable/table.go b/internal/atable/table.go index 8f2b3c0..7251b11 100644 --- a/internal/atable/table.go +++ b/internal/atable/table.go @@ -472,7 +472,7 @@ func (m Model) headersView() string { renderedCell := style.Render(ansi.Truncate(col.Title, col.Width, "…")) s = append(s, m.styles.Header.Render(renderedCell)) } - return lipgloss.JoinHorizontal(lipgloss.Top, s...) + return lipgloss.JoinHorizontal(lipgloss.Top, addSpacing(s)...) } func (m *Model) renderRow(r int) string { @@ -490,9 +490,23 @@ func (m *Model) renderRow(r int) string { s = append(s, renderedCell) } - return lipgloss.JoinHorizontal(lipgloss.Top, s...) + return lipgloss.JoinHorizontal(lipgloss.Top, addSpacing(s)...) } func clamp(v, low, high int) int { return min(max(v, low), high) } + +func addSpacing(cells []string) []string { + if len(cells) <= 1 { + return cells + } + spaced := make([]string, 0, len(cells)*2-1) + for i, cell := range cells { + if i > 0 { + spaced = append(spaced, " ") + } + spaced = append(spaced, cell) + } + return spaced +} |
