diff options
author | Reto Brunner <reto@labrat.space> | 2020-05-27 07:37:02 +0200 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-05-27 07:57:10 +0200 |
commit | 0f78f06610c0e8887aba2ae50e99b86477a384b3 (patch) | |
tree | ff4cd6581d3af0911954a37550602366d2bb0e2f /commands | |
parent | 6c4ed3cfe2fe66a1e5f26c404ea90e048142db72 (diff) | |
download | aerc-0f78f06610c0e8887aba2ae50e99b86477a384b3.tar.gz |
Add Style configuration
The following functionalities are added to configure aerc ui styles.
- Read stylesets from file with very basic fnmatch wildcard matching
- Add default styleset
- Support different stylesets as part of UiConfig allowing contextual
styles.
- Move widgets/ui elements to use the stylesets.
- Add configuration manual for the styleset
Diffstat (limited to 'commands')
-rw-r--r-- | commands/account/mkdir.go | 2 | ||||
-rw-r--r-- | commands/account/view.go | 3 | ||||
-rw-r--r-- | commands/compose/attach.go | 10 | ||||
-rw-r--r-- | commands/compose/detach.go | 4 | ||||
-rw-r--r-- | commands/compose/postpone.go | 6 | ||||
-rw-r--r-- | commands/compose/send.go | 6 | ||||
-rw-r--r-- | commands/exec.go | 17 | ||||
-rw-r--r-- | commands/msg/archive.go | 2 | ||||
-rw-r--r-- | commands/msg/copy.go | 2 | ||||
-rw-r--r-- | commands/msg/delete.go | 4 | ||||
-rw-r--r-- | commands/msg/forward.go | 3 | ||||
-rw-r--r-- | commands/msg/modify-labels.go | 2 | ||||
-rw-r--r-- | commands/msg/move.go | 2 | ||||
-rw-r--r-- | commands/msg/pipe.go | 18 | ||||
-rw-r--r-- | commands/msg/read.go | 4 | ||||
-rw-r--r-- | commands/msg/recall.go | 3 | ||||
-rw-r--r-- | commands/msg/reply.go | 3 | ||||
-rw-r--r-- | commands/msgview/next.go | 4 | ||||
-rw-r--r-- | commands/msgview/open.go | 6 | ||||
-rw-r--r-- | commands/msgview/save.go | 2 | ||||
-rw-r--r-- | commands/term.go | 3 | ||||
-rw-r--r-- | commands/util.go | 4 |
22 files changed, 55 insertions, 55 deletions
diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go index 4352a420..f99fc01d 100644 --- a/commands/account/mkdir.go +++ b/commands/account/mkdir.go @@ -40,7 +40,7 @@ func (MakeDir) Execute(aerc *widgets.Aerc, args []string) error { aerc.PushStatus("Directory created.", 10*time.Second) acct.Directories().Select(name) case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) } }) return nil diff --git a/commands/account/view.go b/commands/account/view.go index b421666b..d4653be2 100644 --- a/commands/account/view.go +++ b/commands/account/view.go @@ -2,6 +2,7 @@ package account import ( "errors" + "time" "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/widgets" @@ -41,7 +42,7 @@ func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error { lib.NewMessageStoreView(msg, store, aerc.DecryptKeys, func(view lib.MessageView, err error) { if err != nil { - aerc.PushError(err.Error()) + aerc.PushError(err.Error(), 10*time.Second) return } viewer := widgets.NewMessageViewer(acct, aerc.Config(), view) diff --git a/commands/compose/attach.go b/commands/compose/attach.go index 2b633dc6..6b8d72fc 100644 --- a/commands/compose/attach.go +++ b/commands/compose/attach.go @@ -8,7 +8,6 @@ import ( "git.sr.ht/~sircmpwn/aerc/commands" "git.sr.ht/~sircmpwn/aerc/widgets" - "github.com/gdamore/tcell" "github.com/mitchellh/go-homedir" ) @@ -36,24 +35,23 @@ func (Attach) Execute(aerc *widgets.Aerc, args []string) error { path, err := homedir.Expand(path) if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) return err } pathinfo, err := os.Stat(path) if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) return err } else if pathinfo.IsDir() { - aerc.PushError("Attachment must be a file, not a directory") + aerc.PushError("Attachment must be a file, not a directory", 10*time.Second) return nil } composer, _ := aerc.SelectedTab().(*widgets.Composer) composer.AddAttachment(path) - aerc.PushStatus(fmt.Sprintf("Attached %s", pathinfo.Name()), 10*time.Second). - Color(tcell.ColorDefault, tcell.ColorGreen) + aerc.PushSuccess(fmt.Sprintf("Attached %s", pathinfo.Name()), 10*time.Second) return nil } diff --git a/commands/compose/detach.go b/commands/compose/detach.go index e8b07ed6..8bc0e887 100644 --- a/commands/compose/detach.go +++ b/commands/compose/detach.go @@ -6,7 +6,6 @@ import ( "time" "git.sr.ht/~sircmpwn/aerc/widgets" - "github.com/gdamore/tcell" ) type Detach struct{} @@ -44,8 +43,7 @@ func (Detach) Execute(aerc *widgets.Aerc, args []string) error { return err } - aerc.PushStatus(fmt.Sprintf("Detached %s", path), 10*time.Second). - Color(tcell.ColorDefault, tcell.ColorGreen) + aerc.PushSuccess(fmt.Sprintf("Detached %s", path), 10*time.Second) return nil } diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go index 60c9df1a..90b6134b 100644 --- a/commands/compose/postpone.go +++ b/commands/compose/postpone.go @@ -63,7 +63,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error { go func() { errStr := <-errChan if errStr != "" { - aerc.PushError(" " + errStr) + aerc.PushError(" "+errStr, 10*time.Second) return } @@ -71,7 +71,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error { ctr := datacounter.NewWriterCounter(ioutil.Discard) err = composer.WriteMessage(header, ctr) if err != nil { - aerc.PushError(errors.Wrap(err, "WriteMessage").Error()) + aerc.PushError(errors.Wrap(err, "WriteMessage").Error(), 10*time.Second) composer.Close() return } @@ -90,7 +90,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error { r.Close() composer.Close() case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) r.Close() composer.Close() } diff --git a/commands/compose/send.go b/commands/compose/send.go index 59ae5d0b..a22be8f8 100644 --- a/commands/compose/send.go +++ b/commands/compose/send.go @@ -12,7 +12,6 @@ import ( "github.com/emersion/go-sasl" "github.com/emersion/go-smtp" - "github.com/gdamore/tcell" "github.com/google/shlex" "github.com/miolini/datacounter" "github.com/pkg/errors" @@ -225,8 +224,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error { aerc.PushStatus("Sending...", 10*time.Second) nbytes, err := sendAsync() if err != nil { - aerc.SetStatus(" "+err.Error()). - Color(tcell.ColorDefault, tcell.ColorRed) + aerc.SetError(" " + err.Error()) return } if config.CopyTo != "" { @@ -247,7 +245,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error { composer.SetSent() composer.Close() case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) r.Close() composer.Close() } diff --git a/commands/exec.go b/commands/exec.go index e15afbe9..0a5470dc 100644 --- a/commands/exec.go +++ b/commands/exec.go @@ -7,8 +7,6 @@ import ( "time" "git.sr.ht/~sircmpwn/aerc/widgets" - - "github.com/gdamore/tcell" ) type ExecCmd struct{} @@ -33,16 +31,17 @@ func (ExecCmd) Execute(aerc *widgets.Aerc, args []string) error { go func() { err := cmd.Run() if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) } else { - color := tcell.ColorDefault if cmd.ProcessState.ExitCode() != 0 { - color = tcell.ColorRed + aerc.PushError(fmt.Sprintf( + "%s: completed with status %d", args[0], + cmd.ProcessState.ExitCode()), 10*time.Second) + } else { + aerc.PushStatus(fmt.Sprintf( + "%s: completed with status %d", args[0], + cmd.ProcessState.ExitCode()), 10*time.Second) } - aerc.PushStatus(fmt.Sprintf( - "%s: completed with status %d", args[0], - cmd.ProcessState.ExitCode()), 10*time.Second). - Color(tcell.ColorDefault, color) } }() return nil diff --git a/commands/msg/archive.go b/commands/msg/archive.go index 55616748..ba7e1f7f 100644 --- a/commands/msg/archive.go +++ b/commands/msg/archive.go @@ -86,7 +86,7 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error { case *types.Done: wg.Done() case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) success = false wg.Done() } diff --git a/commands/msg/copy.go b/commands/msg/copy.go index f3d4030a..e822c5c1 100644 --- a/commands/msg/copy.go +++ b/commands/msg/copy.go @@ -60,7 +60,7 @@ func (Copy) Execute(aerc *widgets.Aerc, args []string) error { case *types.Done: aerc.PushStatus("Messages copied.", 10*time.Second) case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) } }) return nil diff --git a/commands/msg/delete.go b/commands/msg/delete.go index 4bda8b98..482b60c1 100644 --- a/commands/msg/delete.go +++ b/commands/msg/delete.go @@ -47,7 +47,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error { case *types.Done: aerc.PushStatus("Messages deleted.", 10*time.Second) case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) } }) @@ -68,7 +68,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error { lib.NewMessageStoreView(next, store, aerc.DecryptKeys, func(view lib.MessageView, err error) { if err != nil { - aerc.PushError(err.Error()) + aerc.PushError(err.Error(), 10*time.Second) return } nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view) diff --git a/commands/msg/forward.go b/commands/msg/forward.go index 28abbed1..5dd51b29 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -9,6 +9,7 @@ import ( "os" "path" "strings" + "time" "git.sr.ht/~sircmpwn/aerc/models" "git.sr.ht/~sircmpwn/aerc/widgets" @@ -83,7 +84,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { composer, err := widgets.NewComposer(aerc, acct, aerc.Config(), acct.AccountConfig(), acct.Worker(), template, defaults, original) if err != nil { - aerc.PushError("Error: " + err.Error()) + aerc.PushError("Error: "+err.Error(), 10*time.Second) return nil, err } diff --git a/commands/msg/modify-labels.go b/commands/msg/modify-labels.go index f91075ad..d74aece5 100644 --- a/commands/msg/modify-labels.go +++ b/commands/msg/modify-labels.go @@ -58,7 +58,7 @@ func (ModifyLabels) Execute(aerc *widgets.Aerc, args []string) error { case *types.Done: aerc.PushStatus("labels updated", 10*time.Second) case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) } }) return nil diff --git a/commands/msg/move.go b/commands/msg/move.go index 830e7521..a19194ee 100644 --- a/commands/msg/move.go +++ b/commands/msg/move.go @@ -71,7 +71,7 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error { case *types.Done: aerc.PushStatus("Message moved to "+joinedArgs, 10*time.Second) case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) } }) return nil diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go index c88d61f1..15b8c52a 100644 --- a/commands/msg/pipe.go +++ b/commands/msg/pipe.go @@ -12,7 +12,6 @@ import ( "git.sr.ht/~sircmpwn/aerc/worker/types" "git.sr.ht/~sircmpwn/getopt" - "github.com/gdamore/tcell" ) type Pipe struct{} @@ -76,7 +75,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error { doTerm := func(reader io.Reader, name string) { term, err := commands.QuickTerm(aerc, cmd, reader) if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) return } aerc.NewTab(term, name) @@ -94,16 +93,17 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error { }() err = ecmd.Run() if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) } else { - color := tcell.ColorDefault if ecmd.ProcessState.ExitCode() != 0 { - color = tcell.ColorRed + aerc.PushError(fmt.Sprintf( + "%s: completed with status %d", cmd[0], + ecmd.ProcessState.ExitCode()), 10*time.Second) + } else { + aerc.PushStatus(fmt.Sprintf( + "%s: completed with status %d", cmd[0], + ecmd.ProcessState.ExitCode()), 10*time.Second) } - aerc.PushStatus(fmt.Sprintf( - "%s: completed with status %d", cmd[0], - ecmd.ProcessState.ExitCode()), 10*time.Second). - Color(tcell.ColorDefault, color) } } diff --git a/commands/msg/read.go b/commands/msg/read.go index 1e264c27..e27f7433 100644 --- a/commands/msg/read.go +++ b/commands/msg/read.go @@ -93,7 +93,7 @@ func submitReadChange(aerc *widgets.Aerc, store *lib.MessageStore, case *types.Done: aerc.PushStatus(msg_success, 10*time.Second) case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) } }) } @@ -106,7 +106,7 @@ func submitReadChangeWg(aerc *widgets.Aerc, store *lib.MessageStore, case *types.Done: wg.Done() case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) *success = false wg.Done() } diff --git a/commands/msg/recall.go b/commands/msg/recall.go index 7c9ac193..6c5e9736 100644 --- a/commands/msg/recall.go +++ b/commands/msg/recall.go @@ -2,6 +2,7 @@ package msg import ( "io" + "time" "github.com/emersion/go-message" _ "github.com/emersion/go-message/charset" @@ -91,7 +92,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { }, func(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Error: - aerc.PushError(" " + msg.Error.Error()) + aerc.PushError(" "+msg.Error.Error(), 10*time.Second) composer.Close() } }) diff --git a/commands/msg/reply.go b/commands/msg/reply.go index 28ce245d..455c7ca5 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -7,6 +7,7 @@ import ( "io" gomail "net/mail" "strings" + "time" "git.sr.ht/~sircmpwn/getopt" @@ -139,7 +140,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { composer, err := widgets.NewComposer(aerc, acct, aerc.Config(), acct.AccountConfig(), acct.Worker(), template, defaults, original) if err != nil { - aerc.PushError("Error: " + err.Error()) + aerc.PushError("Error: "+err.Error(), 10*time.Second) return err } diff --git a/commands/msgview/next.go b/commands/msgview/next.go index 978cf10f..f9fb3d7b 100644 --- a/commands/msgview/next.go +++ b/commands/msgview/next.go @@ -1,6 +1,8 @@ package msgview import ( + "time" + "git.sr.ht/~sircmpwn/aerc/commands/account" "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/widgets" @@ -40,7 +42,7 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error { lib.NewMessageStoreView(nextMsg, store, aerc.DecryptKeys, func(view lib.MessageView, err error) { if err != nil { - aerc.PushError(err.Error()) + aerc.PushError(err.Error(), 10*time.Second) return } nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view) diff --git a/commands/msgview/open.go b/commands/msgview/open.go index f708b2dd..7f26542a 100644 --- a/commands/msgview/open.go +++ b/commands/msgview/open.go @@ -49,20 +49,20 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error { tmpFile, err := ioutil.TempFile(os.TempDir(), "aerc-*"+extension) if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) return } defer tmpFile.Close() _, err = io.Copy(tmpFile, reader) if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) return } err = lib.OpenFile(tmpFile.Name()) if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) } aerc.PushStatus("Opened", 10*time.Second) diff --git a/commands/msgview/save.go b/commands/msgview/save.go index ef6bba8a..ea1b8f34 100644 --- a/commands/msgview/save.go +++ b/commands/msgview/save.go @@ -128,7 +128,7 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error { go func() { err := <-ch if err != nil { - aerc.PushError(fmt.Sprintf("Save failed: %v", err)) + aerc.PushError(fmt.Sprintf("Save failed: %v", err), 10*time.Second) return } aerc.PushStatus("Saved to "+path, 10*time.Second) diff --git a/commands/term.go b/commands/term.go index 00f6937b..90232859 100644 --- a/commands/term.go +++ b/commands/term.go @@ -2,6 +2,7 @@ package commands import ( "os/exec" + "time" "github.com/riywo/loginshell" @@ -46,7 +47,7 @@ func TermCore(aerc *widgets.Aerc, args []string) error { term.OnClose = func(err error) { aerc.RemoveTab(term) if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) } } return nil diff --git a/commands/util.go b/commands/util.go index fdf20bda..7c7b6ab1 100644 --- a/commands/util.go +++ b/commands/util.go @@ -32,7 +32,7 @@ func QuickTerm(aerc *widgets.Aerc, args []string, stdin io.Reader) (*widgets.Ter term.OnClose = func(err error) { if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) // remove the tab on error, otherwise it gets stuck aerc.RemoveTab(term) } else { @@ -56,7 +56,7 @@ func QuickTerm(aerc *widgets.Aerc, args []string, stdin io.Reader) (*widgets.Ter err := <-status if err != nil { - aerc.PushError(" " + err.Error()) + aerc.PushError(" "+err.Error(), 10*time.Second) } } |