package fzf
import (
"bytes"
"fmt"
"os"
"os/signal"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"syscall"
"time"
C "github.com/junegunn/fzf/src/curses"
"github.com/junegunn/fzf/src/util"
"github.com/junegunn/go-runewidth"
)
// Terminal represents terminal input/output
type Terminal struct {
initDelay time.Duration
inlineInfo bool
prompt string
reverse bool
hscroll bool
hscrollOff int
cx int
cy int
offset int
yanked []rune
input []rune
multi bool
sort bool
toggleSort bool
expect map[int]string
keymap map[int]actionType
execmap map[int]string
pressed string
printQuery bool
history *History
cycle bool
header []string
header0 []string
ansi bool
margin [4]string
marginInt [4]int
count int
progress int
reading bool
merger *Merger
selected map[int32]selectedItem
reqBox *util.EventBox
eventBox *util.EventBox
mutex sync.Mutex
initFunc func()
suppress bool
startChan chan bool
}
type selectedItem struct {
at time.Time
text *string
}
type byTimeOrder []selectedItem
func (a byTimeOrder) Len() int {
return len(a)
}
func (a byTimeOrder) Swap(i, j int) {
a[i], a[j] = a[j], a[i]
}
func (a byTimeOrder) Less(i, j int) bool {
return a[i].at.Before(a[j].at)
}
var _spinner = []string{`-`, `\`, `|`, `/`, `-`, `\`, `|`, `/`}
var _runeWidths = make(map[rune]int)
var _tabStop int
const (
reqPrompt util.EventType = iota
reqInfo
reqHeader
reqList
reqRefresh
reqRedraw
reqClose
reqQuit
)
type actionType int
const (
actIgnore actionType = iota
actInvalid
actRune
actMouse
actBeginningOfLine
actAbort
actAccept
actBackwardChar
actBackwardDeleteChar
actBackwardWord
actCancel
actClearScreen
actDeleteChar
actDeleteCharEOF
actEndOfLine
actForwardChar
actForwardWord
actKillLine
actKillWord
actUnixLineDiscard
actUnixWordRubout
actYank
actBackwardKillWord
actSelectAll
actDeselectAll
actToggle
actToggleAll
actToggleDown
actToggleUp
actToggleIn
actToggleOut
actDown
actUp
actPageUp
actPageDown
actToggleSort
actPreviousHistory
actNextHistory
actExecute
actExecuteMulti
)
func defaultKeymap() map[int]actionType {
keymap := make(map[int]actionType)
keymap[C.Invalid] = actInvalid
keymap[C.CtrlA] = actBeginningOfLine
keymap[C.C