MCPcopy
hub / github.com/mathaou/termdbms / NumHeaders

Method NumHeaders

viewer/tableutil.go:28–50  ·  view source on GitHub ↗

NumHeaders gets the number of columns for the current schema

()

Source from the content-addressed store, hash-verified

26
27// NumHeaders gets the number of columns for the current schema
28func (m *TuiModel) NumHeaders() int {
29 headers := m.GetHeaders()
30 l := len(headers)
31 if m.UI.ExpandColumn > -1 || l == 0 {
32 return 1
33 }
34
35 maxHeaders = 7
36
37 if l > maxHeaders { // this just looked the best after some trial and error
38 if l%5 == 0 {
39 return 5
40 } else if l%4 == 0 {
41 return 4
42 } else if l%3 == 0 {
43 return 3
44 } else {
45 return 6 // primes and shiiiii
46 }
47 }
48
49 return l
50}
51
52// CellWidth gets the current cell width for schema
53func (m *TuiModel) CellWidth() int {

Callers 2

CellWidthMethod · 0.95
GetSelectedColumnNameMethod · 0.95

Calls 1

GetHeadersMethod · 0.95

Tested by

no test coverage detected