Exemple #1
0
func wrapRememberSequence(a Action) Action {
	return ActionFunc(func(ctx context.Context, state *Peco, ev termbox.Event) {
		if s, err := keyseq.EventToString(ev); err == nil {
			seq := state.Inputseq()
			seq.Add(s)
			state.Hub().SendStatusMsg(strings.Join(seq.KeyNames(), " "))
		}
		a.Execute(ctx, state, ev)
	})
}
Exemple #2
0
func wrapRememberSequence(a Action) Action {
	return ActionFunc(func(i *Input, ev termbox.Event) {
		s, err := keyseq.EventToString(ev)
		if err == nil {
			i.currentKeySeq = append(i.currentKeySeq, s)
			i.SendStatusMsg(strings.Join(i.currentKeySeq, " "))
		}
		a.Execute(i, ev)
	})
}
Exemple #3
0
func wrapClearSequence(a Action) Action {
	return ActionFunc(func(i *Input, ev termbox.Event) {
		s, err := keyseq.EventToString(ev)
		if err == nil {
			i.currentKeySeq = append(i.currentKeySeq, s)
		}

		if len(i.currentKeySeq) > 0 {
			i.SendStatusMsgAndClear(strings.Join(i.currentKeySeq, " "), 500*time.Millisecond)
			i.currentKeySeq = []string{}
		}

		a.Execute(i, ev)
	})
}
Exemple #4
0
func wrapClearSequence(a Action) Action {
	return ActionFunc(func(ctx context.Context, state *Peco, ev termbox.Event) {
		seq := state.Inputseq()
		if s, err := keyseq.EventToString(ev); err == nil {
			seq.Add(s)
		}

		if seq.Len() > 0 {
			msg := strings.Join(seq.KeyNames(), " ")
			state.Hub().SendStatusMsgAndClear(msg, 500*time.Millisecond)
			seq.Reset()
		}

		a.Execute(ctx, state, ev)
	})
}