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

Function init

viewer/table.go:24–147  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22)
23
24func init() {
25 tmp := ""
26 MIP = false
27 mid = &tmp
28 HeaderAssembly = func(m *TuiModel, s *string, done *chan bool) {
29 if m.UI.ShowClipboard {
30 *done <- true
31 return
32 }
33
34 var (
35 builder []string
36 )
37
38 style := m.GetBaseStyle()
39
40 if !tuiutil.Ascii {
41 // for column headers
42 style = style.Foreground(lipgloss.Color(tuiutil.HeaderForeground())).
43 BorderBackground(lipgloss.Color(tuiutil.HeaderBorderBackground())).
44 Background(lipgloss.Color(tuiutil.HeaderBackground()))
45 }
46 headers := m.Data().TableHeadersSlice
47 for i, d := range headers { // write all headers
48 if m.UI.ExpandColumn != -1 && i != m.UI.ExpandColumn {
49 continue
50 }
51
52 text := " " + TruncateIfApplicable(m, d)
53 builder = append(builder, style.
54 Render(text))
55 }
56
57 {
58 // schema name
59 var headerTop string
60
61 if m.UI.EditModeEnabled || m.UI.FormatModeEnabled {
62 headerTop = m.TextInput.Model.View()
63 if !m.TextInput.Model.Focused() {
64 headerTop = HeaderStyle.Copy().Faint(true).Render(headerTop)
65 }
66 } else {
67 headerTop = fmt.Sprintf(" %s (%d/%d) - %d record(s) + %d column(s)",
68 m.GetSchemaName(),
69 m.UI.CurrentTable,
70 len(m.Data().TableHeaders), // look at how headers get rendered to get accurate record number
71 len(m.GetColumnData()),
72 len(m.GetHeaders())) // this will need to be refactored when filters get added
73 headerTop = HeaderStyle.Render(headerTop)
74 }
75
76 headerMid := lipgloss.JoinHorizontal(lipgloss.Left, builder...)
77 if m.UI.RenderSelection {
78 headerMid = ""
79 }
80 *s = lipgloss.JoinVertical(lipgloss.Left, headerTop, headerMid)
81 }

Callers

nothing calls this directly

Calls 13

TruncateIfApplicableFunction · 0.85
GetBaseStyleMethod · 0.80
DataMethod · 0.80
FocusedMethod · 0.80
GetSchemaNameMethod · 0.80
GetColumnDataMethod · 0.80
GetHeadersMethod · 0.80
GetRowMethod · 0.80
GetColumnMethod · 0.80
TableMethod · 0.80
WidthMethod · 0.80
RenderMethod · 0.65

Tested by

no test coverage detected