Implement :next-tab, :prev-tab
This commit is contained in:
parent
589db742cb
commit
14cb8cb51f
|
@ -0,0 +1,42 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"git.sr.ht/~sircmpwn/aerc2/widgets"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Register("next-tab", NextPrevTab)
|
||||
Register("prev-tab", NextPrevTab)
|
||||
}
|
||||
|
||||
func nextPrevTabUsage(cmd string) error {
|
||||
return errors.New(fmt.Sprintf("Usage: %s [n]", cmd))
|
||||
}
|
||||
|
||||
func NextPrevTab(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) > 2 {
|
||||
return nextPrevTabUsage(args[0])
|
||||
}
|
||||
var (
|
||||
n int = 1
|
||||
err error
|
||||
)
|
||||
if len(args) > 1 {
|
||||
n, err = strconv.Atoi(args[1])
|
||||
if err != nil {
|
||||
return nextPrevTabUsage(args[0])
|
||||
}
|
||||
}
|
||||
for ; n > 0; n-- {
|
||||
if args[0] == "prev-tab" {
|
||||
aerc.PrevTab()
|
||||
} else {
|
||||
aerc.NextTab()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -117,10 +117,10 @@ G = :select-message -1<Enter>
|
|||
|
||||
J = :next-folder<Enter>
|
||||
K = :prev-folder<Enter>
|
||||
l = :next-account<Enter>
|
||||
<Right> = :next-account<Enter>
|
||||
h = :prev-account<Enter>
|
||||
<Left> = :prev-account<Enter>
|
||||
l = :next-tab<Enter>
|
||||
<Right> = :next-tab<Enter>
|
||||
h = :prev-tab<Enter>
|
||||
<Left> = :prev-tab<Enter>
|
||||
|
||||
<Enter> = :view-message<Enter>
|
||||
d = :confirm 'Really delete this message?' ':delete-message<Enter>'<Enter>
|
||||
|
@ -132,8 +132,8 @@ $ = :term-exec
|
|||
#
|
||||
# Any key not bound is passed through to the sub-terminal.
|
||||
|
||||
<Ctrl+h> = :prev-account<Enter>
|
||||
<Ctrl+l> = :next-account<Enter>
|
||||
<Ctrl+h> = :prev-tab<Enter>
|
||||
<Ctrl+l> = :next-tab<Enter>
|
||||
|
||||
[colors]
|
||||
#
|
||||
|
|
|
@ -146,6 +146,22 @@ func (aerc *Aerc) NewTab(drawable ui.Drawable, name string) *ui.Tab {
|
|||
return tab
|
||||
}
|
||||
|
||||
func (aerc *Aerc) NextTab() {
|
||||
next := aerc.tabs.Selected + 1
|
||||
if next >= len(aerc.tabs.Tabs) {
|
||||
next = 0
|
||||
}
|
||||
aerc.tabs.Select(next)
|
||||
}
|
||||
|
||||
func (aerc *Aerc) PrevTab() {
|
||||
next := aerc.tabs.Selected - 1
|
||||
if next < 0 {
|
||||
next = len(aerc.tabs.Tabs) - 1
|
||||
}
|
||||
aerc.tabs.Select(next)
|
||||
}
|
||||
|
||||
// TODO: Use per-account status lines, but a global ex line
|
||||
func (aerc *Aerc) SetStatus(status string) *StatusMessage {
|
||||
return aerc.statusline.Set(status)
|
||||
|
|
Loading…
Reference in New Issue