Skip to content

Commit

Permalink
Merge branch 'main' into chore/upgrade-golangci-lint
Browse files Browse the repository at this point in the history
* main:
  add ability to minimize panes on main view (#151)
  • Loading branch information
steezeburger committed Aug 14, 2024
2 parents 3543499 + 7f5cdac commit e73ce1b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions modules/cli/internal/processrunner/processrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type NewProcessRunnerOpts struct {
Env []string
Args []string
ReadyCheck *ReadyChecker
// TODO: add a StartsMinimized bool when TUI config is added
LogPath string
ExportLogs bool
}
Expand Down
9 changes: 8 additions & 1 deletion modules/cli/internal/ui/processpane.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type ProcessPane struct {
ansiWriter io.Writer
TickerInterval time.Duration

Title string
Title string
isMinimized bool
}

// NewProcessPane creates a new ProcessPane with a textView and processrunner.ProcessRunner
Expand All @@ -45,6 +46,7 @@ func NewProcessPane(tApp *tview.Application, pr processrunner.ProcessRunner) *Pr
pr: pr,
Title: pr.GetTitle(),
TickerInterval: 250,
isMinimized: false,
}
}

Expand Down Expand Up @@ -102,6 +104,11 @@ func (pp *ProcessPane) SetIsBorderless(isBorderless bool) {
pp.textView.SetBorder(!isBorderless)
}

// TODO: description
func (pp *ProcessPane) SetMinimized(isMinimized bool) {
pp.isMinimized = isMinimized
}

// GetTextView returns the textView associated with the ProcessPane.
func (pp *ProcessPane) GetTextView() *tview.TextView {
return pp.textView
Expand Down
20 changes: 19 additions & 1 deletion modules/cli/internal/ui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (mv *MainView) getHelpInfo() string {
output += appendStatus("(a)utoscroll", mv.s.GetIsAutoscroll()) + " | "
output += appendStatus("(w)rap lines", mv.s.GetIsWordWrap()) + " | "
output += "(up/down) select pane | "
output += "toggle (m)inimized | "
output += "(enter) fullscreen selected pane"
return output
}
Expand All @@ -85,7 +86,14 @@ func (mv *MainView) Render(_ Props) *tview.Flex {
pp.SetIsAutoScroll(mv.s.GetIsAutoscroll())
pp.SetIsBorderless(mv.s.GetIsBorderless())
pp.SetIsWordWrap(mv.s.GetIsWordWrap())
innerFlex.AddItem(pp.GetTextView(), 0, 1, true)
// flexSize controls if the pane is rendered minimized or not
var flexSize int
if pp.isMinimized {
flexSize = 2 // minimized size
} else {
flexSize = 0 // will fill all available space
}
innerFlex.AddItem(pp.GetTextView(), flexSize, 1, true)
}

mainWindowHelpInfo := tview.NewTextView().SetDynamicColors(true).SetText(mv.getHelpInfo())
Expand Down Expand Up @@ -113,6 +121,11 @@ func (mv *MainView) GetKeyboard(a AppController) func(evt *tcell.EventKey) *tcel
for _, pp := range mv.processPanes {
pp.SetIsAutoScroll(mv.s.GetIsAutoscroll())
}
// hotkey for maximizing and minimizing the panels
case 'm':
index := mv.getSelectedPaneIdx()
mv.processPanes[index].SetMinimized(!mv.processPanes[index].isMinimized)

case 'q':
a.Exit()
return nil
Expand Down Expand Up @@ -165,6 +178,11 @@ func (mv *MainView) decrementSelectedPaneIdx() {
mv.redraw()
}

// getSelectedPaneIdx returns the index of the selected panel.
func (mv *MainView) getSelectedPaneIdx() int {
return mv.selectedPaneIdx
}

// redraw ensures the correct visual state of the panes.
func (mv *MainView) redraw() {
// ui treatment for the selected pane
Expand Down

0 comments on commit e73ce1b

Please sign in to comment.