Render renders the help overlay.
()
| 122 | |
| 123 | // Render renders the help overlay. |
| 124 | func (h *HelpOverlay) Render() string { |
| 125 | // Modal dimensions |
| 126 | modalWidth := min(70, h.width-10) |
| 127 | modalHeight := min(24, h.height-6) |
| 128 | |
| 129 | if modalWidth < 40 { |
| 130 | modalWidth = 40 |
| 131 | } |
| 132 | if modalHeight < 14 { |
| 133 | modalHeight = 14 |
| 134 | } |
| 135 | |
| 136 | // Build modal content |
| 137 | var content strings.Builder |
| 138 | |
| 139 | // Title |
| 140 | titleStyle := lipgloss.NewStyle(). |
| 141 | Bold(true). |
| 142 | Foreground(PrimaryColor). |
| 143 | Padding(0, 1) |
| 144 | content.WriteString(titleStyle.Render("Keyboard Shortcuts")) |
| 145 | content.WriteString("\n") |
| 146 | content.WriteString(DividerStyle.Render(strings.Repeat("─", modalWidth-4))) |
| 147 | content.WriteString("\n\n") |
| 148 | |
| 149 | // Get categories based on current view |
| 150 | categories := h.GetCategories() |
| 151 | |
| 152 | // Render categories in two columns |
| 153 | leftCol := &strings.Builder{} |
| 154 | rightCol := &strings.Builder{} |
| 155 | colWidth := (modalWidth - 8) / 2 |
| 156 | |
| 157 | for i, cat := range categories { |
| 158 | col := leftCol |
| 159 | if i >= (len(categories)+1)/2 { |
| 160 | col = rightCol |
| 161 | } |
| 162 | h.renderCategory(col, cat, colWidth) |
| 163 | } |
| 164 | |
| 165 | // Join columns horizontally |
| 166 | leftLines := strings.Split(leftCol.String(), "\n") |
| 167 | rightLines := strings.Split(rightCol.String(), "\n") |
| 168 | |
| 169 | // Ensure both columns have the same number of lines |
| 170 | maxLines := max(len(leftLines), len(rightLines)) |
| 171 | for len(leftLines) < maxLines { |
| 172 | leftLines = append(leftLines, "") |
| 173 | } |
| 174 | for len(rightLines) < maxLines { |
| 175 | rightLines = append(rightLines, "") |
| 176 | } |
| 177 | |
| 178 | // Combine columns |
| 179 | for i := 0; i < maxLines; i++ { |
| 180 | leftLine := leftLines[i] |
| 181 | rightLine := rightLines[i] |
no test coverage detected