mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-08 02:14:53 +01:00
fix(tui): center help dilaog (#853)
This commit is contained in:
@@ -30,9 +30,10 @@ func (h *helpDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case tea.WindowSizeMsg:
|
case tea.WindowSizeMsg:
|
||||||
h.width = msg.Width
|
h.width = msg.Width
|
||||||
h.height = msg.Height
|
h.height = msg.Height
|
||||||
// Set viewport size with some padding for the modal
|
// Set viewport size with some padding for the modal, but cap at reasonable width
|
||||||
h.viewport = viewport.New(viewport.WithWidth(msg.Width-4), viewport.WithHeight(msg.Height-6))
|
maxWidth := min(80, msg.Width-8)
|
||||||
h.commandsComponent.SetSize(msg.Width-4, msg.Height-6)
|
h.viewport = viewport.New(viewport.WithWidth(maxWidth-4), viewport.WithHeight(msg.Height-6))
|
||||||
|
h.commandsComponent.SetSize(maxWidth-4, msg.Height-6)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update viewport content
|
// Update viewport content
|
||||||
@@ -73,7 +74,7 @@ func NewHelpDialog(app *app.App) HelpDialog {
|
|||||||
commandsComponent.WithShowAll(true),
|
commandsComponent.WithShowAll(true),
|
||||||
commandsComponent.WithKeybinds(true),
|
commandsComponent.WithKeybinds(true),
|
||||||
),
|
),
|
||||||
modal: modal.New(modal.WithTitle("Help")),
|
modal: modal.New(modal.WithTitle("Help"), modal.WithMaxWidth(80)),
|
||||||
viewport: vp,
|
viewport: vp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user