summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/gui/confirmation_panel.go13
-rw-r--r--pkg/gui/menu_panel.go13
-rw-r--r--pkg/gui/view_helpers.go37
3 files changed, 32 insertions, 31 deletions
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index 8ddb9b260..5d8a13bb7 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -130,13 +130,6 @@ func (gui *Gui) prepareConfirmationPanel(
editable bool,
mask bool,
) error {
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(true, prompt)
- // calling SetView on an existing view returns the same view, so I'm not bothering
- // to reassign to gui.Views.Confirmation
- _, err := gui.g.SetView("confirmation", x0, y0, x1, y1, 0)
- if err != nil {
- return err
- }
gui.Views.Confirmation.HasLoader = hasLoader
if hasLoader {
gui.g.StartTicking()
@@ -149,11 +142,7 @@ func (gui *Gui) prepareConfirmationPanel(
gui.findSuggestions = findSuggestionsFunc
if findSuggestionsFunc != nil {
- suggestionsViewHeight := 11
- suggestionsView, err := gui.g.SetView("suggestions", x0, y1+1, x1, y1+suggestionsViewHeight, 0)
- if err != nil {
- return err
- }
+ suggestionsView := gui.Views.Suggestions
suggestionsView.Wrap = false
suggestionsView.FgColor = theme.GocuiDefaultTextColor
gui.setSuggestions(findSuggestionsFunc(""))
diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go
index dcc9831e1..459fd60ce 100644
--- a/pkg/gui/menu_panel.go
+++ b/pkg/gui/menu_panel.go
@@ -59,16 +59,3 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
// TODO: ensure that if we're opened a menu from within a menu that it renders correctly
return gui.c.PushContext(gui.State.Contexts.Menu)
}
-
-func (gui *Gui) resizeMenu() {
- itemCount := gui.State.Contexts.Menu.GetList().Len()
- offset := 3
- panelWidth := gui.getConfirmationPanelWidth()
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensionsForContentHeight(panelWidth, itemCount+offset)
- menuBottom := y1 - offset
- _, _ = gui.g.SetView("menu", x0, y0, x1, menuBottom, 0)
-
- tooltipTop := menuBottom + 1
- tooltipHeight := gui.getMessageHeight(true, gui.State.Contexts.Menu.GetSelected().Tooltip, panelWidth) + 2 // plus 2 for the frame
- _, _ = gui.g.SetView("tooltip", x0, tooltipTop, x1, tooltipTop+tooltipHeight-1, 0)
-}
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index 52bc6fefa..023a1b41c 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -50,6 +50,8 @@ func (gui *Gui) resizeCurrentPopupPanel() error {
if v == gui.Views.Menu {
gui.resizeMenu()
+ } else if v == gui.Views.Confirmation || v == gui.Views.Suggestions {
+ gui.resizeConfirmationPanel()
} else if gui.isPopupPanel(v.Name()) {
return gui.resizePopupPanel(v, v.Buffer())
}
@@ -58,17 +60,40 @@ func (gui *Gui) resizeCurrentPopupPanel() error {
}
func (gui *Gui) resizePopupPanel(v *gocui.View, content string) error {
- // If the confirmation panel is already displayed, just resize the width,
- // otherwise continue
x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(v.Wrap, content)
- vx0, vy0, vx1, vy1 := v.Dimensions()
- if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
- return nil
- }
_, err := gui.g.SetView(v.Name(), x0, y0, x1, y1, 0)
return err
}
+func (gui *Gui) resizeMenu() {
+ itemCount := gui.State.Contexts.Menu.GetList().Len()
+ offset := 3
+ panelWidth := gui.getConfirmationPanelWidth()
+ x0, y0, x1, y1 := gui.getConfirmationPanelDimensionsForContentHeight(panelWidth, itemCount+offset)
+ menuBottom := y1 - offset
+ _, _ = gui.g.SetView(gui.Views.Menu.Name(), x0, y0, x1, menuBottom, 0)
+
+ tooltipTop := menuBottom + 1
+ tooltipHeight := gui.getMessageHeight(true, gui.State.Contexts.Menu.GetSelected().Tooltip, panelWidth) + 2 // plus 2 for the frame
+ _, _ = gui.g.SetView(gui.Views.Tooltip.Name(), x0, tooltipTop, x1, tooltipTop+tooltipHeight-1, 0)
+}
+
+func (gui *Gui) resizeConfirmationPanel() {
+ suggestionsViewHeight := 0
+ if gui.Views.Suggestions.Visible {
+ suggestionsViewHeight = 11
+ }
+ panelWidth := gui.getConfirmationPanelWidth()
+ prompt := gui.Views.Confirmation.Buffer()
+ panelHeight := gui.getMessageHeight(true, prompt, panelWidth) + suggestionsViewHeight
+ x0, y0, x1, y1 := gui.getConfirmationPanelDimensionsAux(panelWidth, panelHeight)
+ confirmationViewBottom := y1 - suggestionsViewHeight
+ _, _ = gui.g.SetView(gui.Views.Confirmation.Name(), x0, y0, x1, confirmationViewBottom, 0)
+
+ suggestionsViewTop := confirmationViewBottom + 1
+ _, _ = gui.g.SetView(gui.Views.Suggestions.Name(), x0, suggestionsViewTop, x1, suggestionsViewTop+suggestionsViewHeight, 0)
+}
+
func (gui *Gui) globalOptionsMap() map[string]string {
keybindingConfig := gui.c.UserConfig.Keybinding