View renders the command palette dialog.
()
| 257 | |
| 258 | // View renders the command palette dialog. |
| 259 | func (d *commandPaletteDialog) View() string { |
| 260 | dialogWidth, _, contentWidth := d.dialogSize() |
| 261 | d.textInput.SetWidth(contentWidth) |
| 262 | |
| 263 | gl := d.buildList(contentWidth) |
| 264 | d.updateScrollviewPosition() |
| 265 | d.scrollview.SetContent(gl.Lines(), len(gl.Lines())) |
| 266 | |
| 267 | scrollableContent := d.scrollview.View() |
| 268 | if len(d.filtered) == 0 { |
| 269 | scrollableContent = d.renderEmptyState("No commands found", contentWidth) |
| 270 | } |
| 271 | |
| 272 | content := NewContent(d.regionWidth(contentWidth)). |
| 273 | AddTitle("Commands"). |
| 274 | AddSpace(). |
| 275 | AddContent(d.textInput.View()). |
| 276 | AddSeparator(). |
| 277 | AddContent(scrollableContent). |
| 278 | AddSpace(). |
| 279 | AddHelpKeys("↑/↓", "navigate", "enter", "execute", "esc", "close"). |
| 280 | Build() |
| 281 | |
| 282 | return styles.DialogStyle.Width(dialogWidth).Render(content) |
| 283 | } |
| 284 | |
| 285 | // renderCommand renders a single command line in the list. |
| 286 | func (d *commandPaletteDialog) renderCommand(cmd commands.Item, selected bool, contentWidth int) string { |
nothing calls this directly
no test coverage detected