Compare commits

..

No commits in common. "main" and "v0.0.7" have entirely different histories.
main ... v0.0.7

3 changed files with 3 additions and 36 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
table_header_test.go

View File

@ -60,31 +60,6 @@ func (t *Table) AddRow(row ...interface{}) {
}
}
func (t *Table) StringNoHead() string {
b := new(strings.Builder)
b.WriteRune('┏')
for i, colwidth := range t.colwidth {
b.WriteString(strings.Repeat("━", colwidth))
if i < len(t.colwidth)-1 {
b.WriteRune('┯')
}
}
b.WriteRune('┓')
b.WriteRune('\n')
for i, row := range t.data {
t.printRow(b, row, t.rowheight[i])
if t.rowSep && i < len(t.data)-1 {
t.addNextCellLine(b)
}
}
t.addLastCellLine(b)
return b.String()
}
func (t *Table) String() string {
b := new(strings.Builder)

View File

@ -6,21 +6,14 @@ import (
"git.milar.in/milarin/slices"
)
func FormatHeaderTable(header string, table *Table) string {
return formatHeaderTableStr(header, table.String())
}
func FormatHeaderTableNoHead(header string, table *Table) string {
return formatHeaderTableStr(header, table.StringNoHead())
}
// TODO formatHeaderTableStr is a quick hack
// TODO FormatHeaderTable is a quick hack
// a better solution would be to support nested tables.
// in that case, a header table is just a table with a singe col, single header row and single data row
func formatHeaderTableStr(header string, tab string) string {
func FormatHeaderTable(header string, table *Table) string {
b := new(strings.Builder)
tab := table.String()
splits := strings.Split(tab, "\n")
tabwidth := strLen(splits[0])