remove export of grid methods

This commit is contained in:
Bradley Cicenas 2017-01-02 20:14:35 +00:00
parent 68d2207cb1
commit 157b51b6f6

28
grid.go
View File

@ -24,7 +24,7 @@ func NewGrid() *Grid {
} }
// Return current cursor index // Return current cursor index
func (g *Grid) CursorIdx() int { func (g *Grid) cursorIdx() int {
for n, c := range g.containers { for n, c := range g.containers {
if c.id == g.cursorID { if c.id == g.cursorID {
return n return n
@ -33,26 +33,26 @@ func (g *Grid) CursorIdx() int {
return 0 return 0
} }
func (g *Grid) CursorUp() { func (g *Grid) cursorUp() {
idx := g.CursorIdx() idx := g.cursorIdx()
// decrement if possible // decrement if possible
if idx > 0 { if idx > 0 {
g.cursorID = g.containers[idx-1].id g.cursorID = g.containers[idx-1].id
g.RedrawCursor() g.redrawCursor()
} }
} }
func (g *Grid) CursorDown() { func (g *Grid) cursorDown() {
idx := g.CursorIdx() idx := g.cursorIdx()
// increment if possible // increment if possible
if idx < (len(g.containers) - 1) { if idx < (len(g.containers) - 1) {
g.cursorID = g.containers[idx+1].id g.cursorID = g.containers[idx+1].id
g.RedrawCursor() g.redrawCursor()
} }
} }
// Redraw the cursor with the currently selected row // Redraw the cursor with the currently selected row
func (g *Grid) RedrawCursor() { func (g *Grid) redrawCursor() {
for _, c := range g.containers { for _, c := range g.containers {
if c.id == g.cursorID { if c.id == g.cursorID {
c.widgets.name.TextFgColor = ui.ColorDefault c.widgets.name.TextFgColor = ui.ColorDefault
@ -65,12 +65,12 @@ func (g *Grid) RedrawCursor() {
} }
} }
func (g *Grid) Redraw() { func (g *Grid) redrawRows() {
// reinit body rows // reinit body rows
ui.Body.Rows = []*ui.Row{} ui.Body.Rows = []*ui.Row{}
// build layout // build layout
ui.Body.AddRows(header()) ui.Body.AddRows(header())
for _, c := range g.containers { for _, c := range g.containers {
ui.Body.AddRows(c.widgets.MakeRow()) ui.Body.AddRows(c.widgets.MakeRow())
} }
@ -116,14 +116,14 @@ func Display(g *Grid) bool {
// calculate layout // calculate layout
ui.Body.Align() ui.Body.Align()
g.RedrawCursor() g.redrawCursor()
ui.Render(ui.Body) ui.Render(ui.Body)
ui.Handle("/sys/kbd/<up>", func(ui.Event) { ui.Handle("/sys/kbd/<up>", func(ui.Event) {
g.CursorUp() g.cursorUp()
}) })
ui.Handle("/sys/kbd/<down>", func(ui.Event) { ui.Handle("/sys/kbd/<down>", func(ui.Event) {
g.CursorDown() g.cursorDown()
}) })
ui.Handle("/sys/kbd/h", func(ui.Event) { ui.Handle("/sys/kbd/h", func(ui.Event) {
newView = views.Help newView = views.Help
@ -134,7 +134,7 @@ func Display(g *Grid) bool {
}) })
ui.Handle("/timer/1s", func(e ui.Event) { ui.Handle("/timer/1s", func(e ui.Event) {
g.containers = g.containerMap.Sorted() // refresh containers for current sort order g.containers = g.containerMap.Sorted() // refresh containers for current sort order
g.Redraw() g.redrawRows()
}) })
ui.Handle("/sys/wnd/resize", func(e ui.Event) { ui.Handle("/sys/wnd/resize", func(e ui.Event) {