Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add next/prev split/tab support for terminal pane #3165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions internal/action/termpane.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,28 @@ func (t *TermPane) CommandMode() {
})
}

// NextSplit moves to the next split
// NextSplit changes the view to the next split
func (t *TermPane) NextSplit() {
a := t.tab.active
if a < len(t.tab.Panes)-1 {
a++
} else {
a = 0
}
a := Tabs.List[Tabs.Active()]
a.SetActive((a.active + 1) % len(a.Panes))
}

// PreviousSplit changes the view to the previous split
func (t *TermPane) PreviousSplit() {
a := Tabs.List[Tabs.Active()]
panesLen := len(a.Panes)
a.SetActive((a.active + panesLen - 1) % panesLen)
}

// PreviousTab switches to the previous tab in the tab list
func (t *TermPane) PreviousTab() {
tabsLen := len(Tabs.List)
Tabs.SetActive((Tabs.Active() + tabsLen - 1) % tabsLen)
}

t.tab.SetActive(a)
// NextTab switches to the next tab in the tab list
func (t *TermPane) NextTab() {
Tabs.SetActive((Tabs.Active() + 1) % len(Tabs.List))
}

// HandleCommand handles a command for the term pane
Expand All @@ -228,7 +240,10 @@ func (t *TermPane) HandleCommand(input string) {

// TermKeyActions contains the list of all possible key actions the termpane could execute
var TermKeyActions = map[string]TermKeyAction{
"Exit": (*TermPane).Exit,
"CommandMode": (*TermPane).CommandMode,
"NextSplit": (*TermPane).NextSplit,
"Exit": (*TermPane).Exit,
"CommandMode": (*TermPane).CommandMode,
"NextSplit": (*TermPane).NextSplit,
"PreviousSplit": (*TermPane).PreviousSplit,
"NextTab": (*TermPane).NextTab,
"PreviousTab": (*TermPane).PreviousTab,
}