diff options
Diffstat (limited to 'commands')
78 files changed, 340 insertions, 340 deletions
diff --git a/commands/account/cf.go b/commands/account/cf.go index f0fa3b67..38841474 100644 --- a/commands/account/cf.go +++ b/commands/account/cf.go @@ -4,9 +4,9 @@ import ( "errors" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/lib/state" - "git.sr.ht/~rjarry/aerc/widgets" ) var history map[string]string @@ -22,11 +22,11 @@ func (ChangeFolder) Aliases() []string { return []string{"cf"} } -func (ChangeFolder) Complete(aerc *widgets.Aerc, args []string) []string { +func (ChangeFolder) Complete(aerc *app.Aerc, args []string) []string { return commands.GetFolders(aerc, args) } -func (ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error { +func (ChangeFolder) Execute(aerc *app.Aerc, args []string) error { if len(args) == 1 { return errors.New("Usage: cf <folder>") } diff --git a/commands/account/check-mail.go b/commands/account/check-mail.go index eb57c0c0..2b6a06f9 100644 --- a/commands/account/check-mail.go +++ b/commands/account/check-mail.go @@ -3,7 +3,7 @@ package account import ( "errors" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type CheckMail struct{} @@ -16,11 +16,11 @@ func (CheckMail) Aliases() []string { return []string{"check-mail"} } -func (CheckMail) Complete(aerc *widgets.Aerc, args []string) []string { +func (CheckMail) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (CheckMail) Execute(aerc *widgets.Aerc, args []string) error { +func (CheckMail) Execute(aerc *app.Aerc, args []string) error { acct := aerc.SelectedAccount() if acct == nil { return errors.New("No account selected") diff --git a/commands/account/clear.go b/commands/account/clear.go index a383b621..547c26c4 100644 --- a/commands/account/clear.go +++ b/commands/account/clear.go @@ -3,8 +3,8 @@ package account import ( "errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/state" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" ) @@ -18,11 +18,11 @@ func (Clear) Aliases() []string { return []string{"clear"} } -func (Clear) Complete(aerc *widgets.Aerc, args []string) []string { +func (Clear) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Clear) Execute(aerc *widgets.Aerc, args []string) error { +func (Clear) Execute(aerc *app.Aerc, args []string) error { acct := aerc.SelectedAccount() if acct == nil { return errors.New("No account selected") diff --git a/commands/account/compose.go b/commands/account/compose.go index 5da0f163..e2812251 100644 --- a/commands/account/compose.go +++ b/commands/account/compose.go @@ -10,8 +10,8 @@ import ( "github.com/emersion/go-message/mail" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/config" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" ) @@ -25,11 +25,11 @@ func (Compose) Aliases() []string { return []string{"compose"} } -func (Compose) Complete(aerc *widgets.Aerc, args []string) []string { +func (Compose) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Compose) Execute(aerc *widgets.Aerc, args []string) error { +func (Compose) Execute(aerc *app.Aerc, args []string) error { body, template, editHeaders, err := buildBody(args) if err != nil { return err @@ -50,7 +50,7 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error { } headers := mail.HeaderFromMap(msg.Header) - composer, err := widgets.NewComposer(aerc, acct, + composer, err := app.NewComposer(aerc, acct, acct.AccountConfig(), acct.Worker(), editHeaders, template, &headers, nil, msg.Body) if err != nil { diff --git a/commands/account/connection.go b/commands/account/connection.go index 0a67b2fe..2704d9bb 100644 --- a/commands/account/connection.go +++ b/commands/account/connection.go @@ -3,8 +3,8 @@ package account import ( "errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/state" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -18,11 +18,11 @@ func (Connection) Aliases() []string { return []string{"connect", "disconnect"} } -func (Connection) Complete(aerc *widgets.Aerc, args []string) []string { +func (Connection) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Connection) Execute(aerc *widgets.Aerc, args []string) error { +func (Connection) Execute(aerc *app.Aerc, args []string) error { acct := aerc.SelectedAccount() if acct == nil { return errors.New("No account selected") diff --git a/commands/account/expand-folder.go b/commands/account/expand-folder.go index 3eafaa09..8a7a8e93 100644 --- a/commands/account/expand-folder.go +++ b/commands/account/expand-folder.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type ExpandCollapseFolder struct{} @@ -17,11 +17,11 @@ func (ExpandCollapseFolder) Aliases() []string { return []string{"expand-folder", "collapse-folder"} } -func (ExpandCollapseFolder) Complete(aerc *widgets.Aerc, args []string) []string { +func (ExpandCollapseFolder) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (ExpandCollapseFolder) Execute(aerc *widgets.Aerc, args []string) error { +func (ExpandCollapseFolder) Execute(aerc *app.Aerc, args []string) error { if len(args) > 1 { return expandCollapseFolderUsage(args[0]) } diff --git a/commands/account/export-mbox.go b/commands/account/export-mbox.go index 8981261b..c227bdf9 100644 --- a/commands/account/export-mbox.go +++ b/commands/account/export-mbox.go @@ -8,9 +8,9 @@ import ( "sync" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" mboxer "git.sr.ht/~rjarry/aerc/worker/mbox" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -25,11 +25,11 @@ func (ExportMbox) Aliases() []string { return []string{"export-mbox"} } -func (ExportMbox) Complete(aerc *widgets.Aerc, args []string) []string { +func (ExportMbox) Complete(aerc *app.Aerc, args []string) []string { return commands.CompletePath(filepath.Join(args...)) } -func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error { +func (ExportMbox) Execute(aerc *app.Aerc, args []string) error { if len(args) != 2 { return exportFolderUsage(args[0]) } @@ -59,7 +59,7 @@ func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error { var uids []uint32 // check if something is marked - we export that then - msgProvider, ok := aerc.SelectedTabContent().(widgets.ProvidesMessages) + msgProvider, ok := aerc.SelectedTabContent().(app.ProvidesMessages) if !ok { msgProvider = aerc.SelectedAccount() } diff --git a/commands/account/import-mbox.go b/commands/account/import-mbox.go index 85e9a341..2a441737 100644 --- a/commands/account/import-mbox.go +++ b/commands/account/import-mbox.go @@ -10,10 +10,10 @@ import ( "sync/atomic" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" mboxer "git.sr.ht/~rjarry/aerc/worker/mbox" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -28,11 +28,11 @@ func (ImportMbox) Aliases() []string { return []string{"import-mbox"} } -func (ImportMbox) Complete(aerc *widgets.Aerc, args []string) []string { +func (ImportMbox) Complete(aerc *app.Aerc, args []string) []string { return commands.CompletePath(filepath.Join(args...)) } -func (ImportMbox) Execute(aerc *widgets.Aerc, args []string) error { +func (ImportMbox) Execute(aerc *app.Aerc, args []string) error { if len(args) != 2 { return importFolderUsage(args[0]) } @@ -129,7 +129,7 @@ func (ImportMbox) Execute(aerc *widgets.Aerc, args []string) error { } if len(store.Uids()) > 0 { - confirm := widgets.NewSelectorDialog( + confirm := app.NewSelectorDialog( "Selected directory is not empty", fmt.Sprintf("Import mbox file to %s anyways?", folder), []string{"No", "Yes"}, 0, aerc.SelectedAccountUiConfig(), diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go index 02d997e4..79e0a4fa 100644 --- a/commands/account/mkdir.go +++ b/commands/account/mkdir.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -19,7 +19,7 @@ func (MakeDir) Aliases() []string { return []string{"mkdir"} } -func (MakeDir) Complete(aerc *widgets.Aerc, args []string) []string { +func (MakeDir) Complete(aerc *app.Aerc, args []string) []string { if len(args) == 0 { return nil } @@ -41,7 +41,7 @@ func (MakeDir) Complete(aerc *widgets.Aerc, args []string) []string { return inboxes } -func (MakeDir) Execute(aerc *widgets.Aerc, args []string) error { +func (MakeDir) Execute(aerc *app.Aerc, args []string) error { if len(args) == 0 { return errors.New("Usage: :mkdir <name>") } diff --git a/commands/account/next-folder.go b/commands/account/next-folder.go index e3541e52..b0657ff1 100644 --- a/commands/account/next-folder.go +++ b/commands/account/next-folder.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type NextPrevFolder struct{} @@ -18,11 +18,11 @@ func (NextPrevFolder) Aliases() []string { return []string{"next-folder", "prev-folder"} } -func (NextPrevFolder) Complete(aerc *widgets.Aerc, args []string) []string { +func (NextPrevFolder) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (NextPrevFolder) Execute(aerc *widgets.Aerc, args []string) error { +func (NextPrevFolder) Execute(aerc *app.Aerc, args []string) error { if len(args) > 2 { return nextPrevFolderUsage(args[0]) } diff --git a/commands/account/next-result.go b/commands/account/next-result.go index 922f95a1..06478f0c 100644 --- a/commands/account/next-result.go +++ b/commands/account/next-result.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/ui" - "git.sr.ht/~rjarry/aerc/widgets" ) type NextPrevResult struct{} @@ -18,11 +18,11 @@ func (NextPrevResult) Aliases() []string { return []string{"next-result", "prev-result"} } -func (NextPrevResult) Complete(aerc *widgets.Aerc, args []string) []string { +func (NextPrevResult) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (NextPrevResult) Execute(aerc *widgets.Aerc, args []string) error { +func (NextPrevResult) Execute(aerc *app.Aerc, args []string) error { if len(args) > 1 { return nextPrevResultUsage(args[0]) } diff --git a/commands/account/next.go b/commands/account/next.go index 15dc5363..224534b9 100644 --- a/commands/account/next.go +++ b/commands/account/next.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/ui" - "git.sr.ht/~rjarry/aerc/widgets" ) type NextPrevMsg struct{} @@ -20,11 +20,11 @@ func (NextPrevMsg) Aliases() []string { return []string{"next", "next-message", "prev", "prev-message"} } -func (NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string { +func (NextPrevMsg) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error { +func (NextPrevMsg) Execute(aerc *app.Aerc, args []string) error { n, pct, err := ParseNextPrevMessage(args) if err != nil { return err @@ -58,7 +58,7 @@ func ParseNextPrevMessage(args []string) (int, bool, error) { return n, pct, nil } -func ExecuteNextPrevMessage(args []string, acct *widgets.AccountView, pct bool, n int) error { +func ExecuteNextPrevMessage(args []string, acct *app.AccountView, pct bool, n int) error { if pct { n = int(float64(acct.Messages().Height()) * (float64(n) / 100.0)) } diff --git a/commands/account/recover.go b/commands/account/recover.go index 9fdaa3e9..1bb1aceb 100644 --- a/commands/account/recover.go +++ b/commands/account/recover.go @@ -7,9 +7,9 @@ import ( "os" "path/filepath" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/config" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" ) @@ -27,7 +27,7 @@ func (Recover) Options() string { return "feE" } -func (r Recover) Complete(aerc *widgets.Aerc, args []string) []string { +func (r Recover) Complete(aerc *app.Aerc, args []string) []string { // file name of temp file is hard-coded in the NewComposer() function files, err := filepath.Glob( filepath.Join(os.TempDir(), "aerc-compose-*.eml"), @@ -39,7 +39,7 @@ func (r Recover) Complete(aerc *widgets.Aerc, args []string) []string { commands.Operands(args, r.Options())) } -func (r Recover) Execute(aerc *widgets.Aerc, args []string) error { +func (r Recover) Execute(aerc *app.Aerc, args []string) error { // Complete() expects to be passed only the arguments, not including the command name if len(Recover{}.Complete(aerc, args[1:])) == 0 { return errors.New("No messages to recover.") @@ -89,7 +89,7 @@ func (r Recover) Execute(aerc *widgets.Aerc, args []string) error { return err } - composer, err := widgets.NewComposer(aerc, acct, + composer, err := app.NewComposer(aerc, acct, acct.AccountConfig(), acct.Worker(), editHeaders, "", nil, nil, bytes.NewReader(data)) if err != nil { diff --git a/commands/account/rmdir.go b/commands/account/rmdir.go index 9f6fedeb..eca8b59f 100644 --- a/commands/account/rmdir.go +++ b/commands/account/rmdir.go @@ -6,7 +6,7 @@ import ( "git.sr.ht/~sircmpwn/getopt" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -20,11 +20,11 @@ func (RemoveDir) Aliases() []string { return []string{"rmdir"} } -func (RemoveDir) Complete(aerc *widgets.Aerc, args []string) []string { +func (RemoveDir) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (RemoveDir) Execute(aerc *widgets.Aerc, args []string) error { +func (RemoveDir) Execute(aerc *app.Aerc, args []string) error { acct := aerc.SelectedAccount() if acct == nil { return errors.New("No account selected") diff --git a/commands/account/search.go b/commands/account/search.go index d7884f15..04f7ddc3 100644 --- a/commands/account/search.go +++ b/commands/account/search.go @@ -4,11 +4,11 @@ import ( "errors" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/lib/state" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -27,7 +27,7 @@ func (SearchFilter) Aliases() []string { } func (s SearchFilter) CompleteOption( - aerc *widgets.Aerc, + aerc *app.Aerc, r rune, search string, ) []string { @@ -44,11 +44,11 @@ func (s SearchFilter) CompleteOption( return commands.CompletionFromList(aerc, valid, []string{search}) } -func (SearchFilter) Complete(aerc *widgets.Aerc, args []string) []string { +func (SearchFilter) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (SearchFilter) Execute(aerc *widgets.Aerc, args []string) error { +func (SearchFilter) Execute(aerc *app.Aerc, args []string) error { acct := aerc.SelectedAccount() if acct == nil { return errors.New("No account selected") diff --git a/commands/account/select.go b/commands/account/select.go index 28aedfa5..aeb584f4 100644 --- a/commands/account/select.go +++ b/commands/account/select.go @@ -4,7 +4,7 @@ import ( "errors" "strconv" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type SelectMessage struct{} @@ -17,11 +17,11 @@ func (SelectMessage) Aliases() []string { return []string{"select", "select-message"} } -func (SelectMessage) Complete(aerc *widgets.Aerc, args []string) []string { +func (SelectMessage) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (SelectMessage) Execute(aerc *widgets.Aerc, args []string) error { +func (SelectMessage) Execute(aerc *app.Aerc, args []string) error { if len(args) != 2 { return errors.New("Usage: :select-message <n>") } diff --git a/commands/account/sort.go b/commands/account/sort.go index cabe10ec..8624ff12 100644 --- a/commands/account/sort.go +++ b/commands/account/sort.go @@ -4,10 +4,10 @@ import ( "errors" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/lib/sort" "git.sr.ht/~rjarry/aerc/lib/state" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -21,7 +21,7 @@ func (Sort) Aliases() []string { return []string{"sort"} } -func (Sort) Complete(aerc *widgets.Aerc, args []string) []string { +func (Sort) Complete(aerc *app.Aerc, args []string) []string { supportedCriteria := []string{ "arrival", "cc", @@ -62,7 +62,7 @@ func (Sort) Complete(aerc *widgets.Aerc, args []string) []string { return completions } -func (Sort) Execute(aerc *widgets.Aerc, args []string) error { +func (Sort) Execute(aerc *app.Aerc, args []string) error { acct := aerc.SelectedAccount() if acct == nil { return errors.New("No account selected.") diff --git a/commands/account/split.go b/commands/account/split.go index 7a5acc47..82870d60 100644 --- a/commands/account/split.go +++ b/commands/account/split.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Split struct{} @@ -18,11 +18,11 @@ func (Split) Aliases() []string { return []string{"split", "vsplit"} } -func (Split) Complete(aerc *widgets.Aerc, args []string) []string { +func (Split) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Split) Execute(aerc *widgets.Aerc, args []string) error { +func (Split) Execute(aerc *app.Aerc, args []string) error { if len(args) > 2 { return errors.New("Usage: [v]split n") } diff --git a/commands/account/view.go b/commands/account/view.go index f48d3bc3..cbf2ce3f 100644 --- a/commands/account/view.go +++ b/commands/account/view.go @@ -3,8 +3,8 @@ package account import ( "errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" ) @@ -18,11 +18,11 @@ func (ViewMessage) Aliases() []string { return []string{"view-message", "view"} } -func (ViewMessage) Complete(aerc *widgets.Aerc, args []string) []string { +func (ViewMessage) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error { +func (ViewMessage) Execute(aerc *app.Aerc, args []string) error { peek := false opts, optind, err := getopt.Getopts(args, "p") if err != nil { @@ -65,7 +65,7 @@ func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error { aerc.PushError(err.Error()) return } - viewer := widgets.NewMessageViewer(acct, view) + viewer := app.NewMessageViewer(acct, view) aerc.NewTab(viewer, msg.Envelope.Subject) }) return nil diff --git a/commands/cd.go b/commands/cd.go index 8c0191c2..67891589 100644 --- a/commands/cd.go +++ b/commands/cd.go @@ -5,8 +5,8 @@ import ( "os" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/xdg" - "git.sr.ht/~rjarry/aerc/widgets" ) var previousDir string @@ -21,7 +21,7 @@ func (ChangeDirectory) Aliases() []string { return []string{"cd"} } -func (ChangeDirectory) Complete(aerc *widgets.Aerc, args []string) []string { +func (ChangeDirectory) Complete(aerc *app.Aerc, args []string) []string { path := strings.Join(args, " ") completions := CompletePath(path) @@ -36,7 +36,7 @@ func (ChangeDirectory) Complete(aerc *widgets.Aerc, args []string) []string { return dirs } -func (ChangeDirectory) Execute(aerc *widgets.Aerc, args []string) error { +func (ChangeDirectory) Execute(aerc *app.Aerc, args []string) error { if len(args) < 1 { return errors.New("Usage: cd [directory]") } diff --git a/commands/choose.go b/commands/choose.go index 3b3af794..64535ea6 100644 --- a/commands/choose.go +++ b/commands/choose.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Choose struct{} @@ -17,21 +17,21 @@ func (Choose) Aliases() []string { return []string{"choose"} } -func (Choose) Complete(aerc *widgets.Aerc, args []string) []string { +func (Choose) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Choose) Execute(aerc *widgets.Aerc, args []string) error { +func (Choose) Execute(aerc *app.Aerc, args []string) error { if len(args) < 5 || len(args)%4 != 1 { return chooseUsage(args[0]) } - choices := []widgets.Choice{} + choices := []app.Choice{} for i := 0; i+4 < len(args); i += 4 { if args[i+1] != "-o" { return chooseUsage(args[0]) } - choices = append(choices, widgets.Choice{ + choices = append(choices, app.Choice{ Key: args[i+2], Text: args[i+3], Command: strings.Split(args[i+4], " "), diff --git a/commands/commands.go b/commands/commands.go index 9366be9c..0971d478 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -9,18 +9,18 @@ import ( "github.com/google/shlex" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib/state" "git.sr.ht/~rjarry/aerc/lib/templates" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" ) type Command interface { Aliases() []string - Execute(*widgets.Aerc, []string) error - Complete(*widgets.Aerc, []string) []string + Execute(*app.Aerc, []string) error + Complete(*app.Aerc, []string) []string } type OptionsProvider interface { @@ -30,7 +30,7 @@ type OptionsProvider interface { type OptionCompleter interface { OptionsProvider - CompleteOption(*widgets.Aerc, rune, string) []string + CompleteOption(*app.Aerc, rune, string) []string } type Commands map[string]Command @@ -81,7 +81,7 @@ type CommandSource interface { } func templateData( - aerc *widgets.Aerc, + aerc *app.Aerc, cfg *config.AccountConfig, msg *models.MessageInfo, ) models.TemplateData { @@ -112,7 +112,7 @@ func templateData( } func (cmds *Commands) ExecuteCommand( - aerc *widgets.Aerc, + aerc *app.Aerc, origArgs []string, account *config.AccountConfig, msg *models.MessageInfo, @@ -178,7 +178,7 @@ func expand(data models.TemplateData, origArgs []string) ([]string, error) { } func GetTemplateCompletion( - aerc *widgets.Aerc, cmd string, + aerc *app.Aerc, cmd string, ) ([]string, string, bool) { args, err := splitCmd(cmd) if err != nil || len(args) == 0 { @@ -231,7 +231,7 @@ func GetTemplateCompletion( // GetCompletions returns the completion options and the command prefix func (cmds *Commands) GetCompletions( - aerc *widgets.Aerc, cmd string, + aerc *app.Aerc, cmd string, ) (options []string, prefix string) { log.Tracef("completing command: %s", cmd) @@ -323,7 +323,7 @@ func (cmds *Commands) GetCompletions( return } -func GetFolders(aerc *widgets.Aerc, args []string) []string { +func GetFolders(aerc *app.Aerc, args []string) []string { acct := aerc.SelectedAccount() if acct == nil { return make([]string, 0) @@ -336,14 +336,14 @@ func GetFolders(aerc *widgets.Aerc, args []string) []string { // CompletionFromList provides a convenience wrapper for commands to use in the // Complete function. It simply matches the items provided in valid -func CompletionFromList(aerc *widgets.Aerc, valid []string, args []string) []string { +func CompletionFromList(aerc *app.Aerc, valid []string, args []string) []string { if len(args) == 0 { return valid } return FilterList(valid, args[0], "", aerc.SelectedAccountUiConfig().FuzzyComplete) } -func GetLabels(aerc *widgets.Aerc, args []string) []string { +func GetLabels(aerc *app.Aerc, args []string) []string { acct := aerc.SelectedAccount() if acct == nil { return make([]string, 0) diff --git a/commands/completion_helpers.go b/commands/completion_helpers.go index 96a423ee..c7cb780b 100644 --- a/commands/completion_helpers.go +++ b/commands/completion_helpers.go @@ -5,14 +5,14 @@ import ( "net/mail" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/completer" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" ) // GetAddress uses the address-book-cmd for address completion -func GetAddress(aerc *widgets.Aerc, search string) []string { +func GetAddress(aerc *app.Aerc, search string) []string { var options []string cmd := aerc.SelectedAccount().AccountConfig().AddressBookCmd diff --git a/commands/compose/abort.go b/commands/compose/abort.go index d6a81b57..d6ceae6d 100644 --- a/commands/compose/abort.go +++ b/commands/compose/abort.go @@ -3,7 +3,7 @@ package compose import ( "errors" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Abort struct{} @@ -16,15 +16,15 @@ func (Abort) Aliases() []string { return []string{"abort"} } -func (Abort) Complete(aerc *widgets.Aerc, args []string) []string { +func (Abort) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Abort) Execute(aerc *widgets.Aerc, args []string) error { +func (Abort) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: abort") } - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) aerc.RemoveTab(composer, true) diff --git a/commands/compose/attach-key.go b/commands/compose/attach-key.go index 208e9fd8..29237374 100644 --- a/commands/compose/attach-key.go +++ b/commands/compose/attach-key.go @@ -3,7 +3,7 @@ package compose import ( "errors" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type AttachKey struct{} @@ -16,16 +16,16 @@ func (AttachKey) Aliases() []string { return []string{"attach-key"} } -func (AttachKey) Complete(aerc *widgets.Aerc, args []string) []string { +func (AttachKey) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (AttachKey) Execute(aerc *widgets.Aerc, args []string) error { +func (AttachKey) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: attach-key") } - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) return composer.SetAttachKey(!composer.AttachKey()) } diff --git a/commands/compose/attach.go b/commands/compose/attach.go index f9ef027f..fd84b4ea 100644 --- a/commands/compose/attach.go +++ b/commands/compose/attach.go @@ -10,13 +10,13 @@ import ( "path/filepath" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/lib/xdg" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" "github.com/pkg/errors" "git.sr.ht/~sircmpwn/getopt" @@ -32,12 +32,12 @@ func (Attach) Aliases() []string { return []string{"attach"} } -func (Attach) Complete(aerc *widgets.Aerc, args []string) []string { +func (Attach) Complete(aerc *app.Aerc, args []string) []string { path := strings.Join(args, " ") return commands.CompletePath(path) } -func (a Attach) Execute(aerc *widgets.Aerc, args []string) error { +func (a Attach) Execute(aerc *app.Aerc, args []string) error { var ( menu bool read bool @@ -82,7 +82,7 @@ func (a Attach) Execute(aerc *widgets.Aerc, args []string) error { return a.addPath(aerc, strings.Join(args, " ")) } -func (a Attach) addPath(aerc *widgets.Aerc, path string) error { +func (a Attach) addPath(aerc *app.Aerc, path string) error { path = xdg.ExpandHome(path) attachments, err := filepath.Glob(path) if err != nil && errors.Is(err, filepath.ErrBadPattern) { @@ -103,7 +103,7 @@ func (a Attach) addPath(aerc *widgets.Aerc, path string) error { } } - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) for _, attach := range attachments { log.Debugf("attaching '%s'", attach) @@ -129,7 +129,7 @@ func (a Attach) addPath(aerc *widgets.Aerc, path string) error { return nil } -func (a Attach) openMenu(aerc *widgets.Aerc, args []string) error { +func (a Attach) openMenu(aerc *app.Aerc, args []string) error { filePickerCmd := config.Compose.FilePickerCmd if filePickerCmd == "" { return fmt.Errorf("no file-picker-cmd defined") @@ -157,7 +157,7 @@ func (a Attach) openMenu(aerc *widgets.Aerc, args []string) error { filepicker.ExtraFiles = append(filepicker.ExtraFiles, picks) } - t, err := widgets.NewTerminal(filepicker) + t, err := app.NewTerminal(filepicker) if err != nil { return err } @@ -200,7 +200,7 @@ func (a Attach) openMenu(aerc *widgets.Aerc, args []string) error { } } - aerc.AddDialog(widgets.NewDialog( + aerc.AddDialog(app.NewDialog( ui.NewBox(t, "File Picker", "", aerc.SelectedAccountUiConfig()), // start pos on screen func(h int) int { @@ -215,7 +215,7 @@ func (a Attach) openMenu(aerc *widgets.Aerc, args []string) error { return nil } -func (a Attach) readCommand(aerc *widgets.Aerc, name string, args []string) error { +func (a Attach) readCommand(aerc *app.Aerc, name string, args []string) error { args = append([]string{"-c"}, args...) cmd := exec.Command("sh", args...) @@ -233,7 +233,7 @@ func (a Attach) readCommand(aerc *widgets.Aerc, name string, args []string) erro mimeParams["name"] = name - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) err = composer.AddPartAttachment(name, mimeType, mimeParams, reader) if err != nil { return errors.Wrap(err, "AddPartAttachment") diff --git a/commands/compose/cc-bcc.go b/commands/compose/cc-bcc.go index 045f9092..8f8d4aac 100644 --- a/commands/compose/cc-bcc.go +++ b/commands/compose/cc-bcc.go @@ -3,7 +3,7 @@ package compose import ( "strings" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type CC struct{} @@ -16,16 +16,16 @@ func (CC) Aliases() []string { return []string{"cc", "bcc"} } -func (CC) Complete(aerc *widgets.Aerc, args []string) []string { +func (CC) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (CC) Execute(aerc *widgets.Aerc, args []string) error { +func (CC) Execute(aerc *app.Aerc, args []string) error { var addrs string if len(args) > 1 { addrs = strings.Join(args[1:], " ") } - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) switch args[0] { case "cc": diff --git a/commands/compose/detach.go b/commands/compose/detach.go index 487bf225..014301f2 100644 --- a/commands/compose/detach.go +++ b/commands/compose/detach.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Detach struct{} @@ -17,14 +17,14 @@ func (Detach) Aliases() []string { return []string{"detach"} } -func (Detach) Complete(aerc *widgets.Aerc, args []string) []string { - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) +func (Detach) Complete(aerc *app.Aerc, args []string) []string { + composer, _ := aerc.SelectedTabContent().(*app.Composer) return composer.GetAttachments() } -func (Detach) Execute(aerc *widgets.Aerc, args []string) error { +func (Detach) Execute(aerc *app.Aerc, args []string) error { var path string - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) if len(args) > 1 { path = strings.Join(args[1:], " ") diff --git a/commands/compose/edit.go b/commands/compose/edit.go index 1e8e0672..485b3098 100644 --- a/commands/compose/edit.go +++ b/commands/compose/edit.go @@ -3,8 +3,8 @@ package compose import ( "errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/config" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" ) @@ -18,12 +18,12 @@ func (Edit) Aliases() []string { return []string{"edit"} } -func (Edit) Complete(aerc *widgets.Aerc, args []string) []string { +func (Edit) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Edit) Execute(aerc *widgets.Aerc, args []string) error { - composer, ok := aerc.SelectedTabContent().(*widgets.Composer) +func (Edit) Execute(aerc *app.Aerc, args []string) error { + composer, ok := aerc.SelectedTabContent().(*app.Composer) if !ok { return errors.New("only valid while composing") } diff --git a/commands/compose/encrypt.go b/commands/compose/encrypt.go index 905bdc4b..3c852dc4 100644 --- a/commands/compose/encrypt.go +++ b/commands/compose/encrypt.go @@ -3,7 +3,7 @@ package compose import ( "errors" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Encrypt struct{} @@ -16,16 +16,16 @@ func (Encrypt) Aliases() []string { return []string{"encrypt"} } -func (Encrypt) Complete(aerc *widgets.Aerc, args []string) []string { +func (Encrypt) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Encrypt) Execute(aerc *widgets.Aerc, args []string) error { +func (Encrypt) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: encrypt") } - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) composer.SetEncrypt(!composer.Encrypt()) return nil diff --git a/commands/compose/header.go b/commands/compose/header.go index 59d01952..e66df149 100644 --- a/commands/compose/header.go +++ b/commands/compose/header.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" ) @@ -33,11 +33,11 @@ func (Header) Options() string { return "fd" } -func (Header) Complete(aerc *widgets.Aerc, args []string) []string { +func (Header) Complete(aerc *app.Aerc, args []string) []string { return commands.CompletionFromList(aerc, headers, args) } -func (h Header) Execute(aerc *widgets.Aerc, args []string) error { +func (h Header) Execute(aerc *app.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, h.Options()) args = args[optind:] if err == nil && len(args) < 1 { @@ -58,7 +58,7 @@ func (h Header) Execute(aerc *widgets.Aerc, args []string) error { } } - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) name := strings.TrimRight(args[0], ":") diff --git a/commands/compose/multipart.go b/commands/compose/multipart.go index 32801965..13ee69e5 100644 --- a/commands/compose/multipart.go +++ b/commands/compose/multipart.go @@ -4,9 +4,9 @@ import ( "bytes" "fmt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/config" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" ) @@ -20,7 +20,7 @@ func (Multipart) Aliases() []string { return []string{"multipart"} } -func (Multipart) Complete(aerc *widgets.Aerc, args []string) []string { +func (Multipart) Complete(aerc *app.Aerc, args []string) []string { var completions []string completions = append(completions, "-d") for mime := range config.Converters { @@ -29,8 +29,8 @@ func (Multipart) Complete(aerc *widgets.Aerc, args []string) []string { return commands.CompletionFromList(aerc, completions, args) } -func (a Multipart) Execute(aerc *widgets.Aerc, args []string) error { - composer, ok := aerc.SelectedTabContent().(*widgets.Composer) +func (a Multipart) Execute(aerc *app.Aerc, args []string) error { + composer, ok := aerc.SelectedTabContent().(*app.Composer) if !ok { return fmt.Errorf(":multipart is only available on the compose::review screen") } diff --git a/commands/compose/next-field.go b/commands/compose/next-field.go index ec4db582..d029b50a 100644 --- a/commands/compose/next-field.go +++ b/commands/compose/next-field.go @@ -3,7 +3,7 @@ package compose import ( "fmt" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type NextPrevField struct{} @@ -16,15 +16,15 @@ func (NextPrevField) Aliases() []string { return []string{"next-field", "prev-field"} } -func (NextPrevField) Complete(aerc *widgets.Aerc, args []string) []string { +func (NextPrevField) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (NextPrevField) Execute(aerc *widgets.Aerc, args []string) error { +func (NextPrevField) Execute(aerc *app.Aerc, args []string) error { if len(args) > 2 { return nextPrevFieldUsage(args[0]) } - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) if args[0] == "prev-field" { composer.PrevField() } else { diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go index fd59cc11..e33c9ab7 100644 --- a/commands/compose/postpone.go +++ b/commands/compose/postpone.go @@ -8,10 +8,10 @@ import ( "git.sr.ht/~sircmpwn/getopt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -29,7 +29,7 @@ func (Postpone) Options() string { return "t:" } -func (Postpone) CompleteOption(aerc *widgets.Aerc, r rune, arg string) []string { +func (Postpone) CompleteOption(aerc *app.Aerc, r rune, arg string) []string { var valid []string if r == 't' { valid = commands.GetFolders(aerc, []string{arg}) @@ -37,11 +37,11 @@ func (Postpone) CompleteOption(aerc *widgets.Aerc, r rune, arg string) []string return commands.CompletionFromList(aerc, valid, []string{arg}) } -func (Postpone) Complete(aerc *widgets.Aerc, args []string) []string { +func (Postpone) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (p Postpone) Execute(aerc *widgets.Aerc, args []string) error { +func (p Postpone) Execute(aerc *app.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, p.Options()) if err != nil { return err @@ -55,7 +55,7 @@ func (p Postpone) Execute(aerc *widgets.Aerc, args []string) error { if tab == nil { return errors.New("No tab selected") } - composer, _ := tab.Content.(*widgets.Composer) + composer, _ := tab.Content.(*app.Composer) config := composer.Config() tabName := tab.Name diff --git a/commands/compose/send.go b/commands/compose/send.go index e53b01a3..c9b843a7 100644 --- a/commands/compose/send.go +++ b/commands/compose/send.go @@ -16,11 +16,11 @@ import ( "github.com/google/shlex" "github.com/pkg/errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands/mode" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" "github.com/emersion/go-message/mail" "golang.org/x/oauth2" @@ -36,11 +36,11 @@ func (Send) Aliases() []string { return []string{"send"} } -func (Send) Complete(aerc *widgets.Aerc, args []string) []string { +func (Send) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Send) Execute(aerc *widgets.Aerc, args []string) error { +func (Send) Execute(aerc *app.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, "a:") if err != nil { return err @@ -58,7 +58,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error { if tab == nil { return errors.New("No selected tab") } - composer, _ := tab.Content.(*widgets.Composer) + composer, _ := tab.Content.(*app.Composer) tabName := tab.Name config := composer.Config() @@ -125,7 +125,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error { msg = "You may have forgotten an attachment." } - prompt := widgets.NewPrompt( + prompt := app.NewPrompt( msg+" Abort send? [Y/n] ", func(text string) { if text == "n" || text == "N" { @@ -148,7 +148,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error { return nil } -func send(aerc *widgets.Aerc, composer *widgets.Composer, ctx sendCtx, +func send(aerc *app.Aerc, composer *app.Composer, ctx sendCtx, header *mail.Header, tabName string, archive string, ) { // we don't want to block the UI thread while we are sending @@ -518,7 +518,7 @@ func connectSmtps(host string) (*smtp.Client, error) { } func newJmapSender( - composer *widgets.Composer, header *mail.Header, ctx sendCtx, + composer *app.Composer, header *mail.Header, ctx sendCtx, ) (io.WriteCloser, error) { var writer io.WriteCloser done := make(chan error) diff --git a/commands/compose/sign.go b/commands/compose/sign.go index e6afd98e..f44c33ec 100644 --- a/commands/compose/sign.go +++ b/commands/compose/sign.go @@ -4,7 +4,7 @@ import ( "errors" "time" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Sign struct{} @@ -17,16 +17,16 @@ func (Sign) Aliases() []string { return []string{"sign"} } -func (Sign) Complete(aerc *widgets.Aerc, args []string) []string { +func (Sign) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Sign) Execute(aerc *widgets.Aerc, args []string) error { +func (Sign) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: sign") } - composer, _ := aerc.SelectedTabContent().(*widgets.Composer) + composer, _ := aerc.SelectedTabContent().(*app.Composer) err := composer.SetSign(!composer.Sign()) if err != nil { diff --git a/commands/compose/switch.go b/commands/compose/switch.go index 2b6aadb5..f442d6b0 100644 --- a/commands/compose/switch.go +++ b/commands/compose/switch.go @@ -4,12 +4,12 @@ import ( "errors" "fmt" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~sircmpwn/getopt" ) type AccountSwitcher interface { - SwitchAccount(*widgets.AccountView) error + SwitchAccount(*app.AccountView) error } type SwitchAccount struct{} @@ -22,11 +22,11 @@ func (SwitchAccount) Aliases() []string { return []string{"switch-account"} } -func (SwitchAccount) Complete(aerc *widgets.Aerc, args []string) []string { +func (SwitchAccount) Complete(aerc *app.Aerc, args []string) []string { return aerc.AccountNames() } -func (SwitchAccount) Execute(aerc *widgets.Aerc, args []string) error { +func (SwitchAccount) Execute(aerc *app.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, "np") if err != nil { return err @@ -57,7 +57,7 @@ func (SwitchAccount) Execute(aerc *widgets.Aerc, args []string) error { return errors.New("this tab cannot switch accounts") } - var acct *widgets.AccountView + var acct *app.AccountView switch { case prev: diff --git a/commands/ct.go b/commands/ct.go index 3bd3428e..e6b29b58 100644 --- a/commands/ct.go +++ b/commands/ct.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type ChangeTab struct{} @@ -19,7 +19,7 @@ func (ChangeTab) Aliases() []string { return []string{"ct", "change-tab"} } -func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string { +func (ChangeTab) Complete(aerc *app.Aerc, args []string) []string { if len(args) == 0 { return aerc.TabNames() } @@ -27,7 +27,7 @@ func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string { return FilterList(aerc.TabNames(), joinedArgs, "", aerc.SelectedAccountUiConfig().FuzzyComplete) } -func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error { +func (ChangeTab) Execute(aerc *app.Aerc, args []string) error { if len(args) == 1 { return fmt.Errorf("Usage: %s <tab>", args[0]) } diff --git a/commands/eml.go b/commands/eml.go index 00380763..81e578d3 100644 --- a/commands/eml.go +++ b/commands/eml.go @@ -7,8 +7,8 @@ import ( "os" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib" - "git.sr.ht/~rjarry/aerc/widgets" ) type Eml struct{} @@ -21,11 +21,11 @@ func (Eml) Aliases() []string { return []string{"eml", "preview"} } -func (Eml) Complete(aerc *widgets.Aerc, args []string) []string { +func (Eml) Complete(aerc *app.Aerc, args []string) []string { return CompletePath(strings.Join(args, " ")) } -func (Eml) Execute(aerc *widgets.Aerc, args []string) error { +func (Eml) Execute(aerc *app.Aerc, args []string) error { acct := aerc.SelectedAccount() if acct == nil { return fmt.Errorf("no account selected") @@ -43,7 +43,7 @@ func (Eml) Execute(aerc *widgets.Aerc, args []string) error { aerc.PushError(err.Error()) return } - msgView := widgets.NewMessageViewer(acct, view) + msgView := app.NewMessageViewer(acct, view) aerc.NewTab(msgView, view.MessageInfo().Envelope.Subject) }) @@ -51,10 +51,10 @@ func (Eml) Execute(aerc *widgets.Aerc, args []string) error { if len(args) == 1 { switch tab := aerc.SelectedTabContent().(type) { - case *widgets.MessageViewer: + case *app.MessageViewer: part := tab.SelectedMessagePart() tab.MessageView().FetchBodyPart(part.Index, showEml) - case *widgets.Composer: + case *app.Composer: var buf bytes.Buffer h, err := tab.PrepareHeader() if err != nil { diff --git a/commands/exec.go b/commands/exec.go index 37274116..a38c8789 100644 --- a/commands/exec.go +++ b/commands/exec.go @@ -7,8 +7,8 @@ import ( "os/exec" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" ) type ExecCmd struct{} @@ -21,11 +21,11 @@ func (ExecCmd) Aliases() []string { return []string{"exec"} } -func (ExecCmd) Complete(aerc *widgets.Aerc, args []string) []string { +func (ExecCmd) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (ExecCmd) Execute(aerc *widgets.Aerc, args []string) error { +func (ExecCmd) Execute(aerc *app.Aerc, args []string) error { if len(args) < 2 { return errors.New("Usage: exec [cmd...]") } @@ -34,10 +34,10 @@ func (ExecCmd) Execute(aerc *widgets.Aerc, args []string) error { env := os.Environ() switch view := aerc.SelectedTabContent().(type) { - case *widgets.AccountView: + case *app.AccountView: env = append(env, fmt.Sprintf("account=%s", view.AccountConfig().Name)) env = append(env, fmt.Sprintf("folder=%s", view.Directories().Selected())) - case *widgets.MessageViewer: + case *app.MessageViewer: acct := view.SelectedAccount() env = append(env, fmt.Sprintf("account=%s", acct.AccountConfig().Name)) env = append(env, fmt.Sprintf("folder=%s", acct.Directories().Selected())) diff --git a/commands/help.go b/commands/help.go index b2654ab5..312c3318 100644 --- a/commands/help.go +++ b/commands/help.go @@ -3,7 +3,7 @@ package commands import ( "errors" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Help struct{} @@ -33,11 +33,11 @@ func (Help) Aliases() []string { return []string{"help"} } -func (Help) Complete(aerc *widgets.Aerc, args []string) []string { +func (Help) Complete(aerc *app.Aerc, args []string) []string { return CompletionFromList(aerc, pages, args) } -func (Help) Execute(aerc *widgets.Aerc, args []string) error { +func (Help) Execute(aerc *app.Aerc, args []string) error { page := "aerc" if len(args) == 2 && args[1] != "aerc" { page = "aerc-" + args[1] @@ -46,8 +46,8 @@ func (Help) Execute(aerc *widgets.Aerc, args []string) error { } if page == "aerc-keys" { - aerc.AddDialog(widgets.NewDialog( - widgets.NewListBox( + aerc.AddDialog(app.NewDialog( + app.NewListBox( "Bindings: Press <Esc> or <Enter> to close. "+ "Start typing to filter bindings.", aerc.HumanReadableBindings(), diff --git a/commands/move-tab.go b/commands/move-tab.go index 76e5348d..d85f3b2f 100644 --- a/commands/move-tab.go +++ b/commands/move-tab.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type MoveTab struct{} @@ -18,11 +18,11 @@ func (MoveTab) Aliases() []string { return []string{"move-tab"} } -func (MoveTab) Complete(aerc *widgets.Aerc, args []string) []string { +func (MoveTab) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (MoveTab) Execute(aerc *widgets.Aerc, args []string) error { +func (MoveTab) Execute(aerc *app.Aerc, args []string) error { if len(args) == 1 { return fmt.Errorf("Usage: %s [+|-]<index>", args[0]) } diff --git a/commands/msg/archive.go b/commands/msg/archive.go index 1c9d7929..9753f664 100644 --- a/commands/msg/archive.go +++ b/commands/msg/archive.go @@ -6,10 +6,10 @@ import ( "strings" "sync" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -29,12 +29,12 @@ func (Archive) Aliases() []string { return []string{"archive"} } -func (Archive) Complete(aerc *widgets.Aerc, args []string) []string { +func (Archive) Complete(aerc *app.Aerc, args []string) []string { valid := []string{"flat", "year", "month"} return commands.CompletionFromList(aerc, valid, args) } -func (Archive) Execute(aerc *widgets.Aerc, args []string) error { +func (Archive) Execute(aerc *app.Aerc, args []string) error { if len(args) != 2 { return errors.New("Usage: archive <flat|year|month>") } @@ -47,7 +47,7 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error { return err } -func archive(aerc *widgets.Aerc, msgs []*models.MessageInfo, archiveType string) error { +func archive(aerc *app.Aerc, msgs []*models.MessageInfo, archiveType string) error { h := newHelper(aerc) acct, err := h.account() if err != nil { diff --git a/commands/msg/copy.go b/commands/msg/copy.go index 7118e4f8..3f3498a2 100644 --- a/commands/msg/copy.go +++ b/commands/msg/copy.go @@ -7,8 +7,8 @@ import ( "git.sr.ht/~sircmpwn/getopt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -22,11 +22,11 @@ func (Copy) Aliases() []string { return []string{"cp", "copy"} } -func (Copy) Complete(aerc *widgets.Aerc, args []string) []string { +func (Copy) Complete(aerc *app.Aerc, args []string) []string { return commands.GetFolders(aerc, args) } -func (Copy) Execute(aerc *widgets.Aerc, args []string) error { +func (Copy) Execute(aerc *app.Aerc, args []string) error { if len(args) == 1 { return errors.New("Usage: cp [-p] <folder>") } diff --git a/commands/msg/delete.go b/commands/msg/delete.go index 6d3fb4a3..37103da3 100644 --- a/commands/msg/delete.go +++ b/commands/msg/delete.go @@ -4,11 +4,11 @@ import ( "errors" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -22,11 +22,11 @@ func (Delete) Aliases() []string { return []string{"delete", "delete-message"} } -func (Delete) Complete(aerc *widgets.Aerc, args []string) []string { +func (Delete) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Delete) Execute(aerc *widgets.Aerc, args []string) error { +func (Delete) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: :delete") } @@ -53,7 +53,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error { switch msg := msg.(type) { case *types.Done: aerc.PushStatus("Messages deleted.", 10*time.Second) - mv, isMsgView := h.msgProvider.(*widgets.MessageViewer) + mv, isMsgView := h.msgProvider.(*app.MessageViewer) if isMsgView { if !config.Ui.NextMessageOnDelete { aerc.RemoveTab(h.msgProvider, true) @@ -72,7 +72,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error { aerc.PushError(err.Error()) return } - nextMv := widgets.NewMessageViewer(acct, view) + nextMv := app.NewMessageViewer(acct, view) aerc.ReplaceTab(mv, nextMv, next.Envelope.Subject, true) }) } diff --git a/commands/msg/envelope.go b/commands/msg/envelope.go index 1b16d16f..f5e50358 100644 --- a/commands/msg/envelope.go +++ b/commands/msg/envelope.go @@ -5,10 +5,10 @@ import ( "fmt" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/format" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" "github.com/emersion/go-message/mail" ) @@ -23,11 +23,11 @@ func (Envelope) Aliases() []string { return []string{"envelope"} } -func (Envelope) Complete(aerc *widgets.Aerc, args []string) []string { +func (Envelope) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Envelope) Execute(aerc *widgets.Aerc, args []string) error { +func (Envelope) Execute(aerc *app.Aerc, args []string) error { header := false fmtStr := "%-20.20s: %s" opts, _, err := getopt.Getopts(args, "hs:") @@ -65,8 +65,8 @@ func (Envelope) Execute(aerc *widgets.Aerc, args []string) error { } n := len(list) - aerc.AddDialog(widgets.NewDialog( - widgets.NewListBox( + aerc.AddDialog(app.NewDialog( + app.NewListBox( "Message Envelope. Press <Esc> or <Enter> to close. "+ "Start typing to filter.", list, diff --git a/commands/msg/fold.go b/commands/msg/fold.go index 14d00f17..755a292f 100644 --- a/commands/msg/fold.go +++ b/commands/msg/fold.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/ui" - "git.sr.ht/~rjarry/aerc/widgets" ) type Fold struct{} @@ -19,11 +19,11 @@ func (Fold) Aliases() []string { return []string{"fold", "unfold"} } -func (Fold) Complete(aerc *widgets.Aerc, args []string) []string { +func (Fold) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Fold) Execute(aerc *widgets.Aerc, args []string) error { +func (Fold) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return fmt.Errorf("Usage: %s", args[0]) } diff --git a/commands/msg/forward.go b/commands/msg/forward.go index 86c52059..d1abbc5b 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -12,12 +12,12 @@ import ( "strings" "sync" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/format" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" "github.com/emersion/go-message/mail" @@ -34,11 +34,11 @@ func (forward) Aliases() []string { return []string{"forward"} } -func (forward) Complete(aerc *widgets.Aerc, args []string) []string { +func (forward) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (forward) Execute(aerc *widgets.Aerc, args []string) error { +func (forward) Execute(aerc *app.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, "AFT:eE") if err != nil { return err @@ -69,7 +69,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { return errors.New("Options -A and -F are mutually exclusive") } - widget := aerc.SelectedTabContent().(widgets.ProvidesMessage) + widget := aerc.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -106,8 +106,8 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { RFC822Headers: msg.RFC822Headers, } - addTab := func() (*widgets.Composer, error) { - composer, err := widgets.NewComposer(aerc, acct, + addTab := func() (*app.Composer, error) { + composer, err := app.NewComposer(aerc, acct, acct.AccountConfig(), acct.Worker(), editHeaders, template, h, &original, nil) if err != nil { @@ -153,7 +153,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { return } composer.AddAttachment(tmpFileName) - composer.OnClose(func(_ *widgets.Composer) { + composer.OnClose(func(_ *app.Composer) { os.RemoveAll(tmpDir) }) }) diff --git a/commands/msg/invite.go b/commands/msg/invite.go index 309fe643..ceb043bb 100644 --- a/commands/msg/invite.go +++ b/commands/msg/invite.go @@ -5,13 +5,13 @@ import ( "fmt" "io" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/calendar" "git.sr.ht/~rjarry/aerc/lib/format" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" "github.com/emersion/go-message/mail" ) @@ -26,11 +26,11 @@ func (invite) Aliases() []string { return []string{"accept", "accept-tentative", "decline"} } -func (invite) Complete(aerc *widgets.Aerc, args []string) []string { +func (invite) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (invite) Execute(aerc *widgets.Aerc, args []string) error { +func (invite) Execute(aerc *app.Aerc, args []string) error { acct := aerc.SelectedAccount() if acct == nil { return errors.New("no account selected") @@ -155,7 +155,7 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error { } addTab := func(cr *calendar.Reply) error { - composer, err := widgets.NewComposer(aerc, acct, + composer, err := app.NewComposer(aerc, acct, acct.AccountConfig(), acct.Worker(), editHeaders, "", h, &original, cr.PlainText) if err != nil { @@ -170,7 +170,7 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error { composer.Tab = aerc.NewTab(composer, subject) - composer.OnClose(func(c *widgets.Composer) { + composer.OnClose(func(c *app.Composer) { if c.Sent() { store.Answered([]uint32{msg.Uid}, true, nil) } diff --git a/commands/msg/mark.go b/commands/msg/mark.go index 51aa1eb4..27677609 100644 --- a/commands/msg/mark.go +++ b/commands/msg/mark.go @@ -3,7 +3,7 @@ package msg import ( "fmt" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~sircmpwn/getopt" ) @@ -17,11 +17,11 @@ func (Mark) Aliases() []string { return []string{"mark", "unmark", "remark"} } -func (Mark) Complete(aerc *widgets.Aerc, args []string) []string { +func (Mark) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Mark) Execute(aerc *widgets.Aerc, args []string) error { +func (Mark) Execute(aerc *app.Aerc, args []string) error { h := newHelper(aerc) OnSelectedMessage := func(fn func(uint32)) error { if fn == nil { diff --git a/commands/msg/modify-labels.go b/commands/msg/modify-labels.go index 02eed520..d61dc23b 100644 --- a/commands/msg/modify-labels.go +++ b/commands/msg/modify-labels.go @@ -4,8 +4,8 @@ import ( "errors" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -19,11 +19,11 @@ func (ModifyLabels) Aliases() []string { return []string{"modify-labels", "tag"} } -func (ModifyLabels) Complete(aerc *widgets.Aerc, args []string) []string { +func (ModifyLabels) Complete(aerc *app.Aerc, args []string) []string { return commands.GetLabels(aerc, args) } -func (ModifyLabels) Execute(aerc *widgets.Aerc, args []string) error { +func (ModifyLabels) Execute(aerc *app.Aerc, args []string) error { changes := args[1:] if len(changes) == 0 { return errors.New("Usage: modify-labels <[+-]label> ...") diff --git a/commands/msg/move.go b/commands/msg/move.go index e8661a61..847fa549 100644 --- a/commands/msg/move.go +++ b/commands/msg/move.go @@ -5,12 +5,12 @@ import ( "strings" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" "git.sr.ht/~sircmpwn/getopt" ) @@ -25,11 +25,11 @@ func (Move) Aliases() []string { return []string{"mv", "move"} } -func (Move) Complete(aerc *widgets.Aerc, args []string) []string { +func (Move) Complete(aerc *app.Aerc, args []string) []string { return commands.GetFolders(aerc, args) } -func (Move) Execute(aerc *widgets.Aerc, args []string) error { +func (Move) Execute(aerc *app.Aerc, args []string) error { if len(args) == 1 { return errors.New("Usage: mv [-p] <folder>") } @@ -82,15 +82,15 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error { } func handleDone( - aerc *widgets.Aerc, - acct *widgets.AccountView, + aerc *app.Aerc, + acct *app.AccountView, next *models.MessageInfo, message string, store *lib.MessageStore, ) { h := newHelper(aerc) aerc.PushStatus(message, 10*time.Second) - mv, isMsgView := h.msgProvider.(*widgets.MessageViewer) + mv, isMsgView := h.msgProvider.(*app.MessageViewer) switch { case isMsgView && !config.Ui.NextMessageOnDelete: aerc.RemoveTab(h.msgProvider, true) @@ -108,7 +108,7 @@ func handleDone( aerc.PushError(err.Error()) return } - nextMv := widgets.NewMessageViewer(acct, view) + nextMv := app.NewMessageViewer(acct, view) aerc.ReplaceTab(mv, nextMv, next.Envelope.Subject, true) }) default: diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go index fc1ac8f8..e8c1e277 100644 --- a/commands/msg/pipe.go +++ b/commands/msg/pipe.go @@ -9,9 +9,9 @@ import ( "sort" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" mboxer "git.sr.ht/~rjarry/aerc/worker/mbox" "git.sr.ht/~rjarry/aerc/worker/types" @@ -28,11 +28,11 @@ func (Pipe) Aliases() []string { return []string{"pipe"} } -func (Pipe) Complete(aerc *widgets.Aerc, args []string) []string { +func (Pipe) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Pipe) Execute(aerc *widgets.Aerc, args []string) error { +func (Pipe) Execute(aerc *app.Aerc, args []string) error { var ( background bool pipeFull bool @@ -64,11 +64,11 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error { return errors.New("Usage: pipe [-mp] <cmd> [args...]") } - provider := aerc.SelectedTabContent().(widgets.ProvidesMessage) + provider := aerc.SelectedTabContent().(app.ProvidesMessage) if !pipeFull && !pipePart { - if _, ok := provider.(*widgets.MessageViewer); ok { + if _, ok := provider.(*app.MessageViewer); ok { pipePart = true - } else if _, ok := provider.(*widgets.AccountView); ok { + } else if _, ok := provider.(*app.AccountView); ok { pipeFull = true } else { return errors.New( @@ -123,7 +123,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error { h := newHelper(aerc) store, err := h.store() if err != nil { - if mv, ok := provider.(*widgets.MessageViewer); ok { + if mv, ok := provider.(*app.MessageViewer); ok { mv.MessageView().FetchFull(func(reader io.Reader) { if background { doExec(reader) @@ -209,7 +209,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error { } }() } else if pipePart { - mv, ok := provider.(*widgets.MessageViewer) + mv, ok := provider.(*app.MessageViewer) if !ok { return fmt.Errorf("can only pipe message part from a message view") } diff --git a/commands/msg/read.go b/commands/msg/read.go index cffd2218..10a874e3 100644 --- a/commands/msg/read.go +++ b/commands/msg/read.go @@ -6,8 +6,8 @@ import ( "git.sr.ht/~sircmpwn/getopt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -21,7 +21,7 @@ func (FlagMsg) Aliases() []string { return []string{"flag", "unflag", "read", "unread"} } -func (FlagMsg) Complete(aerc *widgets.Aerc, args []string) []string { +func (FlagMsg) Complete(aerc *app.Aerc, args []string) []string { return nil } @@ -32,7 +32,7 @@ func (FlagMsg) Complete(aerc *widgets.Aerc, args []string) []string { // // If this was called as 'read' or 'unread', it has the same effect as // 'flag' or 'unflag', respectively, but the 'Seen' flag is affected. -func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error { +func (FlagMsg) Execute(aerc *app.Aerc, args []string) error { // The flag to change var flag models.Flags // User-readable name of the flag to change diff --git a/commands/msg/recall.go b/commands/msg/recall.go index e7579ca1..4a08df29 100644 --- a/commands/msg/recall.go +++ b/commands/msg/recall.go @@ -10,10 +10,10 @@ import ( _ "github.com/emersion/go-message/charset" "github.com/pkg/errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" "git.sr.ht/~sircmpwn/getopt" ) @@ -28,11 +28,11 @@ func (Recall) Aliases() []string { return []string{"recall"} } -func (Recall) Complete(aerc *widgets.Aerc, args []string) []string { +func (Recall) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Recall) Execute(aerc *widgets.Aerc, args []string) error { +func (Recall) Execute(aerc *app.Aerc, args []string) error { force := false editHeaders := config.Compose.EditHeaders @@ -54,7 +54,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { return errors.New("Usage: recall [-f] [-e|-E]") } - widget := aerc.SelectedTabContent().(widgets.ProvidesMessage) + widget := aerc.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -74,13 +74,13 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { } log.Debugf("Recalling message <%s>", msgInfo.Envelope.MessageId) - addTab := func(composer *widgets.Composer) { + addTab := func(composer *app.Composer) { subject := msgInfo.Envelope.Subject if subject == "" { subject = "Recalled email" } composer.Tab = aerc.NewTab(composer, subject) - composer.OnClose(func(composer *widgets.Composer) { + composer.OnClose(func(composer *app.Composer) { worker := composer.Worker() uids := []uint32{msgInfo.Uid} @@ -116,7 +116,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { } msg.FetchBodyPart(path, func(reader io.Reader) { - composer, err := widgets.NewComposer(aerc, acct, + composer, err := app.NewComposer(aerc, acct, acct.AccountConfig(), acct.Worker(), editHeaders, "", msgInfo.RFC822Headers, nil, reader) if err != nil { diff --git a/commands/msg/reply.go b/commands/msg/reply.go index b2a61a80..035e6aa3 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -11,6 +11,7 @@ import ( "git.sr.ht/~sircmpwn/getopt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands/account" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" @@ -19,7 +20,6 @@ import ( "git.sr.ht/~rjarry/aerc/lib/parse" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "github.com/emersion/go-message/mail" ) @@ -33,11 +33,11 @@ func (reply) Aliases() []string { return []string{"reply"} } -func (reply) Complete(aerc *widgets.Aerc, args []string) []string { +func (reply) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (reply) Execute(aerc *widgets.Aerc, args []string) error { +func (reply) Execute(aerc *app.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, "acqT:eE") if err != nil { return err @@ -69,7 +69,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { } } - widget := aerc.SelectedTabContent().(widgets.ProvidesMessage) + widget := aerc.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { @@ -177,9 +177,9 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { RFC822Headers: msg.RFC822Headers, } - mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer) + mv, _ := aerc.SelectedTabContent().(*app.MessageViewer) addTab := func() error { - composer, err := widgets.NewComposer(aerc, acct, + composer, err := app.NewComposer(aerc, acct, acct.AccountConfig(), acct.Worker(), editHeaders, template, h, &original, nil) if err != nil { @@ -196,7 +196,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { composer.Tab = aerc.NewTab(composer, subject) - composer.OnClose(func(c *widgets.Composer) { + composer.OnClose(func(c *app.Composer) { switch { case c.Sent() && c.Archive() != "": store.Answered([]uint32{msg.Uid}, true, nil) @@ -221,8 +221,8 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { } if crypto.IsEncrypted(msg.BodyStructure) { - provider := aerc.SelectedTabContent().(widgets.ProvidesMessage) - mv, ok := provider.(*widgets.MessageViewer) + provider := aerc.SelectedTabContent().(app.ProvidesMessage) + mv, ok := provider.(*app.MessageViewer) if !ok { return fmt.Errorf("message is encrypted. can only quote reply while message is open") } diff --git a/commands/msg/toggle-thread-context.go b/commands/msg/toggle-thread-context.go index 09c60b85..6f8b7bbb 100644 --- a/commands/msg/toggle-thread-context.go +++ b/commands/msg/toggle-thread-context.go @@ -3,8 +3,8 @@ package msg import ( "errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/ui" - "git.sr.ht/~rjarry/aerc/widgets" ) type ToggleThreadContext struct{} @@ -17,11 +17,11 @@ func (ToggleThreadContext) Aliases() []string { return []string{"toggle-thread-context"} } -func (ToggleThreadContext) Complete(aerc *widgets.Aerc, args []string) []string { +func (ToggleThreadContext) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (ToggleThreadContext) Execute(aerc *widgets.Aerc, args []string) error { +func (ToggleThreadContext) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: toggle-entire-thread") } diff --git a/commands/msg/toggle-threads.go b/commands/msg/toggle-threads.go index 9508da50..0b85e510 100644 --- a/commands/msg/toggle-threads.go +++ b/commands/msg/toggle-threads.go @@ -3,9 +3,9 @@ package msg import ( "errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/state" "git.sr.ht/~rjarry/aerc/lib/ui" - "git.sr.ht/~rjarry/aerc/widgets" ) type ToggleThreads struct{} @@ -18,11 +18,11 @@ func (ToggleThreads) Aliases() []string { return []string{"toggle-threads"} } -func (ToggleThreads) Complete(aerc *widgets.Aerc, args []string) []string { +func (ToggleThreads) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (ToggleThreads) Execute(aerc *widgets.Aerc, args []string) error { +func (ToggleThreads) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: toggle-threads") } diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go index 505392d4..23029244 100644 --- a/commands/msg/unsubscribe.go +++ b/commands/msg/unsubscribe.go @@ -8,10 +8,10 @@ import ( "strings" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" "github.com/emersion/go-message/mail" ) @@ -30,12 +30,12 @@ func (Unsubscribe) Aliases() []string { } // Complete returns a list of completions -func (Unsubscribe) Complete(aerc *widgets.Aerc, args []string) []string { +func (Unsubscribe) Complete(aerc *app.Aerc, args []string) []string { return nil } // Execute runs the Unsubscribe command -func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error { +func (Unsubscribe) Execute(aerc *app.Aerc, args []string) error { editHeaders := config.Compose.EditHeaders opts, optind, err := getopt.Getopts(args, "eE") if err != nil { @@ -52,7 +52,7 @@ func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error { editHeaders = false } } - widget := aerc.SelectedTabContent().(widgets.ProvidesMessage) + widget := aerc.SelectedTabContent().(app.ProvidesMessage) msg, err := widget.SelectedMessage() if err != nil { return err @@ -97,14 +97,14 @@ func (Unsubscribe) Execute(aerc *widgets.Aerc, args []string) error { options[i] = method.Scheme } - dialog := widgets.NewSelectorDialog( + dialog := app.NewSelectorDialog( title, "Press <Enter> to confirm or <ESC> to cancel", options, 0, aerc.SelectedAccountUiConfig(), func(option string, err error) { aerc.CloseDialog() if err != nil { - if errors.Is(err, widgets.ErrNoOptionSelected) { + if errors.Is(err, app.ErrNoOptionSelected) { aerc.PushStatus("Unsubscribe: "+err.Error(), 5*time.Second) } else { @@ -148,8 +148,8 @@ func parseUnsubscribeMethods(header string) (methods []*url.URL) { } } -func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL, editHeaders bool) error { - widget := aerc.SelectedTabContent().(widgets.ProvidesMessage) +func unsubscribeMailto(aerc *app.Aerc, u *url.URL, editHeaders bool) error { + widget := aerc.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -161,7 +161,7 @@ func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL, editHeaders bool) error { h.SetAddressList("to", to) } - composer, err := widgets.NewComposer( + composer, err := app.NewComposer( aerc, acct, acct.AccountConfig(), @@ -180,8 +180,8 @@ func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL, editHeaders bool) error { return nil } -func unsubscribeHTTP(aerc *widgets.Aerc, u *url.URL) error { - confirm := widgets.NewSelectorDialog( +func unsubscribeHTTP(aerc *app.Aerc, u *url.URL) error { + confirm := app.NewSelectorDialog( "Do you want to open this link?", u.String(), []string{"No", "Yes"}, 0, aerc.SelectedAccountUiConfig(), diff --git a/commands/msg/utils.go b/commands/msg/utils.go index 8210cae1..423be37d 100644 --- a/commands/msg/utils.go +++ b/commands/msg/utils.go @@ -4,19 +4,19 @@ import ( "errors" "time" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" ) type helper struct { - msgProvider widgets.ProvidesMessages + msgProvider app.ProvidesMessages statusInfo func(string) } -func newHelper(aerc *widgets.Aerc) *helper { - msgProvider, ok := aerc.SelectedTabContent().(widgets.ProvidesMessages) +func newHelper(aerc *app.Aerc) *helper { + msgProvider, ok := aerc.SelectedTabContent().(app.ProvidesMessages) if !ok { msgProvider = aerc.SelectedAccount() } @@ -40,7 +40,7 @@ func (h *helper) store() (*lib.MessageStore, error) { return store, nil } -func (h *helper) account() (*widgets.AccountView, error) { +func (h *helper) account() (*app.AccountView, error) { acct := h.msgProvider.SelectedAccount() if acct == nil { return nil, errors.New("No account selected") diff --git a/commands/msgview/close.go b/commands/msgview/close.go index 5e4f3e92..428dc51f 100644 --- a/commands/msgview/close.go +++ b/commands/msgview/close.go @@ -3,7 +3,7 @@ package msgview import ( "errors" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Close struct{} @@ -16,15 +16,15 @@ func (Close) Aliases() []string { return []string{"close"} } -func (Close) Complete(aerc *widgets.Aerc, args []string) []string { +func (Close) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Close) Execute(aerc *widgets.Aerc, args []string) error { +func (Close) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: close") } - mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer) + mv, _ := aerc.SelectedTabContent().(*app.MessageViewer) aerc.RemoveTab(mv, true) return nil } diff --git a/commands/msgview/next-part.go b/commands/msgview/next-part.go index 652dccb6..6f314991 100644 --- a/commands/msgview/next-part.go +++ b/commands/msgview/next-part.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type NextPrevPart struct{} @@ -17,11 +17,11 @@ func (NextPrevPart) Aliases() []string { return []string{"next-part", "prev-part"} } -func (NextPrevPart) Complete(aerc *widgets.Aerc, args []string) []string { +func (NextPrevPart) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (NextPrevPart) Execute(aerc *widgets.Aerc, args []string) error { +func (NextPrevPart) Execute(aerc *app.Aerc, args []string) error { if len(args) > 2 { return nextPrevPartUsage(args[0]) } @@ -35,7 +35,7 @@ func (NextPrevPart) Execute(aerc *widgets.Aerc, args []string) error { return nextPrevPartUsage(args[0]) } } - mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer) + mv, _ := aerc.SelectedTabContent().(*app.MessageViewer) for ; n > 0; n-- { if args[0] == "prev-part" { mv.PreviousPart() diff --git a/commands/msgview/next.go b/commands/msgview/next.go index cc7a5479..e647cc0d 100644 --- a/commands/msgview/next.go +++ b/commands/msgview/next.go @@ -4,10 +4,10 @@ import ( "errors" "fmt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands/account" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -21,16 +21,16 @@ func (NextPrevMsg) Aliases() []string { return []string{"next", "next-message", "prev", "prev-message"} } -func (NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string { +func (NextPrevMsg) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error { +func (NextPrevMsg) Execute(aerc *app.Aerc, args []string) error { n, pct, err := account.ParseNextPrevMessage(args) if err != nil { return err } - mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer) + mv, _ := aerc.SelectedTabContent().(*app.MessageViewer) acct := mv.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -51,7 +51,7 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error { aerc.PushError(err.Error()) return } - nextMv := widgets.NewMessageViewer(acct, view) + nextMv := app.NewMessageViewer(acct, view) aerc.ReplaceTab(mv, nextMv, nextMsg.Envelope.Subject, true) }) diff --git a/commands/msgview/open-link.go b/commands/msgview/open-link.go index da58b717..4052e3a6 100644 --- a/commands/msgview/open-link.go +++ b/commands/msgview/open-link.go @@ -5,10 +5,10 @@ import ( "fmt" "net/url" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" ) type OpenLink struct{} @@ -21,8 +21,8 @@ func (OpenLink) Aliases() []string { return []string{"open-link"} } -func (OpenLink) Complete(aerc *widgets.Aerc, args []string) []string { - mv := aerc.SelectedTabContent().(*widgets.MessageViewer) +func (OpenLink) Complete(aerc *app.Aerc, args []string) []string { + mv := aerc.SelectedTabContent().(*app.MessageViewer) if mv != nil { if p := mv.SelectedMessagePart(); p != nil { return commands.CompletionFromList(aerc, p.Links, args) @@ -31,7 +31,7 @@ func (OpenLink) Complete(aerc *widgets.Aerc, args []string) []string { return nil } -func (OpenLink) Execute(aerc *widgets.Aerc, args []string) error { +func (OpenLink) Execute(aerc *app.Aerc, args []string) error { if len(args) < 2 { return errors.New("Usage: open-link <url> [program [args...]]") } diff --git a/commands/msgview/open.go b/commands/msgview/open.go index b66456cc..1f74bc7a 100644 --- a/commands/msgview/open.go +++ b/commands/msgview/open.go @@ -9,9 +9,9 @@ import ( "git.sr.ht/~sircmpwn/getopt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/widgets" ) type Open struct{} @@ -28,11 +28,11 @@ func (Open) Aliases() []string { return []string{"open"} } -func (Open) Complete(aerc *widgets.Aerc, args []string) []string { +func (Open) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (o Open) Execute(aerc *widgets.Aerc, args []string) error { +func (o Open) Execute(aerc *app.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, o.Options()) if err != nil { return err @@ -46,7 +46,7 @@ func (o Open) Execute(aerc *widgets.Aerc, args []string) error { } } - mv := aerc.SelectedTabContent().(*widgets.MessageViewer) + mv := aerc.SelectedTabContent().(*app.MessageViewer) if mv == nil { return errors.New("open only supported selected message parts") } diff --git a/commands/msgview/save.go b/commands/msgview/save.go index 1ffdaf92..4d914e3e 100644 --- a/commands/msgview/save.go +++ b/commands/msgview/save.go @@ -11,12 +11,12 @@ import ( "git.sr.ht/~sircmpwn/getopt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib/xdg" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" ) type Save struct{} @@ -33,7 +33,7 @@ func (Save) Aliases() []string { return []string{"save"} } -func (s Save) Complete(aerc *widgets.Aerc, args []string) []string { +func (s Save) Complete(aerc *app.Aerc, args []string) []string { trimmed := commands.Operands(args, s.Options()) path := strings.Join(trimmed, " ") defaultPath := config.General.DefaultSavePath @@ -51,7 +51,7 @@ type saveParams struct { allAttachments bool } -func (s Save) Execute(aerc *widgets.Aerc, args []string) error { +func (s Save) Execute(aerc *app.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, s.Options()) if err != nil { return err @@ -100,7 +100,7 @@ func (s Save) Execute(aerc *widgets.Aerc, args []string) error { path = xdg.ExpandHome(path) - mv, ok := aerc.SelectedTabContent().(*widgets.MessageViewer) + mv, ok := aerc.SelectedTabContent().(*app.MessageViewer) if !ok { return fmt.Errorf("SelectedTabContent is not a MessageViewer") } @@ -125,10 +125,10 @@ func (s Save) Execute(aerc *widgets.Aerc, args []string) error { } func savePart( - pi *widgets.PartInfo, + pi *app.PartInfo, path string, - mv *widgets.MessageViewer, - aerc *widgets.Aerc, + mv *app.MessageViewer, + aerc *app.Aerc, params *saveParams, names map[string]struct{}, ) error { diff --git a/commands/msgview/toggle-headers.go b/commands/msgview/toggle-headers.go index 1a593494..0bb834a9 100644 --- a/commands/msgview/toggle-headers.go +++ b/commands/msgview/toggle-headers.go @@ -3,7 +3,7 @@ package msgview import ( "fmt" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type ToggleHeaders struct{} @@ -16,15 +16,15 @@ func (ToggleHeaders) Aliases() []string { return []string{"toggle-headers"} } -func (ToggleHeaders) Complete(aerc *widgets.Aerc, args []string) []string { +func (ToggleHeaders) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (ToggleHeaders) Execute(aerc *widgets.Aerc, args []string) error { +func (ToggleHeaders) Execute(aerc *app.Aerc, args []string) error { if len(args) > 1 { return toggleHeadersUsage(args[0]) } - mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer) + mv, _ := aerc.SelectedTabContent().(*app.MessageViewer) mv.ToggleHeaders() return nil } diff --git a/commands/msgview/toggle-key-passthrough.go b/commands/msgview/toggle-key-passthrough.go index 00a39559..7e24329a 100644 --- a/commands/msgview/toggle-key-passthrough.go +++ b/commands/msgview/toggle-key-passthrough.go @@ -3,8 +3,8 @@ package msgview import ( "errors" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/state" - "git.sr.ht/~rjarry/aerc/widgets" ) type ToggleKeyPassthrough struct{} @@ -17,15 +17,15 @@ func (ToggleKeyPassthrough) Aliases() []string { return []string{"toggle-key-passthrough"} } -func (ToggleKeyPassthrough) Complete(aerc *widgets.Aerc, args []string) []string { +func (ToggleKeyPassthrough) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (ToggleKeyPassthrough) Execute(aerc *widgets.Aerc, args []string) error { +func (ToggleKeyPassthrough) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: toggle-key-passthrough") } - mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer) + mv, _ := aerc.SelectedTabContent().(*app.MessageViewer) keyPassthroughEnabled := mv.ToggleKeyPassthrough() if acct := mv.SelectedAccount(); acct != nil { acct.SetStatus(state.Passthrough(keyPassthroughEnabled)) diff --git a/commands/new-account.go b/commands/new-account.go index d67b5eca..3170c75c 100644 --- a/commands/new-account.go +++ b/commands/new-account.go @@ -3,7 +3,7 @@ package commands import ( "errors" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~sircmpwn/getopt" ) @@ -17,16 +17,16 @@ func (NewAccount) Aliases() []string { return []string{"new-account"} } -func (NewAccount) Complete(aerc *widgets.Aerc, args []string) []string { +func (NewAccount) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (NewAccount) Execute(aerc *widgets.Aerc, args []string) error { +func (NewAccount) Execute(aerc *app.Aerc, args []string) error { opts, _, err := getopt.Getopts(args, "t") if err != nil { return errors.New("Usage: new-account [-t]") } - wizard := widgets.NewAccountWizard(aerc) + wizard := app.NewAccountWizard(aerc) for _, opt := range opts { if opt.Option == 't' { wizard.ConfigureTemporaryAccount(true) diff --git a/commands/next-tab.go b/commands/next-tab.go index 854353f8..247e7534 100644 --- a/commands/next-tab.go +++ b/commands/next-tab.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type NextPrevTab struct{} @@ -17,11 +17,11 @@ func (NextPrevTab) Aliases() []string { return []string{"next-tab", "prev-tab"} } -func (NextPrevTab) Complete(aerc *widgets.Aerc, args []string) []string { +func (NextPrevTab) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (NextPrevTab) Execute(aerc *widgets.Aerc, args []string) error { +func (NextPrevTab) Execute(aerc *app.Aerc, args []string) error { if len(args) > 2 { return nextPrevTabUsage(args[0]) } diff --git a/commands/pin-tab.go b/commands/pin-tab.go index 9a626614..e2e897ed 100644 --- a/commands/pin-tab.go +++ b/commands/pin-tab.go @@ -3,7 +3,7 @@ package commands import ( "fmt" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type PinTab struct{} @@ -16,11 +16,11 @@ func (PinTab) Aliases() []string { return []string{"pin-tab", "unpin-tab"} } -func (PinTab) Complete(aerc *widgets.Aerc, args []string) []string { +func (PinTab) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (PinTab) Execute(aerc *widgets.Aerc, args []string) error { +func (PinTab) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return fmt.Errorf("Usage: %s", args[0]) } diff --git a/commands/prompt.go b/commands/prompt.go index a93d19a9..d3a9411c 100644 --- a/commands/prompt.go +++ b/commands/prompt.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Prompt struct{} @@ -17,7 +17,7 @@ func (Prompt) Aliases() []string { return []string{"prompt"} } -func (Prompt) Complete(aerc *widgets.Aerc, args []string) []string { +func (Prompt) Complete(aerc *app.Aerc, args []string) []string { argc := len(args) if argc == 0 { return nil @@ -69,7 +69,7 @@ func (Prompt) Complete(aerc *widgets.Aerc, args []string) []string { return rs } -func (Prompt) Execute(aerc *widgets.Aerc, args []string) error { +func (Prompt) Execute(aerc *app.Aerc, args []string) error { if len(args) < 3 { return fmt.Errorf("Usage: %s <prompt> <cmd>", args[0]) } diff --git a/commands/pwd.go b/commands/pwd.go index 624258ce..9082a469 100644 --- a/commands/pwd.go +++ b/commands/pwd.go @@ -5,7 +5,7 @@ import ( "os" "time" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type PrintWorkDir struct{} @@ -18,11 +18,11 @@ func (PrintWorkDir) Aliases() []string { return []string{"pwd"} } -func (PrintWorkDir) Complete(aerc *widgets.Aerc, args []string) []string { +func (PrintWorkDir) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (PrintWorkDir) Execute(aerc *widgets.Aerc, args []string) error { +func (PrintWorkDir) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: pwd") } diff --git a/commands/quit.go b/commands/quit.go index 09791a74..73054f86 100644 --- a/commands/quit.go +++ b/commands/quit.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands/mode" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~sircmpwn/getopt" ) @@ -19,7 +19,7 @@ func (Quit) Aliases() []string { return []string{"quit", "exit"} } -func (Quit) Complete(aerc *widgets.Aerc, args []string) []string { +func (Quit) Complete(aerc *app.Aerc, args []string) []string { return nil } @@ -29,7 +29,7 @@ func (err ErrorExit) Error() string { return "exit" } -func (Quit) Execute(aerc *widgets.Aerc, args []string) error { +func (Quit) Execute(aerc *app.Aerc, args []string) error { force := false opts, optind, err := getopt.Getopts(args, "f") if err != nil { diff --git a/commands/term.go b/commands/term.go index 22957635..c5fa5cbd 100644 --- a/commands/term.go +++ b/commands/term.go @@ -5,8 +5,8 @@ import ( "github.com/riywo/loginshell" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/ui" - "git.sr.ht/~rjarry/aerc/widgets" ) type Term struct{} @@ -19,12 +19,12 @@ func (Term) Aliases() []string { return []string{"terminal", "term"} } -func (Term) Complete(aerc *widgets.Aerc, args []string) []string { +func (Term) Complete(aerc *app.Aerc, args []string) []string { return nil } // The help command is an alias for `term man` thus Term requires a simple func -func TermCore(aerc *widgets.Aerc, args []string) error { +func TermCore(aerc *app.Aerc, args []string) error { if len(args) == 1 { shell, err := loginshell.Shell() if err != nil { @@ -32,7 +32,7 @@ func TermCore(aerc *widgets.Aerc, args []string) error { } args = append(args, shell) } - term, err := widgets.NewTerminal(exec.Command(args[1], args[2:]...)) + term, err := app.NewTerminal(exec.Command(args[1], args[2:]...)) if err != nil { return err } @@ -55,6 +55,6 @@ func TermCore(aerc *widgets.Aerc, args []string) error { return nil } -func (Term) Execute(aerc *widgets.Aerc, args []string) error { +func (Term) Execute(aerc *app.Aerc, args []string) error { return TermCore(aerc, args) } diff --git a/commands/terminal/close.go b/commands/terminal/close.go index 812266c0..0f72292e 100644 --- a/commands/terminal/close.go +++ b/commands/terminal/close.go @@ -3,7 +3,7 @@ package terminal import ( "errors" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Close struct{} @@ -16,15 +16,15 @@ func (Close) Aliases() []string { return []string{"close"} } -func (Close) Complete(aerc *widgets.Aerc, args []string) []string { +func (Close) Complete(aerc *app.Aerc, args []string) []string { return nil } -func (Close) Execute(aerc *widgets.Aerc, args []string) error { +func (Close) Execute(aerc *app.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: close") } - term, _ := aerc.SelectedTabContent().(*widgets.Terminal) + term, _ := aerc.SelectedTabContent().(*app.Terminal) term.Close() return nil } diff --git a/commands/util.go b/commands/util.go index aeb18237..fbb20433 100644 --- a/commands/util.go +++ b/commands/util.go @@ -12,24 +12,24 @@ import ( "github.com/lithammer/fuzzysearch/fuzzy" + "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/xdg" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" - "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" "github.com/gdamore/tcell/v2" ) // QuickTerm is an ephemeral terminal for running a single command and quitting. -func QuickTerm(aerc *widgets.Aerc, args []string, stdin io.Reader) (*widgets.Terminal, error) { +func QuickTerm(aerc *app.Aerc, args []string, stdin io.Reader) (*app.Terminal, error) { cmd := exec.Command(args[0], args[1:]...) pipe, err := cmd.StdinPipe() if err != nil { return nil, err } - term, err := widgets.NewTerminal(cmd) + term, err := app.NewTerminal(cmd) if err != nil { return nil, err } @@ -167,7 +167,7 @@ func listDir(path string, hidden bool) []string { // MarkedOrSelected returns either all marked messages if any are marked or the // selected message instead -func MarkedOrSelected(pm widgets.ProvidesMessages) ([]uint32, error) { +func MarkedOrSelected(pm app.ProvidesMessages) ([]uint32, error) { // marked has priority over the selected message marked, err := pm.MarkedMessages() if err != nil { diff --git a/commands/z.go b/commands/z.go index ca982ba7..aa903738 100644 --- a/commands/z.go +++ b/commands/z.go @@ -6,7 +6,7 @@ import ( "os/exec" "strings" - "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/app" ) type Zoxide struct{} @@ -36,13 +36,13 @@ func (Zoxide) Aliases() []string { return []string{"z"} } -func (Zoxide) Complete(aerc *widgets.Aerc, args []string) []string { +func (Zoxide) Complete(aerc *app.Aerc, args []string) []string { return ChangeDirectory{}.Complete(aerc, args) } // Execute calls zoxide add and query and delegates actually changing the // directory to ChangeDirectory -func (Zoxide) Execute(aerc *widgets.Aerc, args []string) error { +func (Zoxide) Execute(aerc *app.Aerc, args []string) error { if len(args) < 1 { return errors.New("Usage: z [directory or zoxide query]") } |