Example #1
0
func (v *View) movePage(p hub.Payload, r PagingRequest) {
	defer p.Done()

	if v.layout.MovePage(v.state, r) {
		v.layout.DrawScreen(v.state, false)
	}
}
Example #2
0
// Work is the actual work horse that that does the matching
// in a goroutine of its own. It wraps Matcher.Match().
func (f *Filter) Work(ctx context.Context, q hub.Payload) {
	defer q.Done()

	query, ok := q.Data().(string)
	if !ok {
		return
	}

	if pdebug.Enabled {
		g := pdebug.Marker("Filter.Work query '%s'", query)
		defer g.End()
	}

	state := f.state
	if query == "" {
		state.ResetCurrentLineBuffer()
		if !state.config.StickySelection {
			state.Selection().Reset()
		}
		return
	}

	// Create a new pipeline
	p := pipeline.New()
	p.SetSource(state.Source())
	thisf := state.Filters().Current().Clone()
	thisf.SetQuery(query)
	p.Add(thisf)

	buf := NewMemoryBuffer()
	p.SetDestination(buf)
	state.SetCurrentLineBuffer(buf)

	go func() {
		defer state.Hub().SendDraw(true)
		if err := p.Run(ctx); err != nil {
			state.Hub().SendStatusMsg(err.Error())
		}
	}()

	go func() {
		if pdebug.Enabled {
			pdebug.Printf("waiting for query to finish")
			defer pdebug.Printf("Filter.Work: finished running query")
		}
		t := time.NewTicker(100 * time.Millisecond)
		defer t.Stop()
		defer state.Hub().SendStatusMsg("")
		defer state.Hub().SendDraw(true)
		for {
			select {
			case <-p.Done():
				return
			case <-t.C:
				pdebug.Printf("Sending draw while waiting for filter to end")
				state.Hub().SendDraw(true)
			}
		}
	}()

	if !state.config.StickySelection {
		state.Selection().Reset()
	}
}
Example #3
0
func (v *View) drawPrompt(p hub.Payload) {
	defer p.Done()

	v.layout.DrawPrompt(v.state)
}
Example #4
0
func (v *View) drawScreen(p hub.Payload, runningQuery bool) {
	defer p.Done()

	v.layout.DrawScreen(v.state, runningQuery)
}
Example #5
0
func (v *View) purgeDisplayCache(p hub.Payload) {
	defer p.Done()

	v.layout.PurgeDisplayCache()
}
Example #6
0
func (v *View) printStatus(p hub.Payload, r statusMsgReq) {
	defer p.Done()
	v.layout.PrintStatus(r.Message(), r.Delay())
}