summaryrefslogtreecommitdiff
path: root/widgets/compose.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-05-28 10:32:42 -0400
committerDrew DeVault <sir@cmpwn.com>2020-05-28 10:32:42 -0400
commitcaad1b2c06a0446059ee5ee916e3dce1794b159b (patch)
treeee81255485234137a5902d87d5960ac06618b341 /widgets/compose.go
parent76a91813d8dc0f0011202f8120fc197097f022aa (diff)
downloadaerc-caad1b2c06a0446059ee5ee916e3dce1794b159b.zip
Revert "Add Style configuration"
This reverts commit 0f78f06610c0e8887aba2ae50e99b86477a384b3.
Diffstat (limited to 'widgets/compose.go')
-rw-r--r--widgets/compose.go69
1 files changed, 29 insertions, 40 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index f85e1f3..01b8dd8 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -72,11 +72,10 @@ func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
templateData := templates.ParseTemplateData(defaults, original)
cmpl := completer.New(conf.Compose.AddressBookCmd, func(err error) {
- aerc.PushError(
- fmt.Sprintf("could not complete header: %v", err), 10*time.Second)
+ aerc.PushError(fmt.Sprintf("could not complete header: %v", err))
worker.Logger.Printf("could not complete header: %v", err)
}, aerc.Logger())
- layout, editors, focusable := buildComposeHeader(aerc, cmpl, defaults)
+ layout, editors, focusable := buildComposeHeader(conf, cmpl, defaults)
email, err := ioutil.TempFile("", "aerc-compose-*.eml")
if err != nil {
@@ -113,21 +112,21 @@ func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
return c, nil
}
-func buildComposeHeader(aerc *Aerc, cmpl *completer.Completer,
+func buildComposeHeader(conf *config.AercConfig, cmpl *completer.Completer,
defaults map[string]string) (
newLayout HeaderLayout,
editors map[string]*headerEditor,
focusable []ui.MouseableDrawableInteractive,
) {
- layout := aerc.conf.Compose.HeaderLayout
+ layout := conf.Compose.HeaderLayout
editors = make(map[string]*headerEditor)
focusable = make([]ui.MouseableDrawableInteractive, 0)
for _, row := range layout {
for _, h := range row {
- e := newHeaderEditor(h, "", aerc.SelectedAccount().UiConfig())
- if aerc.conf.Ui.CompletionPopovers {
- e.input.TabComplete(cmpl.ForHeader(h), aerc.SelectedAccount().UiConfig().CompletionDelay)
+ e := newHeaderEditor(h, "")
+ if conf.Ui.CompletionPopovers {
+ e.input.TabComplete(cmpl.ForHeader(h), conf.Ui.CompletionDelay)
}
editors[h] = e
switch h {
@@ -144,9 +143,9 @@ func buildComposeHeader(aerc *Aerc, cmpl *completer.Completer,
for _, h := range []string{"Cc", "Bcc"} {
if val, ok := defaults[h]; ok && val != "" {
if _, ok := editors[h]; !ok {
- e := newHeaderEditor(h, "", aerc.SelectedAccount().UiConfig())
- if aerc.conf.Ui.CompletionPopovers {
- e.input.TabComplete(cmpl.ForHeader(h), aerc.SelectedAccount().UiConfig().CompletionDelay)
+ e := newHeaderEditor(h, "")
+ if conf.Ui.CompletionPopovers {
+ e.input.TabComplete(cmpl.ForHeader(h), conf.Ui.CompletionDelay)
}
editors[h] = e
focusable = append(focusable, e)
@@ -260,9 +259,7 @@ func (c *Composer) readSignatureFromFile() []byte {
}
signature, err := ioutil.ReadFile(sigFile)
if err != nil {
- c.aerc.PushError(
- fmt.Sprintf(" Error loading signature from file: %v", sigFile),
- 10*time.Second)
+ c.aerc.PushError(fmt.Sprintf(" Error loading signature from file: %v", sigFile))
return nil
}
return signature
@@ -651,7 +648,7 @@ func (c *Composer) AddEditor(header string, value string, appendHeader bool) {
}
return
}
- e := newHeaderEditor(header, value, c.aerc.SelectedAccount().UiConfig())
+ e := newHeaderEditor(header, value)
if c.config.Ui.CompletionPopovers {
e.input.TabComplete(c.completer.ForHeader(header), c.config.Ui.CompletionDelay)
}
@@ -705,27 +702,23 @@ func (c *Composer) reloadEmail() error {
}
type headerEditor struct {
- name string
- focused bool
- input *ui.TextInput
- uiConfig config.UIConfig
+ name string
+ focused bool
+ input *ui.TextInput
}
-func newHeaderEditor(name string, value string, uiConfig config.UIConfig) *headerEditor {
+func newHeaderEditor(name string, value string) *headerEditor {
return &headerEditor{
- input: ui.NewTextInput(value, uiConfig),
- name: name,
- uiConfig: uiConfig,
+ input: ui.NewTextInput(value),
+ name: name,
}
}
func (he *headerEditor) Draw(ctx *ui.Context) {
name := he.name + " "
size := runewidth.StringWidth(name)
- defaultStyle := he.uiConfig.GetStyle(config.STYLE_DEFAULT)
- headerStyle := he.uiConfig.GetStyle(config.STYLE_HEADER)
- ctx.Fill(0, 0, size, ctx.Height(), ' ', defaultStyle)
- ctx.Printf(0, 0, headerStyle, "%s", name)
+ ctx.Fill(0, 0, size, ctx.Height(), ' ', tcell.StyleDefault)
+ ctx.Printf(0, 0, tcell.StyleDefault.Bold(true), "%s", name)
he.input.Draw(ctx.Subcontext(size, 0, ctx.Width()-size, 1))
}
@@ -786,25 +779,21 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage {
{ui.SIZE_WEIGHT, 1},
})
- uiConfig := composer.config.Ui
-
if err != nil {
- grid.AddChild(ui.NewText(err.Error(), uiConfig.GetStyle(config.STYLE_ERROR)))
- grid.AddChild(ui.NewText("Press [q] to close this tab.",
- uiConfig.GetStyle(config.STYLE_DEFAULT))).At(1, 0)
+ grid.AddChild(ui.NewText(err.Error()).
+ Color(tcell.ColorRed, tcell.ColorDefault))
+ grid.AddChild(ui.NewText("Press [q] to close this tab.")).At(1, 0)
} else {
// TODO: source this from actual keybindings?
- grid.AddChild(ui.NewText("Send this email? [y]es/[n]o/[e]dit/[a]ttach",
- uiConfig.GetStyle(config.STYLE_DEFAULT))).At(0, 0)
- grid.AddChild(ui.NewText("Attachments:",
- uiConfig.GetStyle(config.STYLE_TITLE))).At(1, 0)
+ grid.AddChild(ui.NewText(
+ "Send this email? [y]es/[n]o/[p]ostpone/[e]dit/[a]ttach")).At(0, 0)
+ grid.AddChild(ui.NewText("Attachments:").
+ Reverse(true)).At(1, 0)
if len(composer.attachments) == 0 {
- grid.AddChild(ui.NewText("(none)",
- uiConfig.GetStyle(config.STYLE_DEFAULT))).At(2, 0)
+ grid.AddChild(ui.NewText("(none)")).At(2, 0)
} else {
for i, a := range composer.attachments {
- grid.AddChild(ui.NewText(a, uiConfig.GetStyle(config.STYLE_DEFAULT))).
- At(i+2, 0)
+ grid.AddChild(ui.NewText(a)).At(i+2, 0)
}
}
}