diff options
author | Drew DeVault <sir@cmpwn.com> | 2020-05-28 10:32:42 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-05-28 10:32:42 -0400 |
commit | caad1b2c06a0446059ee5ee916e3dce1794b159b (patch) | |
tree | ee81255485234137a5902d87d5960ac06618b341 /widgets/msgviewer.go | |
parent | 76a91813d8dc0f0011202f8120fc197097f022aa (diff) | |
download | aerc-caad1b2c06a0446059ee5ee916e3dce1794b159b.tar.gz |
Revert "Add Style configuration"
This reverts commit 0f78f06610c0e8887aba2ae50e99b86477a384b3.
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r-- | widgets/msgviewer.go | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index 6544dddd..ce859706 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -32,7 +32,6 @@ type MessageViewer struct { grid *ui.Grid switcher *PartSwitcher msg lib.MessageView - uiConfig config.UIConfig } type PartSwitcher struct { @@ -62,11 +61,9 @@ func NewMessageViewer(acct *AccountView, header, headerHeight := layout.grid( func(header string) ui.Drawable { return &HeaderView{ - conf: conf, Name: header, Value: fmtHeader(msg.MessageInfo(), header, acct.UiConfig().TimestampFormat), - uiConfig: acct.UiConfig(), } }, ) @@ -96,16 +93,15 @@ func NewMessageViewer(acct *AccountView, err := createSwitcher(acct, switcher, conf, msg) if err != nil { return &MessageViewer{ - err: err, - grid: grid, - msg: msg, - uiConfig: acct.UiConfig(), + err: err, + grid: grid, + msg: msg, } } grid.AddChild(header).At(0, 0) if msg.PGPDetails() != nil { - grid.AddChild(NewPGPInfo(msg.PGPDetails(), acct.UiConfig())).At(1, 0) + grid.AddChild(NewPGPInfo(msg.PGPDetails())).At(1, 0) grid.AddChild(ui.NewFill(' ')).At(2, 0) grid.AddChild(switcher).At(3, 0) } else { @@ -119,7 +115,6 @@ func NewMessageViewer(acct *AccountView, grid: grid, msg: msg, switcher: switcher, - uiConfig: acct.UiConfig(), } switcher.mv = mv @@ -228,9 +223,8 @@ func createSwitcher(acct *AccountView, switcher *PartSwitcher, func (mv *MessageViewer) Draw(ctx *ui.Context) { if mv.err != nil { - style := mv.acct.UiConfig().GetStyle(config.STYLE_DEFAULT) - ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style) - ctx.Printf(0, 0, style, "%s", mv.err.Error()) + ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault) + ctx.Printf(0, 0, tcell.StyleDefault, "%s", mv.err.Error()) return } mv.grid.Draw(ctx) @@ -352,10 +346,7 @@ func (ps *PartSwitcher) Draw(ctx *ui.Context) { ps.height = ctx.Height() y := ctx.Height() - height for i, part := range ps.parts { - style := ps.mv.uiConfig.GetStyle(config.STYLE_DEFAULT) - if ps.selected == i { - style = ps.mv.uiConfig.GetStyleSelected(config.STYLE_DEFAULT) - } + style := tcell.StyleDefault.Reverse(ps.selected == i) ctx.Fill(0, y+i, ctx.Width(), 1, ' ', style) name := fmt.Sprintf("%s/%s", strings.ToLower(part.part.MIMEType), @@ -444,7 +435,6 @@ func (mv *MessageViewer) Focus(focus bool) { type PartViewer struct { ui.Invalidatable - conf *config.AercConfig err error fetched bool filter *exec.Cmd @@ -459,7 +449,6 @@ type PartViewer struct { term *Terminal selecter *Selecter grid *ui.Grid - uiConfig config.UIConfig } func NewPartViewer(acct *AccountView, conf *config.AercConfig, @@ -529,8 +518,7 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig, {ui.SIZE_WEIGHT, 1}, }) - selecter := NewSelecter([]string{"Save message", "Pipe to command"}, - 0, acct.UiConfig()). + selecter := NewSelecter([]string{"Save message", "Pipe to command"}, 0). OnChoose(func(option string) { switch option { case "Save message": @@ -543,7 +531,6 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig, grid.AddChild(selecter).At(2, 0) pv := &PartViewer{ - conf: conf, filter: filter, index: index, msg: msg, @@ -555,7 +542,6 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig, term: term, selecter: selecter, grid: grid, - uiConfig: acct.UiConfig(), } if term != nil { @@ -653,16 +639,14 @@ func (pv *PartViewer) Invalidate() { } func (pv *PartViewer) Draw(ctx *ui.Context) { - style := pv.uiConfig.GetStyle(config.STYLE_DEFAULT) - styleError := pv.uiConfig.GetStyle(config.STYLE_ERROR) if pv.filter == nil { // TODO: Let them download it directly or something - ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style) - ctx.Printf(0, 0, styleError, + ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault) + ctx.Printf(0, 0, tcell.StyleDefault.Foreground(tcell.ColorRed), "No filter configured for this mimetype ('%s/%s')", pv.part.MIMEType, pv.part.MIMESubType, ) - ctx.Printf(0, 2, style, + ctx.Printf(0, 2, tcell.StyleDefault, "You can still :save the message or :pipe it to an external command") pv.selecter.Focus(true) pv.grid.Draw(ctx) @@ -673,8 +657,8 @@ func (pv *PartViewer) Draw(ctx *ui.Context) { pv.fetched = true } if pv.err != nil { - ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style) - ctx.Printf(0, 0, style, "%s", pv.err.Error()) + ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault) + ctx.Printf(0, 0, tcell.StyleDefault, "%s", pv.err.Error()) return } pv.term.Draw(ctx) @@ -696,10 +680,8 @@ func (pv *PartViewer) Event(event tcell.Event) bool { type HeaderView struct { ui.Invalidatable - conf *config.AercConfig - Name string - Value string - uiConfig config.UIConfig + Name string + Value string } func (hv *HeaderView) Draw(ctx *ui.Context) { @@ -707,15 +689,18 @@ func (hv *HeaderView) Draw(ctx *ui.Context) { size := runewidth.StringWidth(name) lim := ctx.Width() - size - 1 value := runewidth.Truncate(" "+hv.Value, lim, "…") - - vstyle := hv.uiConfig.GetStyle(config.STYLE_DEFAULT) - hstyle := hv.uiConfig.GetStyle(config.STYLE_HEADER) - + var ( + hstyle tcell.Style + vstyle tcell.Style + ) // TODO: Make this more robust and less dumb if hv.Name == "PGP" { - vstyle = hv.uiConfig.GetStyle(config.STYLE_SUCCESS) + vstyle = tcell.StyleDefault.Foreground(tcell.ColorGreen) + hstyle = tcell.StyleDefault.Bold(true) + } else { + vstyle = tcell.StyleDefault + hstyle = tcell.StyleDefault.Bold(true) } - ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', vstyle) ctx.Printf(0, 0, hstyle, "%s", name) ctx.Printf(size, 0, vstyle, "%s", value) |