diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-03-21 20:57:52 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-04-30 13:19:53 +1000 |
commit | 509e3efa70512ed34b90177eb17d6481664bb958 (patch) | |
tree | 663333126d6764706462271712583e4c8e93d786 /pkg/gui/view_helpers.go | |
parent | 8edad826caf2fa48bfad33f9f8c4f3ba49a052da (diff) |
lots more refactoring
Diffstat (limited to 'pkg/gui/view_helpers.go')
-rw-r--r-- | pkg/gui/view_helpers.go | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 7e6e6510e..85ec21128 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -62,71 +62,6 @@ func (gui *Gui) currentViewName() string { return currentView.Name() } -func (gui *Gui) resizeCurrentPopupPanel() error { - v := gui.g.CurrentView() - if v == nil { - return nil - } - - 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()) - } - - return nil -} - -func (gui *Gui) resizePopupPanel(v *gocui.View, content string) error { - x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(v.Wrap, content) - _, 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() - wrap := true - if gui.Views.Confirmation.Editable { - prompt = gui.Views.Confirmation.TextArea.GetContent() - wrap = false - } - panelHeight := gui.getMessageHeight(wrap, 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) isPopupPanel(viewName string) bool { - return viewName == "commitMessage" || viewName == "confirmation" || viewName == "menu" -} - -func (gui *Gui) popupPanelFocused() bool { - return gui.isPopupPanel(gui.currentViewName()) -} - func (gui *Gui) onViewTabClick(windowName string, tabIndex int) error { tabs := gui.viewTabMap()[windowName] if len(tabs) == 0 { |