tabs: rename SelectedTab to SelectedTabContent
This function returns an ui.Drawable. Use a more explicit name. This prepares for adding a new SelectedTab function which will return an ui.Tab. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
parent
c49a065496
commit
c841f36513
4
aerc.go
4
aerc.go
|
@ -59,7 +59,7 @@ func getCommands(selected libui.Drawable) []*commands.Commands {
|
|||
}
|
||||
|
||||
func execCommand(aerc *widgets.Aerc, ui *libui.UI, cmd []string) error {
|
||||
cmds := getCommands(aerc.SelectedTab())
|
||||
cmds := getCommands(aerc.SelectedTabContent())
|
||||
for i, set := range cmds {
|
||||
err := set.ExecuteCommand(aerc, cmd)
|
||||
if _, ok := err.(commands.NoSuchCommand); ok {
|
||||
|
@ -81,7 +81,7 @@ func execCommand(aerc *widgets.Aerc, ui *libui.UI, cmd []string) error {
|
|||
|
||||
func getCompletions(aerc *widgets.Aerc, cmd string) []string {
|
||||
var completions []string
|
||||
for _, set := range getCommands(aerc.SelectedTab()) {
|
||||
for _, set := range getCommands(aerc.SelectedTabContent()) {
|
||||
completions = append(completions, set.GetCompletions(aerc, cmd)...)
|
||||
}
|
||||
sort.Strings(completions)
|
||||
|
|
|
@ -24,7 +24,7 @@ func (Abort) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) != 1 {
|
||||
return errors.New("Usage: abort")
|
||||
}
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
|
||||
aerc.RemoveTab(composer)
|
||||
composer.Close()
|
||||
|
|
|
@ -25,7 +25,7 @@ func (AttachKey) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return errors.New("Usage: attach-key")
|
||||
}
|
||||
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
|
||||
return composer.SetAttachKey(!composer.AttachKey())
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ func (Attach) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
composer.AddAttachment(path)
|
||||
|
||||
aerc.PushSuccess(fmt.Sprintf("Attached %s", pathinfo.Name()))
|
||||
|
|
|
@ -25,7 +25,7 @@ func (CC) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) > 1 {
|
||||
addrs = strings.Join(args[1:], " ")
|
||||
}
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
|
||||
switch args[0] {
|
||||
case "cc":
|
||||
|
|
|
@ -18,13 +18,13 @@ func (Detach) Aliases() []string {
|
|||
}
|
||||
|
||||
func (Detach) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
return composer.GetAttachments()
|
||||
}
|
||||
|
||||
func (Detach) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
var path string
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
|
||||
if len(args) > 1 {
|
||||
path = strings.Join(args[1:], " ")
|
||||
|
|
|
@ -24,7 +24,7 @@ func (Edit) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) != 1 {
|
||||
return errors.New("Usage: edit")
|
||||
}
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
composer.ShowTerminal()
|
||||
composer.FocusTerminal()
|
||||
return nil
|
||||
|
|
|
@ -25,7 +25,7 @@ func (Encrypt) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return errors.New("Usage: encrypt")
|
||||
}
|
||||
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
|
||||
composer.SetEncrypt(!composer.Encrypt())
|
||||
return nil
|
||||
|
|
|
@ -60,7 +60,7 @@ func (Header) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
}
|
||||
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
|
||||
args[optind] = strings.TrimRight(args[optind], ":")
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ func (NextPrevField) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) > 2 {
|
||||
return nextPrevFieldUsage(args[0])
|
||||
}
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
if args[0] == "prev-field" {
|
||||
composer.PrevField()
|
||||
} else {
|
||||
|
|
|
@ -35,7 +35,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if acct == nil {
|
||||
return errors.New("No account selected")
|
||||
}
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
config := composer.Config()
|
||||
tabName := aerc.TabNames()[aerc.SelectedTabIndex()]
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) > 1 {
|
||||
return errors.New("Usage: send")
|
||||
}
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
tabName := aerc.TabNames()[aerc.SelectedTabIndex()]
|
||||
config := composer.Config()
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ func (Sign) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return errors.New("Usage: sign")
|
||||
}
|
||||
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
composer, _ := aerc.SelectedTabContent().(*widgets.Composer)
|
||||
|
||||
err := composer.SetSign(!composer.Sign())
|
||||
if err != nil {
|
||||
|
|
|
@ -33,7 +33,7 @@ func (ExecCmd) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
cmd := exec.Command(args[1], args[2:]...)
|
||||
env := os.Environ()
|
||||
|
||||
switch view := aerc.SelectedTab().(type) {
|
||||
switch view := aerc.SelectedTabContent().(type) {
|
||||
case *widgets.AccountView:
|
||||
env = append(env, fmt.Sprintf("account=%s", view.AccountConfig().Name))
|
||||
env = append(env, fmt.Sprintf("folder=%s", view.Directories().Selected()))
|
||||
|
|
|
@ -60,7 +60,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return errors.New("Options -A and -F are mutually exclusive")
|
||||
}
|
||||
|
||||
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
|
||||
widget := aerc.SelectedTabContent().(widgets.ProvidesMessage)
|
||||
acct := widget.SelectedAccount()
|
||||
if acct == nil {
|
||||
return errors.New("No account selected")
|
||||
|
|
|
@ -63,7 +63,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return errors.New("Usage: pipe [-mp] <cmd> [args...]")
|
||||
}
|
||||
|
||||
provider := aerc.SelectedTab().(widgets.ProvidesMessage)
|
||||
provider := aerc.SelectedTabContent().(widgets.ProvidesMessage)
|
||||
if !pipeFull && !pipePart {
|
||||
if _, ok := provider.(*widgets.MessageViewer); ok {
|
||||
pipePart = true
|
||||
|
|
|
@ -51,7 +51,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return errors.New("Usage: recall [-f]")
|
||||
}
|
||||
|
||||
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
|
||||
widget := aerc.SelectedTabContent().(widgets.ProvidesMessage)
|
||||
acct := widget.SelectedAccount()
|
||||
if acct == nil {
|
||||
return errors.New("No account selected")
|
||||
|
|
|
@ -55,7 +55,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
}
|
||||
|
||||
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
|
||||
widget := aerc.SelectedTabContent().(widgets.ProvidesMessage)
|
||||
acct := widget.SelectedAccount()
|
||||
|
||||
if acct == nil {
|
||||
|
|
|
@ -37,7 +37,7 @@ func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) != 1 {
|
||||
return errors.New("Usage: unsubscribe")
|
||||
}
|
||||
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
|
||||
widget := aerc.SelectedTabContent().(widgets.ProvidesMessage)
|
||||
msg, err := widget.SelectedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -135,7 +135,7 @@ func parseUnsubscribeMethods(header string) (methods []*url.URL) {
|
|||
}
|
||||
|
||||
func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error {
|
||||
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
|
||||
widget := aerc.SelectedTabContent().(widgets.ProvidesMessage)
|
||||
acct := widget.SelectedAccount()
|
||||
if acct == nil {
|
||||
return errors.New("No account selected")
|
||||
|
|
|
@ -14,7 +14,7 @@ type helper struct {
|
|||
}
|
||||
|
||||
func newHelper(aerc *widgets.Aerc) *helper {
|
||||
return &helper{aerc.SelectedTab().(widgets.ProvidesMessages)}
|
||||
return &helper{aerc.SelectedTabContent().(widgets.ProvidesMessages)}
|
||||
}
|
||||
|
||||
func (h *helper) markedOrSelectedUids() ([]uint32, error) {
|
||||
|
|
|
@ -24,7 +24,7 @@ func (Close) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) != 1 {
|
||||
return errors.New("Usage: close")
|
||||
}
|
||||
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer)
|
||||
mv.Close()
|
||||
aerc.RemoveTab(mv)
|
||||
return nil
|
||||
|
|
|
@ -35,7 +35,7 @@ func (NextPrevPart) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return nextPrevPartUsage(args[0])
|
||||
}
|
||||
}
|
||||
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer)
|
||||
for ; n > 0; n-- {
|
||||
if args[0] == "prev-part" {
|
||||
mv.PreviousPart()
|
||||
|
|
|
@ -27,7 +27,7 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer)
|
||||
acct := mv.SelectedAccount()
|
||||
if acct == nil {
|
||||
return errors.New("No account selected")
|
||||
|
|
|
@ -25,7 +25,7 @@ func (Open) Aliases() []string {
|
|||
}
|
||||
|
||||
func (Open) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
mv := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
mv := aerc.SelectedTabContent().(*widgets.MessageViewer)
|
||||
if mv != nil {
|
||||
if p := mv.SelectedMessagePart(); p != nil {
|
||||
return commands.CompletionFromList(aerc, p.Links, args)
|
||||
|
@ -35,7 +35,7 @@ func (Open) Complete(aerc *widgets.Aerc, args []string) []string {
|
|||
}
|
||||
|
||||
func (Open) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
mv := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
mv := aerc.SelectedTabContent().(*widgets.MessageViewer)
|
||||
p := mv.SelectedMessagePart()
|
||||
|
||||
if args[0] == "open-link" && len(args) > 1 {
|
||||
|
|
|
@ -99,9 +99,9 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
mv, ok := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
mv, ok := aerc.SelectedTabContent().(*widgets.MessageViewer)
|
||||
if !ok {
|
||||
return fmt.Errorf("SelectedTab is not a MessageViewer")
|
||||
return fmt.Errorf("SelectedTabContent is not a MessageViewer")
|
||||
}
|
||||
|
||||
if params.attachments {
|
||||
|
|
|
@ -24,7 +24,7 @@ func (ToggleHeaders) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) > 1 {
|
||||
return toggleHeadersUsage(args[0])
|
||||
}
|
||||
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer)
|
||||
mv.ToggleHeaders()
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func (ToggleKeyPassthrough) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) != 1 {
|
||||
return errors.New("Usage: toggle-key-passthrough")
|
||||
}
|
||||
mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
|
||||
mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer)
|
||||
keyPassthroughEnabled := mv.ToggleKeyPassthrough()
|
||||
if acct := mv.SelectedAccount(); acct != nil {
|
||||
acct.SetStatus(statusline.Passthrough(keyPassthroughEnabled))
|
||||
|
|
|
@ -24,7 +24,7 @@ func (Close) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if len(args) != 1 {
|
||||
return errors.New("Usage: close")
|
||||
}
|
||||
term, _ := aerc.SelectedTab().(*widgets.Terminal)
|
||||
term, _ := aerc.SelectedTabContent().(*widgets.Terminal)
|
||||
term.Close(nil)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ func (aerc *Aerc) getBindings() *config.KeyBindings {
|
|||
if aerc.SelectedAccount() != nil {
|
||||
selectedAccountName = aerc.SelectedAccount().acct.Name
|
||||
}
|
||||
switch view := aerc.SelectedTab().(type) {
|
||||
switch view := aerc.SelectedTabContent().(type) {
|
||||
case *AccountView:
|
||||
binds := aerc.conf.MergeContextualBinds(aerc.conf.Bindings.MessageList, config.BIND_CONTEXT_ACCOUNT, selectedAccountName, "messages")
|
||||
return aerc.conf.MergeContextualBinds(binds, config.BIND_CONTEXT_FOLDER, view.SelectedDirectory(), "messages")
|
||||
|
@ -310,7 +310,7 @@ func (aerc *Aerc) Logger() *log.Logger {
|
|||
}
|
||||
|
||||
func (aerc *Aerc) SelectedAccount() *AccountView {
|
||||
return aerc.account(aerc.SelectedTab())
|
||||
return aerc.account(aerc.SelectedTabContent())
|
||||
}
|
||||
|
||||
func (aerc *Aerc) account(d ui.Drawable) *AccountView {
|
||||
|
@ -333,7 +333,7 @@ func (aerc *Aerc) SelectedAccountUiConfig() *config.UIConfig {
|
|||
return acct.UiConfig()
|
||||
}
|
||||
|
||||
func (aerc *Aerc) SelectedTab() ui.Drawable {
|
||||
func (aerc *Aerc) SelectedTabContent() ui.Drawable {
|
||||
if aerc.NumTabs() == 0 || aerc.SelectedTabIndex() >= aerc.NumTabs() {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue