Trying to get keys to the treebrowser
This commit is contained in:
@@ -2,6 +2,7 @@ package widgets
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
h "git.bullercodeworks.com/brian/expds/helpers"
|
||||
t "git.bullercodeworks.com/brian/tcell-widgets"
|
||||
@@ -104,6 +105,7 @@ func (w *TreeBrowser) GetKeyMap() *t.KeyMap { return w.keyMap }
|
||||
func (w *TreeBrowser) SetKeyMap(km *t.KeyMap) { w.keyMap = km }
|
||||
|
||||
func (w *TreeBrowser) HandleKey(ev *tcell.EventKey) bool {
|
||||
w.Log("TreeBrowser Handling Key: %s", ev.Name())
|
||||
if !w.active || !w.focusable {
|
||||
return false
|
||||
}
|
||||
@@ -139,6 +141,7 @@ func (w *TreeBrowser) Draw(screen tcell.Screen) {
|
||||
break
|
||||
}
|
||||
}
|
||||
th.DrawText(x, y, fmt.Sprintf("Cursor: %d", w.cursor), w.style, screen)
|
||||
}
|
||||
|
||||
func (w *TreeBrowser) SetStyle(s tcell.Style) { w.style = s }
|
||||
@@ -290,6 +293,9 @@ func (w *TreeBrowser) updateList() {
|
||||
if w.cursor >= len(w.list) {
|
||||
w.cursor = len(w.list) - 1
|
||||
}
|
||||
if w.cursor <= 0 {
|
||||
w.cursor = 0
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -338,3 +344,18 @@ func (tn *TreeNode) AddChild(t *TreeNode, rest ...*TreeNode) {
|
||||
tn.children = append(tn.children, rest[i])
|
||||
}
|
||||
}
|
||||
|
||||
func (tn *TreeNode) GetPath() []string {
|
||||
var path []string
|
||||
if tn.parent != nil {
|
||||
path = tn.parent.GetPath()
|
||||
}
|
||||
return append(path, tn.value)
|
||||
}
|
||||
func (tn *TreeNode) GetLabelPath() []string {
|
||||
var path []string
|
||||
if tn.parent != nil {
|
||||
path = tn.parent.GetLabelPath()
|
||||
}
|
||||
return append(path, tn.label)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user