From fc84b19bba0e0953ec06de27f1ec9c9f8d1a96ef Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Tue, 26 Oct 2021 22:42:07 +0200 Subject: [PATCH] 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 --- lib/ui/fill.go | 11 +++++++---- widgets/account-wizard.go | 22 +++++++++++----------- widgets/aerc.go | 8 ++++---- widgets/compose.go | 3 ++- widgets/msgviewer.go | 6 ++++-- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/ui/fill.go b/lib/ui/fill.go index 0ab4f74..13ad286 100644 --- a/lib/ui/fill.go +++ b/lib/ui/fill.go @@ -4,16 +4,19 @@ import ( "github.com/gdamore/tcell/v2" ) -type Fill rune +type Fill struct { + Rune rune + Style tcell.Style +} -func NewFill(f rune) Fill { - return Fill(f) +func NewFill(f rune, s tcell.Style) Fill { + return Fill{f, s} } func (f Fill) Draw(ctx *Context) { for x := 0; x < ctx.Width(); x += 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) } } } diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go index d8e2eb0..6402c0b 100644 --- a/widgets/account-wizard.go +++ b/widgets/account-wizard.go @@ -163,7 +163,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { At(1, 0) basics.AddChild(wizard.accountName). At(2, 0) - basics.AddChild(ui.NewFill(' ')). + basics.AddChild(ui.NewFill(' ', tcell.StyleDefault)). At(3, 0) basics.AddChild( 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) basics.AddChild(wizard.fullName). At(5, 0) - basics.AddChild(ui.NewFill(' ')). + basics.AddChild(ui.NewFill(' ', tcell.StyleDefault)). At(6, 0) basics.AddChild( 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) incoming.AddChild(wizard.imapUsername). At(2, 0) - incoming.AddChild(ui.NewFill(' ')). + incoming.AddChild(ui.NewFill(' ', tcell.StyleDefault)). At(3, 0) incoming.AddChild( ui.NewText("Password", @@ -246,7 +246,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { At(4, 0) incoming.AddChild(wizard.imapPassword). At(5, 0) - incoming.AddChild(ui.NewFill(' ')). + incoming.AddChild(ui.NewFill(' ', tcell.StyleDefault)). At(6, 0) incoming.AddChild( ui.NewText("Server address "+ @@ -255,7 +255,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { At(7, 0) incoming.AddChild(wizard.imapServer). At(8, 0) - incoming.AddChild(ui.NewFill(' ')). + incoming.AddChild(ui.NewFill(' ', tcell.StyleDefault)). At(9, 0) incoming.AddChild( ui.NewText("Connection mode", @@ -279,7 +279,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { incoming.AddChild(imapMode).At(11, 0) selector = NewSelector([]string{"Previous", "Next"}, 1, conf.Ui). 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(selector).At(14, 0) wizard.incoming = []ui.Interactive{ @@ -320,7 +320,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { At(1, 0) outgoing.AddChild(wizard.smtpUsername). At(2, 0) - outgoing.AddChild(ui.NewFill(' ')). + outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)). At(3, 0) outgoing.AddChild( ui.NewText("Password", @@ -328,7 +328,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { At(4, 0) outgoing.AddChild(wizard.smtpPassword). At(5, 0) - outgoing.AddChild(ui.NewFill(' ')). + outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)). At(6, 0) outgoing.AddChild( ui.NewText("Server address "+ @@ -337,7 +337,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { At(7, 0) outgoing.AddChild(wizard.smtpServer). At(8, 0) - outgoing.AddChild(ui.NewFill(' ')). + outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)). At(9, 0) outgoing.AddChild( ui.NewText("Connection mode", @@ -361,9 +361,9 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { outgoing.AddChild(smtpMode).At(11, 0) selector = NewSelector([]string{"Previous", "Next"}, 1, conf.Ui). 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(ui.NewFill(' ')).At(14, 0) + outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(14, 0) outgoing.AddChild( ui.NewText("Copy sent messages to 'Sent' folder?", conf.Ui.GetStyle(config.STYLE_HEADER))).At(15, 0) diff --git a/widgets/aerc.go b/widgets/aerc.go index 350e94e..7ee2c3b 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -230,8 +230,8 @@ func (aerc *Aerc) Event(event tcell.Event) bool { aerc.statusline.Expire() aerc.pendingKeys = append(aerc.pendingKeys, config.KeyStroke{ Modifiers: event.Modifiers(), - Key: event.Key(), - Rune: event.Rune(), + Key: event.Key(), + Rune: event.Rune(), }) aerc.statusline.Invalidate() bindings := aerc.getBindings() @@ -648,8 +648,8 @@ func errorScreen(s string, conf config.UIConfig) ui.Drawable { }).Columns([]ui.GridSpec{ {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(ui.NewFill(' ')).At(2, 0) + grid.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(2, 0) return grid } diff --git a/widgets/compose.go b/widgets/compose.go index 01c6281..f4320a1 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -678,9 +678,10 @@ func (c *Composer) updateGrid() { if c.heditors != nil { c.grid.RemoveChild(c.heditors) } + borderStyle := c.config.Ui.GetStyle(config.STYLE_BORDER) c.heditors = heditors 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 { diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index 5e88790..87deac4 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -105,13 +105,15 @@ func NewMessageViewer(acct *AccountView, } } + borderStyle := acct.UiConfig().GetStyle(config.STYLE_BORDER) + grid.AddChild(header).At(0, 0) if msg.PGPDetails() != nil { 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) } else { - grid.AddChild(ui.NewFill(' ')).At(1, 0) + grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0) grid.AddChild(switcher).At(2, 0) }