view,compose: use border color to separate headers from body

When composing a message, there is an empty fill line between the
headers and the text editor. The line is printed with the default style
which may cause users to assume it is part of the editor.

Display the fill lines with the border color to avoid confusion.

Signed-off-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Robin Jarry 2021-10-26 22:42:07 +02:00
parent 42b4302ba3
commit fc84b19bba
5 changed files with 28 additions and 22 deletions

View file

@ -4,16 +4,19 @@ import (
"github.com/gdamore/tcell/v2" "github.com/gdamore/tcell/v2"
) )
type Fill rune type Fill struct {
Rune rune
Style tcell.Style
}
func NewFill(f rune) Fill { func NewFill(f rune, s tcell.Style) Fill {
return Fill(f) return Fill{f, s}
} }
func (f Fill) Draw(ctx *Context) { func (f Fill) Draw(ctx *Context) {
for x := 0; x < ctx.Width(); x += 1 { for x := 0; x < ctx.Width(); x += 1 {
for y := 0; y < ctx.Height(); y += 1 { for y := 0; y < ctx.Height(); y += 1 {
ctx.SetCell(x, y, rune(f), tcell.StyleDefault) ctx.SetCell(x, y, f.Rune, f.Style)
} }
} }
} }

View file

@ -163,7 +163,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(1, 0) At(1, 0)
basics.AddChild(wizard.accountName). basics.AddChild(wizard.accountName).
At(2, 0) At(2, 0)
basics.AddChild(ui.NewFill(' ')). basics.AddChild(ui.NewFill(' ', tcell.StyleDefault)).
At(3, 0) At(3, 0)
basics.AddChild( basics.AddChild(
ui.NewText("Full name for outgoing emails? (e.g. 'John Doe')", ui.NewText("Full name for outgoing emails? (e.g. 'John Doe')",
@ -171,7 +171,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(4, 0) At(4, 0)
basics.AddChild(wizard.fullName). basics.AddChild(wizard.fullName).
At(5, 0) At(5, 0)
basics.AddChild(ui.NewFill(' ')). basics.AddChild(ui.NewFill(' ', tcell.StyleDefault)).
At(6, 0) At(6, 0)
basics.AddChild( basics.AddChild(
ui.NewText("Your email address? (e.g. 'john@example.org')", ui.NewText("Your email address? (e.g. 'john@example.org')",
@ -238,7 +238,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(1, 0) At(1, 0)
incoming.AddChild(wizard.imapUsername). incoming.AddChild(wizard.imapUsername).
At(2, 0) At(2, 0)
incoming.AddChild(ui.NewFill(' ')). incoming.AddChild(ui.NewFill(' ', tcell.StyleDefault)).
At(3, 0) At(3, 0)
incoming.AddChild( incoming.AddChild(
ui.NewText("Password", ui.NewText("Password",
@ -246,7 +246,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(4, 0) At(4, 0)
incoming.AddChild(wizard.imapPassword). incoming.AddChild(wizard.imapPassword).
At(5, 0) At(5, 0)
incoming.AddChild(ui.NewFill(' ')). incoming.AddChild(ui.NewFill(' ', tcell.StyleDefault)).
At(6, 0) At(6, 0)
incoming.AddChild( incoming.AddChild(
ui.NewText("Server address "+ ui.NewText("Server address "+
@ -255,7 +255,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(7, 0) At(7, 0)
incoming.AddChild(wizard.imapServer). incoming.AddChild(wizard.imapServer).
At(8, 0) At(8, 0)
incoming.AddChild(ui.NewFill(' ')). incoming.AddChild(ui.NewFill(' ', tcell.StyleDefault)).
At(9, 0) At(9, 0)
incoming.AddChild( incoming.AddChild(
ui.NewText("Connection mode", ui.NewText("Connection mode",
@ -279,7 +279,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
incoming.AddChild(imapMode).At(11, 0) incoming.AddChild(imapMode).At(11, 0)
selector = NewSelector([]string{"Previous", "Next"}, 1, conf.Ui). selector = NewSelector([]string{"Previous", "Next"}, 1, conf.Ui).
OnChoose(wizard.advance) OnChoose(wizard.advance)
incoming.AddChild(ui.NewFill(' ')).At(12, 0) incoming.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(12, 0)
incoming.AddChild(wizard.imapStr).At(13, 0) incoming.AddChild(wizard.imapStr).At(13, 0)
incoming.AddChild(selector).At(14, 0) incoming.AddChild(selector).At(14, 0)
wizard.incoming = []ui.Interactive{ wizard.incoming = []ui.Interactive{
@ -320,7 +320,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(1, 0) At(1, 0)
outgoing.AddChild(wizard.smtpUsername). outgoing.AddChild(wizard.smtpUsername).
At(2, 0) At(2, 0)
outgoing.AddChild(ui.NewFill(' ')). outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)).
At(3, 0) At(3, 0)
outgoing.AddChild( outgoing.AddChild(
ui.NewText("Password", ui.NewText("Password",
@ -328,7 +328,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(4, 0) At(4, 0)
outgoing.AddChild(wizard.smtpPassword). outgoing.AddChild(wizard.smtpPassword).
At(5, 0) At(5, 0)
outgoing.AddChild(ui.NewFill(' ')). outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)).
At(6, 0) At(6, 0)
outgoing.AddChild( outgoing.AddChild(
ui.NewText("Server address "+ ui.NewText("Server address "+
@ -337,7 +337,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(7, 0) At(7, 0)
outgoing.AddChild(wizard.smtpServer). outgoing.AddChild(wizard.smtpServer).
At(8, 0) At(8, 0)
outgoing.AddChild(ui.NewFill(' ')). outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)).
At(9, 0) At(9, 0)
outgoing.AddChild( outgoing.AddChild(
ui.NewText("Connection mode", ui.NewText("Connection mode",
@ -361,9 +361,9 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
outgoing.AddChild(smtpMode).At(11, 0) outgoing.AddChild(smtpMode).At(11, 0)
selector = NewSelector([]string{"Previous", "Next"}, 1, conf.Ui). selector = NewSelector([]string{"Previous", "Next"}, 1, conf.Ui).
OnChoose(wizard.advance) OnChoose(wizard.advance)
outgoing.AddChild(ui.NewFill(' ')).At(12, 0) outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(12, 0)
outgoing.AddChild(wizard.smtpStr).At(13, 0) outgoing.AddChild(wizard.smtpStr).At(13, 0)
outgoing.AddChild(ui.NewFill(' ')).At(14, 0) outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(14, 0)
outgoing.AddChild( outgoing.AddChild(
ui.NewText("Copy sent messages to 'Sent' folder?", ui.NewText("Copy sent messages to 'Sent' folder?",
conf.Ui.GetStyle(config.STYLE_HEADER))).At(15, 0) conf.Ui.GetStyle(config.STYLE_HEADER))).At(15, 0)

View file

@ -648,8 +648,8 @@ func errorScreen(s string, conf config.UIConfig) ui.Drawable {
}).Columns([]ui.GridSpec{ }).Columns([]ui.GridSpec{
{ui.SIZE_WEIGHT, ui.Const(1)}, {ui.SIZE_WEIGHT, ui.Const(1)},
}) })
grid.AddChild(ui.NewFill(' ')).At(0, 0) grid.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(0, 0)
grid.AddChild(text).At(1, 0) grid.AddChild(text).At(1, 0)
grid.AddChild(ui.NewFill(' ')).At(2, 0) grid.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(2, 0)
return grid return grid
} }

View file

@ -678,9 +678,10 @@ func (c *Composer) updateGrid() {
if c.heditors != nil { if c.heditors != nil {
c.grid.RemoveChild(c.heditors) c.grid.RemoveChild(c.heditors)
} }
borderStyle := c.config.Ui.GetStyle(config.STYLE_BORDER)
c.heditors = heditors c.heditors = heditors
c.grid.AddChild(c.heditors).At(0, 0) c.grid.AddChild(c.heditors).At(0, 0)
c.grid.AddChild(ui.NewFill(' ')).At(1, 0) c.grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0)
} }
func (c *Composer) reloadEmail() error { func (c *Composer) reloadEmail() error {

View file

@ -105,13 +105,15 @@ func NewMessageViewer(acct *AccountView,
} }
} }
borderStyle := acct.UiConfig().GetStyle(config.STYLE_BORDER)
grid.AddChild(header).At(0, 0) grid.AddChild(header).At(0, 0)
if msg.PGPDetails() != nil { if msg.PGPDetails() != nil {
grid.AddChild(NewPGPInfo(msg.PGPDetails(), acct.UiConfig())).At(1, 0) grid.AddChild(NewPGPInfo(msg.PGPDetails(), acct.UiConfig())).At(1, 0)
grid.AddChild(ui.NewFill(' ')).At(2, 0) grid.AddChild(ui.NewFill(' ', borderStyle)).At(2, 0)
grid.AddChild(switcher).At(3, 0) grid.AddChild(switcher).At(3, 0)
} else { } else {
grid.AddChild(ui.NewFill(' ')).At(1, 0) grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0)
grid.AddChild(switcher).At(2, 0) grid.AddChild(switcher).At(2, 0)
} }