From a33af0476e312afe0954ac4740a4c2a75b6f6812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Mon, 27 Feb 2023 00:04:57 +0100 Subject: [PATCH] message box --- colors.go | 1 + main.go | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/colors.go b/colors.go index b571fa4..439e3c6 100644 --- a/colors.go +++ b/colors.go @@ -13,6 +13,7 @@ var ( styleWhiteBold = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorWhite).Bold(true) styleBrown = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.Color94) styleBrownBold = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.Color94).Bold(true) + styleGray = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorGray) ) // TODO: check supported number of colors diff --git a/main.go b/main.go index 9ce362e..0eb6f1d 100644 --- a/main.go +++ b/main.go @@ -49,8 +49,22 @@ func main() { log.Panicln(err.Error()) } - // TODO: draw message - // -m, --message=STR Attach message next to the tree + if opts.message != "" { + // upper border + sc.x = int(opts.msgX) + sc.y = int(opts.msgY) + sc.draw("+"+strings.Repeat("-", len(opts.message)+2)+"+", styleGray) + // center with message and front- and back-border + sc.x = int(opts.msgX) + sc.y = int(opts.msgY) + 1 + sc.draw("| ", styleGray) + sc.draw(opts.message, styleDefault) + sc.draw(" |", styleGray) + // lower border + sc.x = int(opts.msgX) + sc.y = int(opts.msgY) + 2 + sc.draw("+"+strings.Repeat("-", len(opts.message)+2)+"+", styleGray) + } // refresh screen evDrawn(sc)