MCPcopy
hub / github.com/docker/docker-agent / View

Method View

pkg/tui/dialog/command_palette.go:259–283  ·  view source on GitHub ↗

View renders the command palette dialog.

()

Source from the content-addressed store, hash-verified

257
258// View renders the command palette dialog.
259func (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.
286func (d *commandPaletteDialog) renderCommand(cmd commands.Item, selected bool, contentWidth int) string {

Callers

nothing calls this directly

Calls 15

buildListMethod · 0.95
NewContentFunction · 0.85
SetContentMethod · 0.80
LinesMethod · 0.80
renderEmptyStateMethod · 0.80
AddHelpKeysMethod · 0.80
AddSpaceMethod · 0.80
AddSeparatorMethod · 0.80
AddTitleMethod · 0.80
regionWidthMethod · 0.80
ViewMethod · 0.65
RenderMethod · 0.65

Tested by

no test coverage detected