MCPcopy Index your code
hub / github.com/codechenx/FastTableViewer / drawUI

Function drawUI

ui.go:180–939  ·  view source on GitHub ↗

draw app UI

(b *Buffer)

Source from the content-addressed store, hash-verified

178
179// draw app UI
180func drawUI(b *Buffer) error {
181
182 //bufferTable init with modern styling
183 bufferTable = tview.NewTable()
184 bufferTable.SetSelectable(true, true)
185 bufferTable.SetBorders(false)
186 bufferTable.SetSeparator(tview.Borders.Vertical) // Add subtle vertical separators
187 bufferTable.SetBordersColor(tcell.NewRGBColor(60, 100, 140)) // Subtle blue borders
188 bufferTable.SetFixed(b.rowFreeze, b.colFreeze)
189 bufferTable.Select(0, 0)
190 bufferTable.SetSelectedStyle(tcell.Style{}.
191 Foreground(tcell.ColorWhite).
192 Background(tcell.NewRGBColor(80, 120, 160)). // Darker, muted blue
193 Attributes(tcell.AttrBold))
194
195 // Auto-detect and wrap long columns (sample first 100 rows, threshold 50 characters)
196 detectAndWrapLongColumns(b, 100, 50)
197
198 drawBuffer(b, bufferTable)
199
200 //main page init with modern styling
201 cursorPosStr = buildCursorPosStr(0, 0) //footer right
202 if statusMessage == "" {
203 statusMessage = "All Done"
204 }
205 shorFileName := filepath.Base(args.FileName)
206 fileNameStr = shorFileName + " | " + "? help" //footer left
207 filterInfoStr := buildFilterInfoStr(0) // Top strip for filter info, initially at column 0
208
209 mainPage = tview.NewFrame(bufferTable).
210 SetBorders(0, 0, 0, 0, 0, 0)
211
212 // Add filter info strip at top if filter is active and cursor on filtered column
213 if filterInfoStr != "" {
214 mainPage.AddText(filterInfoStr, true, tview.AlignCenter, tcell.NewRGBColor(255, 140, 0))
215 }
216
217 // Add main footer at bottom
218 mainPage.AddText(fileNameStr, false, tview.AlignLeft, tcell.NewRGBColor(255, 150, 50)).
219 AddText(statusMessage, false, tview.AlignCenter, tcell.NewRGBColor(100, 200, 255)).
220 AddText(cursorPosStr, false, tview.AlignRight, tcell.NewRGBColor(150, 255, 150))
221
222 drawFooterText := func(lstr, cstr, rstr string) {
223 statusMessage = cstr // Update global status
224 mainPage.Clear()
225
226 // Add filter info strip at top if filter is active and cursor on filtered column
227 filterInfoStr := buildFilterInfoStr(currentCursorColumn)
228 if filterInfoStr != "" {
229 mainPage.AddText(filterInfoStr, true, tview.AlignCenter, tcell.NewRGBColor(255, 140, 0))
230 }
231
232 // Add main footer at bottom
233 mainPage.AddText(lstr, false, tview.AlignLeft, tcell.NewRGBColor(255, 150, 50)).
234 AddText(cstr, false, tview.AlignCenter, tcell.NewRGBColor(100, 200, 255)).
235 AddText(rstr, false, tview.AlignRight, tcell.NewRGBColor(150, 255, 150))
236 }
237

Callers 2

loadAndDisplayAsyncFunction · 0.85
loadAndDisplaySyncFunction · 0.85

Calls 15

summaryMethod · 0.95
detectAndWrapLongColumnsFunction · 0.85
drawBufferFunction · 0.85
buildCursorPosStrFunction · 0.85
buildFilterInfoStrFunction · 0.85
performSearchFunction · 0.85
I2SFunction · 0.85
showStatsDialogFunction · 0.85
getColumnMaxWidthFunction · 0.85
showHelpDialogFunction · 0.85
filterByColumnMethod · 0.80
getColTypeMethod · 0.80

Tested by

no test coverage detected