mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
parent
fe1be27ea7
commit
5beaeb6328
|
|
@ -229,7 +229,7 @@ func doSelectAll(i *Input, _ termbox.Event) {
|
|||
i.selection.Remove(l)
|
||||
}
|
||||
}
|
||||
i.SendDraw()
|
||||
i.SendDraw(false)
|
||||
}
|
||||
|
||||
func doSelectVisible(i *Input, _ termbox.Event) {
|
||||
|
|
@ -246,7 +246,7 @@ func doSelectVisible(i *Input, _ termbox.Event) {
|
|||
l.SetDirty(true)
|
||||
i.selection.Add(l)
|
||||
}
|
||||
i.SendDraw()
|
||||
i.SendDraw(false)
|
||||
}
|
||||
|
||||
func doFinish(i *Input, _ termbox.Event) {
|
||||
|
|
@ -345,7 +345,7 @@ func doInvertSelection(i *Input, _ termbox.Event) {
|
|||
return true
|
||||
})
|
||||
|
||||
i.SendDraw()
|
||||
i.SendDraw(false)
|
||||
}
|
||||
|
||||
func doDeleteBackwardWord(i *Input, _ termbox.Event) {
|
||||
|
|
|
|||
2
cli.go
2
cli.go
|
|
@ -220,7 +220,7 @@ func (cli *CLI) Run() error {
|
|||
ctx.SetQuery([]rune(opts.OptQuery))
|
||||
ctx.ExecQuery()
|
||||
} else {
|
||||
ctx.SendDraw()
|
||||
ctx.SendDraw(false)
|
||||
}
|
||||
|
||||
ctx.WaitDone()
|
||||
|
|
|
|||
8
ctx.go
8
ctx.go
|
|
@ -418,21 +418,21 @@ func (c Ctx) GetRawLineBufferSize() int {
|
|||
|
||||
func (c *Ctx) ResetActiveLineBuffer() {
|
||||
c.rawLineBuffer.Replay()
|
||||
c.SetActiveLineBuffer(c.rawLineBuffer)
|
||||
c.SetActiveLineBuffer(c.rawLineBuffer, false)
|
||||
}
|
||||
|
||||
func (c *Ctx) SetActiveLineBuffer(l *RawLineBuffer) {
|
||||
func (c *Ctx) SetActiveLineBuffer(l *RawLineBuffer, runningQuery bool) {
|
||||
c.activeLineBuffer = l
|
||||
|
||||
go func(l *RawLineBuffer) {
|
||||
prev := time.Time{}
|
||||
for _ = range l.OutputCh() {
|
||||
if time.Since(prev) > time.Millisecond {
|
||||
c.SendDraw()
|
||||
c.SendDraw(runningQuery)
|
||||
prev = time.Now()
|
||||
}
|
||||
}
|
||||
c.SendDraw()
|
||||
c.SendDraw(runningQuery)
|
||||
}(l)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ func (f *Filter) Work(cancel chan struct{}, q HubReq) {
|
|||
buf.onEnd = func() { f.SendStatusMsg("") }
|
||||
buf.Accept(filter)
|
||||
|
||||
f.SetActiveLineBuffer(buf)
|
||||
f.SetActiveLineBuffer(buf, true)
|
||||
}
|
||||
|
||||
if ! f.config.StickySelection {
|
||||
|
|
|
|||
4
hub.go
4
hub.go
|
|
@ -123,11 +123,11 @@ func (h *Hub) SendDrawPrompt() {
|
|||
}
|
||||
|
||||
// SendDraw sends a request to redraw the terminal display
|
||||
func (h *Hub) SendDraw() {
|
||||
func (h *Hub) SendDraw(runningQuery bool) {
|
||||
trace("Hub.SendDraw: START")
|
||||
defer trace("Hub.SendDraw: END")
|
||||
// to make sure interface is nil, I need to EXPLICITLY set nil
|
||||
req := HubReq{nil, nil}
|
||||
req := HubReq{runningQuery, nil}
|
||||
send(h.DrawCh(), req, h.isSync)
|
||||
}
|
||||
|
||||
|
|
|
|||
2
input.go
2
input.go
|
|
@ -40,7 +40,7 @@ func (i *Input) handleInputEvent(ev termbox.Event) {
|
|||
case termbox.EventError:
|
||||
//update = false
|
||||
case termbox.EventResize:
|
||||
i.SendDraw()
|
||||
i.SendDraw(false)
|
||||
case termbox.EventKey:
|
||||
// ModAlt is a sequence of letters with a leading \x1b (=Esc).
|
||||
// It would be nice if termbox differentiated this for us, but
|
||||
|
|
|
|||
40
layout.go
40
layout.go
|
|
@ -75,7 +75,7 @@ func IsValidVerticalAnchor(anchor VerticalAnchor) bool {
|
|||
type Layout interface {
|
||||
PrintStatus(string, time.Duration)
|
||||
DrawPrompt()
|
||||
DrawScreen()
|
||||
DrawScreen(bool)
|
||||
MovePage(PagingRequest) (moved bool)
|
||||
}
|
||||
|
||||
|
|
@ -373,30 +373,36 @@ func (l *ListArea) SetDirty(dirty bool) {
|
|||
}
|
||||
|
||||
// Draw displays the ListArea on the screen
|
||||
func (l *ListArea) Draw(parent Layout, perPage int) {
|
||||
func (l *ListArea) Draw(parent Layout, perPage int, runningQuery bool) {
|
||||
trace("ListArea.Draw: START")
|
||||
defer trace("ListArea.Draw: END")
|
||||
currentPage := l.currentPage
|
||||
|
||||
linebuf := l.GetCurrentLineBuffer()
|
||||
bufsiz := linebuf.Size()
|
||||
page := currentPage.page
|
||||
for ; page > 1; {
|
||||
if (currentPage.perPage * (page - 1) < bufsiz) &&
|
||||
(currentPage.perPage * page) >= bufsiz {
|
||||
break
|
||||
}
|
||||
|
||||
page--;
|
||||
}
|
||||
if currentPage.page != page {
|
||||
currentPage.page = page
|
||||
parent.DrawPrompt()
|
||||
// Should only get into this clause if we are RUNNING A QUERY.
|
||||
// regular paging shouldn't be affected.
|
||||
if runningQuery {
|
||||
bufsiz := linebuf.Size()
|
||||
page := currentPage.page
|
||||
|
||||
for ; page > 1; {
|
||||
if (currentPage.perPage * (page - 1) < bufsiz) &&
|
||||
(currentPage.perPage * page) >= bufsiz {
|
||||
break
|
||||
}
|
||||
|
||||
page--;
|
||||
}
|
||||
if currentPage.page != page {
|
||||
currentPage.page = page
|
||||
parent.DrawPrompt()
|
||||
}
|
||||
}
|
||||
|
||||
pf := PageCrop{perPage: currentPage.perPage, currentPage: currentPage.page}
|
||||
buf := pf.Crop(linebuf)
|
||||
bufsiz = buf.Size()
|
||||
bufsiz := buf.Size()
|
||||
|
||||
// previously drawn lines are cached. first, truncate the cache
|
||||
// to current size of the drawable area
|
||||
|
|
@ -584,7 +590,7 @@ func (l *BasicLayout) DrawPrompt() {
|
|||
}
|
||||
|
||||
// DrawScreen draws the entire screen
|
||||
func (l *BasicLayout) DrawScreen() {
|
||||
func (l *BasicLayout) DrawScreen(runningQuery bool) {
|
||||
trace("DrawScreen: START")
|
||||
defer trace("DrawScreen: END")
|
||||
|
||||
|
|
@ -595,7 +601,7 @@ func (l *BasicLayout) DrawScreen() {
|
|||
}
|
||||
|
||||
l.DrawPrompt()
|
||||
l.list.Draw(l, perPage)
|
||||
l.list.Draw(l, perPage, runningQuery)
|
||||
|
||||
if err := screen.Flush(); err != nil {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func (b *BufferReader) Loop() {
|
|||
|
||||
refresh = time.AfterFunc(100*time.Millisecond, func() {
|
||||
if !b.ExecQuery() {
|
||||
b.SendDraw()
|
||||
b.SendDraw(false)
|
||||
}
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
|
|
|||
17
view.go
17
view.go
|
|
@ -53,12 +53,15 @@ func (v *View) Loop() {
|
|||
r.Done()
|
||||
case lines := <-v.DrawCh():
|
||||
tmp := lines.DataInterface()
|
||||
if name, ok := tmp.(string); ok {
|
||||
if name == "prompt" {
|
||||
switch tmp.(type) {
|
||||
case string:
|
||||
if tmp.(string) == "prompt" {
|
||||
v.drawPrompt()
|
||||
}
|
||||
} else {
|
||||
v.drawScreen()
|
||||
case bool:
|
||||
v.drawScreen(tmp.(bool))
|
||||
default:
|
||||
v.drawScreen(false)
|
||||
}
|
||||
lines.Done()
|
||||
}
|
||||
|
|
@ -69,10 +72,10 @@ func (v *View) printStatus(r StatusMsgRequest) {
|
|||
v.layout.PrintStatus(r.message, r.clearDelay)
|
||||
}
|
||||
|
||||
func (v *View) drawScreen() {
|
||||
func (v *View) drawScreen(runningQuery bool) {
|
||||
v.mutex.Lock()
|
||||
defer v.mutex.Unlock()
|
||||
v.layout.DrawScreen()
|
||||
v.layout.DrawScreen(runningQuery)
|
||||
}
|
||||
|
||||
func (v *View) drawPrompt() {
|
||||
|
|
@ -86,6 +89,6 @@ func (v *View) movePage(p PagingRequest) {
|
|||
defer v.mutex.Unlock()
|
||||
|
||||
if v.layout.MovePage(p) {
|
||||
v.layout.DrawScreen()
|
||||
v.layout.DrawScreen(false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue