Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ...' (#51) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Some checks are pending
Security Scan / security (push) Waiting to run
Some checks are pending
Security Scan / security (push) Waiting to run
This commit is contained in:
commit
bad4b95693
2 changed files with 36 additions and 1 deletions
|
|
@ -174,6 +174,13 @@ var borderSets = map[BorderStyle]borderSet{
|
||||||
BorderDouble: {"╔", "╗", "╚", "╝", "═", "║", "╦", "╩", "╠", "╣", "╬"},
|
BorderDouble: {"╔", "╗", "╚", "╝", "═", "║", "╦", "╩", "╠", "╣", "╬"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var borderSetsASCII = map[BorderStyle]borderSet{
|
||||||
|
BorderNormal: {"+", "+", "+", "+", "-", "|", "+", "+", "+", "+", "+"},
|
||||||
|
BorderRounded: {"+", "+", "+", "+", "-", "|", "+", "+", "+", "+", "+"},
|
||||||
|
BorderHeavy: {"+", "+", "+", "+", "=", "|", "+", "+", "+", "+", "+"},
|
||||||
|
BorderDouble: {"+", "+", "+", "+", "=", "|", "+", "+", "+", "+", "+"},
|
||||||
|
}
|
||||||
|
|
||||||
// CellStyleFn returns a style based on the cell's raw value.
|
// CellStyleFn returns a style based on the cell's raw value.
|
||||||
// Return nil to use the table's default CellStyle.
|
// Return nil to use the table's default CellStyle.
|
||||||
type CellStyleFn func(value string) *AnsiStyle
|
type CellStyleFn func(value string) *AnsiStyle
|
||||||
|
|
@ -391,7 +398,7 @@ func (t *Table) renderPlain() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Table) renderBordered() string {
|
func (t *Table) renderBordered() string {
|
||||||
b := borderSets[t.borders]
|
b := tableBorderSet(t.borders)
|
||||||
widths := t.columnWidths()
|
widths := t.columnWidths()
|
||||||
cols := t.colCount()
|
cols := t.colCount()
|
||||||
|
|
||||||
|
|
@ -472,3 +479,15 @@ func (t *Table) renderBordered() string {
|
||||||
|
|
||||||
return sb.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{}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,22 @@ func TestTable_Good(t *testing.T) {
|
||||||
assert.Contains(t, out, "║")
|
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) {
|
t.Run("bordered structure", func(t *testing.T) {
|
||||||
SetColorEnabled(false)
|
SetColorEnabled(false)
|
||||||
defer SetColorEnabled(true)
|
defer SetColorEnabled(true)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue