mirror of
https://git.sr.ht/~sircmpwn/aerc
synced 2024-11-23 08:32:12 +01:00
Allow cc/bcc command to receive no arguments
This commit is contained in:
parent
0ceea02720
commit
0a52124102
@ -1,7 +1,6 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.sr.ht/~sircmpwn/aerc/widgets"
|
||||
@ -22,10 +21,10 @@ func (_ CC) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
}
|
||||
|
||||
func (_ CC) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Usage: %s <addresses>", args[0])
|
||||
var addrs string
|
||||
if len(args) > 1 {
|
||||
addrs = strings.Join(args[1:], " ")
|
||||
}
|
||||
addrs := strings.Join(args[1:], " ")
|
||||
composer, _ := aerc.SelectedTab().(*widgets.Composer)
|
||||
|
||||
switch args[0] {
|
||||
|
@ -216,7 +216,7 @@ message list, the message in the message viewer, etc).
|
||||
Detaches the file with the given path from the composed email. If no path is
|
||||
specified, detaches the first attachment instead.
|
||||
|
||||
*cc* <addresses>, *bcc* <addresses>
|
||||
*cc* [addresses], *bcc* [addresses]
|
||||
Sets the Cc or Bcc header to the given addresses. If an editor for the header
|
||||
is not currently visible in the compose window, a new one will be added.
|
||||
|
||||
|
@ -509,6 +509,17 @@ func (c *Composer) NextField() {
|
||||
c.focusable[c.focused].Focus(true)
|
||||
}
|
||||
|
||||
func (c *Composer) FocusEditor(editor *headerEditor) {
|
||||
c.focusable[c.focused].Focus(false)
|
||||
for i, e := range c.focusable {
|
||||
if e == editor {
|
||||
c.focused = i
|
||||
break
|
||||
}
|
||||
}
|
||||
c.focusable[c.focused].Focus(true)
|
||||
}
|
||||
|
||||
// AddEditor appends a new header editor to the compose window.
|
||||
func (c *Composer) AddEditor(header string, value string, appendHeader bool) {
|
||||
if _, ok := c.editors[header]; ok {
|
||||
@ -517,6 +528,9 @@ func (c *Composer) AddEditor(header string, value string, appendHeader bool) {
|
||||
value = strings.TrimSpace(header) + ", " + value
|
||||
}
|
||||
c.editors[header].input.Set(value)
|
||||
if value == "" {
|
||||
c.FocusEditor(c.editors[header])
|
||||
}
|
||||
return
|
||||
}
|
||||
e := newHeaderEditor(header, value)
|
||||
@ -529,6 +543,9 @@ func (c *Composer) AddEditor(header string, value string, appendHeader bool) {
|
||||
c.focusable[len(c.focusable)-1],
|
||||
)
|
||||
c.updateGrid()
|
||||
if value == "" {
|
||||
c.FocusEditor(c.editors[header])
|
||||
}
|
||||
}
|
||||
|
||||
// updateGrid should be called when the underlying header layout is changed.
|
||||
|
Loading…
Reference in New Issue
Block a user