diff --git a/pkg/cli/styles.go b/pkg/cli/styles.go index 9ee9880..1e281d8 100644 --- a/pkg/cli/styles.go +++ b/pkg/cli/styles.go @@ -174,6 +174,13 @@ var borderSets = map[BorderStyle]borderSet{ BorderDouble: {"╔", "╗", "╚", "╝", "═", "║", "╦", "╩", "╠", "╣", "╬"}, } +var borderSetsASCII = map[BorderStyle]borderSet{ + BorderNormal: {"+", "+", "+", "+", "-", "|", "+", "+", "+", "+", "+"}, + BorderRounded: {"+", "+", "+", "+", "-", "|", "+", "+", "+", "+", "+"}, + BorderHeavy: {"+", "+", "+", "+", "=", "|", "+", "+", "+", "+", "+"}, + BorderDouble: {"+", "+", "+", "+", "=", "|", "+", "+", "+", "+", "+"}, +} + // CellStyleFn returns a style based on the cell's raw value. // Return nil to use the table's default CellStyle. type CellStyleFn func(value string) *AnsiStyle @@ -391,7 +398,7 @@ func (t *Table) renderPlain() string { } func (t *Table) renderBordered() string { - b := borderSets[t.borders] + b := tableBorderSet(t.borders) widths := t.columnWidths() cols := t.colCount() @@ -472,3 +479,15 @@ func (t *Table) renderBordered() string { return sb.String() } + +func tableBorderSet(style BorderStyle) borderSet { + if currentTheme == ThemeASCII { + if b, ok := borderSetsASCII[style]; ok { + return b + } + } + if b, ok := borderSets[style]; ok { + return b + } + return borderSet{} +} diff --git a/pkg/cli/styles_test.go b/pkg/cli/styles_test.go index 8adae78..949c138 100644 --- a/pkg/cli/styles_test.go +++ b/pkg/cli/styles_test.go @@ -81,6 +81,22 @@ func TestTable_Good(t *testing.T) { assert.Contains(t, out, "║") }) + t.Run("ASCII theme uses ASCII borders", func(t *testing.T) { + restoreThemeAndColors(t) + UseASCII() + + tbl := NewTable("REPO", "STATUS").WithBorders(BorderRounded) + tbl.AddRow("core", "clean") + + out := tbl.String() + assert.Contains(t, out, "+") + assert.Contains(t, out, "-") + assert.Contains(t, out, "|") + assert.NotContains(t, out, "╭") + assert.NotContains(t, out, "╮") + assert.NotContains(t, out, "│") + }) + t.Run("bordered structure", func(t *testing.T) { SetColorEnabled(false) defer SetColorEnabled(true)