viewer: add colon after header names

Display them as standard RFC 822 headers.

Signed-off-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Robin Jarry 2021-11-05 10:34:10 +01:00
parent b1daf08991
commit 20752df89c
2 changed files with 4 additions and 4 deletions

View file

@ -773,11 +773,11 @@ func (he *headerEditor) setValue(val string) {
func (he *headerEditor) Draw(ctx *ui.Context) { func (he *headerEditor) Draw(ctx *ui.Context) {
name := textproto.CanonicalMIMEHeaderKey(he.name) name := textproto.CanonicalMIMEHeaderKey(he.name)
// Extra character to put a blank cell between the header and the input // Extra character to put a blank cell between the header and the input
size := runewidth.StringWidth(name) + 1 size := runewidth.StringWidth(name+":") + 1
defaultStyle := he.uiConfig.GetStyle(config.STYLE_DEFAULT) defaultStyle := he.uiConfig.GetStyle(config.STYLE_DEFAULT)
headerStyle := he.uiConfig.GetStyle(config.STYLE_HEADER) headerStyle := he.uiConfig.GetStyle(config.STYLE_HEADER)
ctx.Fill(0, 0, size, ctx.Height(), ' ', defaultStyle) ctx.Fill(0, 0, size, ctx.Height(), ' ', defaultStyle)
ctx.Printf(0, 0, headerStyle, "%s", name) ctx.Printf(0, 0, headerStyle, "%s:", name)
he.input.Draw(ctx.Subcontext(size, 0, ctx.Width()-size, 1)) he.input.Draw(ctx.Subcontext(size, 0, ctx.Width()-size, 1))
} }

View file

@ -731,7 +731,7 @@ type HeaderView struct {
func (hv *HeaderView) Draw(ctx *ui.Context) { func (hv *HeaderView) Draw(ctx *ui.Context) {
name := hv.Name name := hv.Name
size := runewidth.StringWidth(name) size := runewidth.StringWidth(name + ":")
lim := ctx.Width() - size - 1 lim := ctx.Width() - size - 1
value := runewidth.Truncate(" "+hv.Value, lim, "…") value := runewidth.Truncate(" "+hv.Value, lim, "…")
@ -744,7 +744,7 @@ func (hv *HeaderView) Draw(ctx *ui.Context) {
} }
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', vstyle) ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', vstyle)
ctx.Printf(0, 0, hstyle, "%s", name) ctx.Printf(0, 0, hstyle, "%s:", name)
ctx.Printf(size, 0, vstyle, "%s", value) ctx.Printf(size, 0, vstyle, "%s", value)
} }