Skip to content

Commit

Permalink
feat(gui): add a figlet banner with the name of the app as text
Browse files Browse the repository at this point in the history
  • Loading branch information
danvergara committed May 5, 2021
1 parent 5d0ec06 commit a46bf17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module github.com/danvergara/dblab
go 1.16

require (
github.com/bxcodec/faker/v3 v3.6.0 // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/bxcodec/faker/v3 v3.6.0
github.com/common-nighthawk/go-figure v0.0.0-20200609044655-c4b36f998cf2
github.com/fatih/color v1.10.0
github.com/go-sql-driver/mysql v1.6.0
github.com/golang-migrate/migrate/v4 v4.14.1
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/cockroach-go v0.0.0-20190925194419-606b3d062051/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk=
github.com/common-nighthawk/go-figure v0.0.0-20200609044655-c4b36f998cf2 h1:tjT4Jp4gxECvsJcYpAMtW2I3YqzBTPuB67OejxXs86s=
github.com/common-nighthawk/go-figure v0.0.0-20200609044655-c4b36f998cf2/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
github.com/containerd/containerd v1.4.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.1 h1:pASeJT3R3YyVn+94qEPk0SnU1OQ20Jd/T+SPKy9xehY=
github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
Expand Down
12 changes: 11 additions & 1 deletion pkg/gui/layout.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package gui

import (
"fmt"

"github.com/common-nighthawk/go-figure"
"github.com/jroimartin/gocui"
)

// Layout is called for every screen re-render e.g. when the screen is resized.
func (gui *Gui) layout(g *gocui.Gui) error {
maxX, maxY := gui.g.Size()

if v, err := gui.g.SetView("tables", 0, 0, int(0.2*float32(maxX)), maxY-5); err != nil {
if v, err := g.SetView("banner", 0, 0, int(0.2*float32(maxX)), maxY-7); err != nil {
myFigure := figure.NewFigure("dblab", "", true)
figure.Write(v, myFigure)
}

if v, err := gui.g.SetView("tables", 0, 7, int(0.2*float32(maxX)), maxY-5); err != nil {
if err != gocui.ErrUnknownView {
return err
}
Expand Down Expand Up @@ -40,6 +48,8 @@ func (gui *Gui) layout(g *gocui.Gui) error {
return err
}

fmt.Fprintln(v, "Type the sql query above. Press Ctrl-c to quit.")

v.Title = "Rows"
}

Expand Down

0 comments on commit a46bf17

Please sign in to comment.