add buffer data to buffer table with optimized wrapped column lookup
(b *Buffer, t *tview.Table)
| 40 | |
| 41 | // add buffer data to buffer table with optimized wrapped column lookup |
| 42 | func drawBuffer(b *Buffer, t *tview.Table) { |
| 43 | b.mu.RLock() |
| 44 | defer b.mu.RUnlock() |
| 45 | |
| 46 | t.Clear() |
| 47 | cols, rows := b.colLen, b.rowLen |
| 48 | |
| 49 | // Pre-compute wrapped column info to avoid repeated map lookups |
| 50 | type colInfo struct { |
| 51 | maxWidth int |
| 52 | needsTruncate bool |
| 53 | } |
| 54 | colInfos := make([]colInfo, cols) |
| 55 | for c := 0; c < cols; c++ { |
| 56 | if width, isWrapped := wrappedColumns[c]; isWrapped { |
| 57 | colInfos[c] = colInfo{maxWidth: width, needsTruncate: true} |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | for r := 0; r < rows; r++ { |
| 62 | for c := 0; c < cols; c++ { |
| 63 | color := tcell.ColorWhite |
| 64 | backgroundColor := tcell.ColorDefault |
| 65 | attributes := tcell.AttrNone |
| 66 | alignment := tview.AlignLeft |
| 67 | |
| 68 | // Get cell content |
| 69 | cellText := b.cont[r][c] |
| 70 | |
| 71 | // Check if this is a header row/column (frozen area) |
| 72 | isHeaderRow := r < b.rowFreeze && args.Header != -1 && args.Header != 2 |
| 73 | isHeaderCol := c < b.colFreeze |
| 74 | |
| 75 | // Modern header styling with rich visual design |
| 76 | if isHeaderRow { |
| 77 | // Main header row: bold white text on gradient blue background |
| 78 | color = tcell.ColorWhite |
| 79 | backgroundColor = tcell.NewRGBColor(30, 60, 120) // Deep blue |
| 80 | attributes = tcell.AttrBold | tcell.AttrUnderline |
| 81 | alignment = tview.AlignCenter |
| 82 | |
| 83 | // Add filter indicator if this column has a filter applied |
| 84 | if isFiltered { |
| 85 | if _, hasFilter := activeFilters[c]; hasFilter { |
| 86 | cellText = "🔎 " + cellText + " 🔎" |
| 87 | backgroundColor = tcell.NewRGBColor(255, 100, 0) // Orange background for filtered column |
| 88 | } |
| 89 | } |
| 90 | } else if isHeaderCol { |
| 91 | // Frozen column: gold color for row headers |
| 92 | color = tcell.NewRGBColor(255, 215, 0) // Gold |
| 93 | attributes = tcell.AttrBold |
| 94 | } |
| 95 | |
| 96 | // Check if this cell is a search result and highlight it |
| 97 | isSearchMatch := false |
| 98 | if searchQuery != "" && len(searchResults) > 0 { |
| 99 | for _, result := range searchResults { |
no test coverage detected