on main help sign in
Merge pull request #125 from charmbracelet/perm-dialog
ed8bdf9Kujtim Hoxha
internal/tui/components/core/core.go+15
@@ -191,6 +191,21 @@ func SelectableButtons(buttons []ButtonOpts, spacing string) string {
191 return lipgloss.JoinHorizontal(lipgloss.Left, parts...)
191 return lipgloss.JoinHorizontal(lipgloss.Left, parts...)
192}
192}
193
193
194+// SelectableButtonsVertical creates a vertical row of selectable buttons
195+func SelectableButtonsVertical(buttons []ButtonOpts, spacing int) string {
196+ var parts []string
197+ for i, button := range buttons {
198+ parts = append(parts, SelectableButton(button))
199+ if i < len(buttons)-1 {
200+ for j := 0; j < spacing; j++ {
201+ parts = append(parts, "")
202+ }
203+ }
204+ }
205+
206+ return lipgloss.JoinVertical(lipgloss.Center, parts...)
207+}
208+
194func DiffFormatter() *diffview.DiffView {
209func DiffFormatter() *diffview.DiffView {
195 t := styles.CurrentTheme()
210 t := styles.CurrentTheme()
196 formatDiff := diffview.New()
211 formatDiff := diffview.New()
internal/tui/components/dialogs/permissions/permissions.go+9−2
@@ -199,6 +199,13 @@ func (p *permissionDialogCmp) renderButtons() string {
199 }
199 }
200
200
201 content := core.SelectableButtons(buttons, " ")
201 content := core.SelectableButtons(buttons, " ")
202+ if lipgloss.Width(content) > p.width-4 {
203+ content = core.SelectableButtonsVertical(buttons, 1)
204+ return baseStyle.AlignVertical(lipgloss.Center).
205+ AlignHorizontal(lipgloss.Center).
206+ Width(p.width - 4).
207+ Render(content)
208+ }
202
209
203 return baseStyle.AlignHorizontal(lipgloss.Right).Width(p.width - 4).Render(content)
210 return baseStyle.AlignHorizontal(lipgloss.Right).Width(p.width - 4).Render(content)
204}
211}
@@ -482,7 +489,7 @@ func (p *permissionDialogCmp) SetSize() tea.Cmd {
482
489
483 switch p.permission.ToolName {
490 switch p.permission.ToolName {
484 case tools.BashToolName:
491 case tools.BashToolName:
485− p.width = int(float64(p.wWidth) * 0.4)
492+ p.width = int(float64(p.wWidth) * 0.8)
486 p.height = int(float64(p.wHeight) * 0.3)
493 p.height = int(float64(p.wHeight) * 0.3)
487 case tools.EditToolName:
494 case tools.EditToolName:
488 p.width = int(float64(p.wWidth) * 0.8)
495 p.width = int(float64(p.wWidth) * 0.8)
@@ -491,7 +498,7 @@ func (p *permissionDialogCmp) SetSize() tea.Cmd {
491 p.width = int(float64(p.wWidth) * 0.8)
498 p.width = int(float64(p.wWidth) * 0.8)
492 p.height = int(float64(p.wHeight) * 0.8)
499 p.height = int(float64(p.wHeight) * 0.8)
493 case tools.FetchToolName:
500 case tools.FetchToolName:
494− p.width = int(float64(p.wWidth) * 0.4)
501+ p.width = int(float64(p.wWidth) * 0.8)
495 p.height = int(float64(p.wHeight) * 0.3)
502 p.height = int(float64(p.wHeight) * 0.3)
496 default:
503 default:
497 p.width = int(float64(p.wWidth) * 0.7)
504 p.width = int(float64(p.wWidth) * 0.7)