Some work
This commit is contained in:
@@ -130,7 +130,6 @@ func (w *LinearLayout) HandleKey(ev *tcell.EventKey) bool {
|
||||
}
|
||||
active := w.findActive()
|
||||
if active != nil {
|
||||
w.Log("LL(%s) Active(%s) Handlekey", w.Id(), active.Id())
|
||||
if active.HandleKey(ev) {
|
||||
return true
|
||||
}
|
||||
@@ -504,6 +503,7 @@ func (w *LinearLayout) updateLLHWidgetSize(wd Widget) {
|
||||
if w.stacked {
|
||||
rH = wd.MinH()
|
||||
}
|
||||
w.Log("(%s) Resize (%s): X:%d, Y:%d", w.Id(), wd.Id(), w.getWeightedW(wd), rH)
|
||||
wd.HandleResize((&Coord{X: w.getWeightedW(wd), Y: rH}).ResizeEvent())
|
||||
}
|
||||
|
||||
@@ -562,6 +562,11 @@ func (w *LinearLayout) updateLLVWidgetPos(wd Widget) {
|
||||
}
|
||||
|
||||
func (w *LinearLayout) updateLLHWidgetPos(wd Widget) {
|
||||
debug := func(wd Widget, txt string, args ...any) {
|
||||
if wd.Id() == "mngenc.selectadversary" {
|
||||
w.Log(txt, args...)
|
||||
}
|
||||
}
|
||||
c := Coord{}
|
||||
for i := range w.widgets {
|
||||
if w.widgets[i] == wd {
|
||||
@@ -572,6 +577,7 @@ func (w *LinearLayout) updateLLHWidgetPos(wd Widget) {
|
||||
}
|
||||
if w.widgets[i].Visible() {
|
||||
c.X = w.widgets[i].GetX() + w.widgets[i].GetW()
|
||||
debug(wd, "Bumping X: %d + %d = %d", w.widgets[i].GetX(), w.widgets[i].GetW(), c.X)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,6 +614,7 @@ func (w *LinearLayout) updateLLHWidgetPos(wd Widget) {
|
||||
c.X += 1
|
||||
c.Y += 1
|
||||
}
|
||||
w.Log("(%s) SetPos (%s): X:%d, Y:%d", w.Id(), wd.Id(), c.X, c.Y)
|
||||
wd.SetPos(c)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ type Searcher struct {
|
||||
search *Field
|
||||
data []string
|
||||
filteredData []string
|
||||
filteredToTrue map[int]int
|
||||
cursor int
|
||||
disableBorder bool
|
||||
|
||||
@@ -84,6 +85,7 @@ func (w *Searcher) Init(id string, style tcell.Style) {
|
||||
})
|
||||
w.customKeyMap = BlankKeyMap()
|
||||
w.focusable = true
|
||||
w.filteredToTrue = make(map[int]int)
|
||||
}
|
||||
|
||||
func (w *Searcher) Id() string { return w.id }
|
||||
@@ -332,6 +334,7 @@ func (w *Searcher) SetData(data []string) {
|
||||
func (w *Searcher) updateFilter() {
|
||||
var selVal string
|
||||
data := []string{}
|
||||
w.filteredToTrue = make(map[int]int)
|
||||
copy(data, w.filteredData)
|
||||
if len(data) > 0 && len(data) > w.cursor {
|
||||
selVal = data[w.cursor]
|
||||
@@ -342,10 +345,12 @@ func (w *Searcher) updateFilter() {
|
||||
for i := range w.data {
|
||||
if cS {
|
||||
if strings.Contains(w.data[i], filter) {
|
||||
w.filteredToTrue[len(w.filteredData)] = i
|
||||
w.filteredData = append(w.filteredData, w.data[i])
|
||||
}
|
||||
} else {
|
||||
if strings.Contains(strings.ToLower(w.data[i]), filter) {
|
||||
w.filteredToTrue[len(w.filteredData)] = i
|
||||
w.filteredData = append(w.filteredData, w.data[i])
|
||||
}
|
||||
}
|
||||
@@ -379,7 +384,12 @@ func (w *Searcher) doChange() {
|
||||
return
|
||||
}
|
||||
if w.cursor < l {
|
||||
w.onChange(w.cursor, w.filteredData[w.cursor])
|
||||
tr, ok := w.filteredToTrue[w.cursor]
|
||||
if !ok {
|
||||
// How did we get here?
|
||||
return
|
||||
}
|
||||
w.onChange(tr, w.data[tr])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ THE SOFTWARE.
|
||||
package widgets
|
||||
|
||||
import (
|
||||
h "git.bullercodeworks.com/brian/tcell-widgets/helpers"
|
||||
wh "git.bullercodeworks.com/brian/tcell-widgets/helpers"
|
||||
"github.com/gdamore/tcell"
|
||||
)
|
||||
@@ -235,9 +236,7 @@ func (w *SimpleList) WantH() int {
|
||||
|
||||
func (w *SimpleList) MinW() int {
|
||||
lng := wh.Longest(w.list)
|
||||
if lng > 80 {
|
||||
lng = 80
|
||||
}
|
||||
lng = h.Min(lng, 80)
|
||||
return 2 + lng
|
||||
}
|
||||
|
||||
@@ -252,6 +251,9 @@ func (w *SimpleList) MoveUp() bool {
|
||||
}
|
||||
return true
|
||||
} else if w.cursorWrap {
|
||||
if w.cursor <= 0 {
|
||||
return false
|
||||
}
|
||||
w.cursor = len(w.list) - 1
|
||||
if w.onChange != nil {
|
||||
w.onChange(w.cursor, w.list[w.cursor])
|
||||
@@ -270,7 +272,7 @@ func (w *SimpleList) MoveDown() bool {
|
||||
return true
|
||||
} else if w.cursorWrap {
|
||||
w.cursor = 0
|
||||
if w.onChange != nil {
|
||||
if len(w.list) > w.cursor && w.onChange != nil {
|
||||
w.onChange(w.cursor, w.list[w.cursor])
|
||||
}
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user