Working on buffer stuff...
Trying to figure out how/if it fits...
This commit is contained in:
@@ -33,8 +33,10 @@ type Searcher struct {
|
||||
id string
|
||||
style tcell.Style
|
||||
|
||||
x, y int
|
||||
w, h int
|
||||
x, y int
|
||||
w, h int
|
||||
buffer Buffer
|
||||
|
||||
active bool
|
||||
visible bool
|
||||
focusable bool
|
||||
@@ -94,6 +96,7 @@ func (w *Searcher) HandleResize(ev *tcell.EventResize) {
|
||||
}
|
||||
w.search.SetPos(Coord{X: 1, Y: 1})
|
||||
w.search.HandleResize(Coord{X: aW, Y: aH}.ResizeEvent())
|
||||
// w.buildBuffer()
|
||||
}
|
||||
|
||||
func (w *Searcher) SetKeyMap(km KeyMap, def bool) {
|
||||
@@ -126,7 +129,11 @@ func (w *Searcher) HandleKey(ev *tcell.EventKey) bool {
|
||||
if w.cursor != sel && w.onChange != nil {
|
||||
w.onChange(w.cursor, w.filteredData[w.cursor])
|
||||
}
|
||||
return b1 || b2 || ret
|
||||
if b1 || b2 || ret {
|
||||
// w.buildBuffer()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *Searcher) handleKeyUp(ev *tcell.EventKey) bool {
|
||||
@@ -134,6 +141,7 @@ func (w *Searcher) handleKeyUp(ev *tcell.EventKey) bool {
|
||||
return false
|
||||
}
|
||||
w.cursor = ((w.cursor - 1) + len(w.filteredData)) % len(w.filteredData)
|
||||
// w.buildBuffer()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -142,6 +150,7 @@ func (w *Searcher) handleKeyDown(ev *tcell.EventKey) bool {
|
||||
return false
|
||||
}
|
||||
w.cursor = ((w.cursor + 1) + len(w.filteredData)) % len(w.filteredData)
|
||||
// w.buildBuffer()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -150,6 +159,7 @@ func (w *Searcher) handleKeyHome(ev *tcell.EventKey) bool {
|
||||
return false
|
||||
}
|
||||
w.cursor = 0
|
||||
// w.buildBuffer()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -158,6 +168,7 @@ func (w *Searcher) handleKeyEnd(ev *tcell.EventKey) bool {
|
||||
return false
|
||||
}
|
||||
w.cursor = len(w.filteredData) - 1
|
||||
// w.buildBuffer()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -169,8 +180,8 @@ func (w *Searcher) handleKeyPgUp(ev *tcell.EventKey) bool {
|
||||
if w.cursor < 0 {
|
||||
w.cursor = 0
|
||||
}
|
||||
|
||||
return false
|
||||
// w.buildBuffer()
|
||||
return true
|
||||
}
|
||||
|
||||
func (w *Searcher) handleKeyPgDn(ev *tcell.EventKey) bool {
|
||||
@@ -182,7 +193,8 @@ func (w *Searcher) handleKeyPgDn(ev *tcell.EventKey) bool {
|
||||
if w.cursor > mx {
|
||||
w.cursor = mx
|
||||
}
|
||||
return false
|
||||
// w.buildBuffer()
|
||||
return true
|
||||
}
|
||||
|
||||
func (w *Searcher) handleKeyEnter(ev *tcell.EventKey) bool {
|
||||
@@ -200,7 +212,9 @@ func (w *Searcher) handleKeyEnter(ev *tcell.EventKey) bool {
|
||||
idx = i
|
||||
}
|
||||
}
|
||||
return w.selectFunc(idx, selV)
|
||||
res := w.selectFunc(idx, selV)
|
||||
// w.buildBuffer()
|
||||
return res
|
||||
}
|
||||
|
||||
func (w *Searcher) HandleTime(ev *tcell.EventTime) { w.search.HandleTime(ev) }
|
||||
@@ -208,6 +222,11 @@ func (w *Searcher) Draw(screen tcell.Screen) {
|
||||
if !w.visible {
|
||||
return
|
||||
}
|
||||
w.oldDraw(screen)
|
||||
// w.buffer.Draw(w.x, w.y, screen)
|
||||
}
|
||||
|
||||
func (w *Searcher) oldDraw(screen tcell.Screen) {
|
||||
dStyle := w.style.Dim(!w.active)
|
||||
if !w.disableBorder {
|
||||
if len(w.title) > 0 {
|
||||
@@ -216,7 +235,7 @@ func (w *Searcher) Draw(screen tcell.Screen) {
|
||||
wh.BorderFilled(w.x, w.y, w.x+w.w, w.y+w.h, wh.BRD_CSIMPLE, dStyle, screen)
|
||||
}
|
||||
}
|
||||
//w.GetPos().DrawOffset(w.search, screen)
|
||||
// w.GetPos().DrawOffset(w.search, screen)
|
||||
x, y := w.x+1, w.y+2
|
||||
w.search.SetPos(Coord{X: w.x + 1, Y: w.y + 1})
|
||||
w.search.Draw(screen)
|
||||
@@ -242,6 +261,20 @@ func (w *Searcher) Draw(screen tcell.Screen) {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Searcher) buildBuffer() {
|
||||
b := NewBuffer()
|
||||
dStyle := w.style.Dim(!w.active)
|
||||
if !w.disableBorder {
|
||||
if len(w.title) > 0 {
|
||||
w.buffer.TitledBorderFilled(0, 0, w.w, w.y, w.title, wh.BRD_CSIMPLE, dStyle)
|
||||
} else {
|
||||
w.buffer.BorderFilled(0, 0, w.w, w.y, wh.BRD_CSIMPLE, dStyle)
|
||||
}
|
||||
}
|
||||
// x, y := 1, 1
|
||||
w.buffer = b
|
||||
}
|
||||
|
||||
func (w *Searcher) Active() bool { return w.active }
|
||||
func (w *Searcher) SetActive(a bool) {
|
||||
w.active = a
|
||||
|
||||
Reference in New Issue
Block a user