From 0197300b1858d528139d6355a1358cfd43d0ccbd Mon Sep 17 00:00:00 2001 From: erroneousboat Date: Fri, 30 Mar 2018 15:55:29 +0200 Subject: [PATCH] Add loading screen --- context/context.go | 3 +++ views/load.go | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 views/load.go diff --git a/context/context.go b/context/context.go index 8638771..16f871d 100644 --- a/context/context.go +++ b/context/context.go @@ -37,6 +37,9 @@ func CreateAppContext(flgConfig string, flgDebug bool) (*AppContext, error) { }() } + // Loading screen + views.Loading() + // Load config config, err := config.NewConfig(flgConfig) if err != nil { diff --git a/views/load.go b/views/load.go new file mode 100644 index 0000000..93c6a0d --- /dev/null +++ b/views/load.go @@ -0,0 +1,21 @@ +package views + +import ( + termbox "github.com/nsf/termbox-go" +) + +func Loading() { + const loading string = "LOADING" + + w, h := termbox.Size() + termbox.Clear(termbox.ColorDefault, termbox.ColorDefault) + + offset := (w / 2) - (len(loading) / 2) + y := h / 2 + + for x := 0; x < len(loading); x++ { + termbox.SetCell(offset+x, y, rune(loading[x]), termbox.ColorDefault, termbox.ColorDefault) + } + + termbox.Flush() +}