A Golang command line dashboard

607 views
Skip to first unread message

Gizak

unread,
Mar 10, 2015, 5:11:36 PM3/10/15
to golan...@googlegroups.com
TL;DR: termui

Hi guys!

I was wondering why seems like we don't have a dashboard-like command line ui, so I made some commits and just released a Go command line dashboard termui build upon termbox-go. It is still in active developing, and APIs are subject to change!

Cheers

andrewc...@gmail.com

unread,
Mar 10, 2015, 9:34:55 PM3/10/15
to golan...@googlegroups.com
Really cool! :)

Robert Frangioso

unread,
Mar 10, 2015, 9:43:04 PM3/10/15
to andrewc...@gmail.com, Robert Frangioso, golan...@googlegroups.com
Love it! :)

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Polanski

unread,
Mar 11, 2015, 9:53:27 PM3/11/15
to golan...@googlegroups.com
awesome

michal...@gmail.com

unread,
Mar 12, 2015, 5:19:55 AM3/12/15
to golan...@googlegroups.com
lovely

Thorsten Sommer

unread,
Mar 12, 2015, 7:08:05 AM3/12/15
to golan...@googlegroups.com
Wow! Thank you very much for your work. Keep the good work.

Egon

unread,
Mar 12, 2015, 7:19:44 AM3/12/15
to golan...@googlegroups.com
Make a theme definition:

type Theme map[string]Attribute

func (t Theme) Lookup(name string) Attribute {}

Names are for example:

"bg"
"fg"
"line"
"border.fg"
"sparkline.line"
"sparkline.title.fg"

For resolving the names you start by removing the token before the last item, e.g. for resolving "sparkline.title.fg" you check for these attributes...

"sparkline.title.fg"
"sparkline.fg"
"fg"

This allows for more flexibility in defining themes and you can also that way split out the different "widgets" to separate package.

Basically it allows your themes to be composable.

+ Egon

Gizak

unread,
Mar 12, 2015, 11:16:50 AM3/12/15
to golan...@googlegroups.com
Hey, that is a good idea! Thank you for pointing out! (do you mind I put you in the contributors list after embedding this in codes?)

Egon

unread,
Mar 13, 2015, 3:22:43 AM3/13/15
to golan...@googlegroups.com
On Thursday, 12 March 2015 17:16:50 UTC+2, Gizak wrote:
Hey, that is a good idea! Thank you for pointing out! (do you mind I put you in the contributors list after embedding this in codes?)

Sure, go ahead if you like.

Also, introduce a Rect type, maybe something like:

type Rect struct {
Left, Top, Bottom, Right int
}

func NewRect(x, y int, w, h int) Rect {
return Rect{x,y,x+w,y+h }
}

func (r Rect) Inset(pad Rect) Rect {
r.Left += p.Left
r.Top += p.Top
r.Right -= p.Right
r.Bottom -= p.Bottom
}

func (r Rect) Outset(margin Rect) Rect {
r.Left -= p.Left
r.Top -= p.Top
r.Right += p.Right
r.Bottom += p.Bottom
}

type Block struct {
Rect Rect
Padding Rect
inner Rect

Border        labeledBorder
IsDisplay     bool
HasBorder     bool
BgColor       Attribute
}

Alternatively:

type Rect struct {
X, Y int
W, H int
}

type Padding struct {
Left, Top, Right, Bottom int
}

Or you can take the design of http://golang.org/pkg/image/#Rectangle

It should make some of the code nicer.

PS. regarding the theme, you may want to also try out several other designs, e.g.

"": Attributes{ "bg": Attribute{}, "fg": Attribute{}, "line": Attribute{}}
"border": Attributes{ "bg": Attribute{}, "fg": Attribute{}}
"sparkline": Attributes{ "bg": Attribute{}, "fg": Attribute{}, "line": Attribute{}}
"sparkline.title": Attributes{ "bg": Attribute{}, "fg": Attribute{}}

I don't like the "remove the token before the last item", it isn't simple mechanic... maybe explicitly defining the widget and attributes for that widget is better?

Then you would have:
func (t Theme) Lookup(widget, attr string) Attribute {}

e.g.
Lookup("sparkline.title", "bg")
Lookup("sparkline", "bg")
Lookup("", "bg")

And would remove tokens only in the widget name, 

Nilton OS

unread,
Mar 25, 2015, 9:27:57 AM3/25/15
to golan...@googlegroups.com
Cool!!!!

..............................................................................................
 Nilton OS | Linux Expert 16 years ago | linuxpro.com.br
"Cert: LPI101, ITILv3 2011"

--

Mauro Risonho de Paula Assumpção

unread,
Mar 25, 2015, 2:50:21 PM3/25/15
to Nilton OS, golang-nuts
Wow! Cool!:)

@firebitsbr

Micky

unread,
Mar 25, 2015, 6:14:42 PM3/25/15
to Gizak, golang-nuts
So sick!!!
Good job

--
B60.gif
Reply all
Reply to author
Forward
0 new messages