Documentation ¶
Index ¶
- Constants
- func IsTty(fd uintptr) bool
- func LocateRcfile() (string, error)
- func TtyReady() error
- func TtyTerm()
- type Action
- type ActionFunc
- type BufferReader
- type CaseSensitiveMatcher
- type Config
- type Ctx
- func (c *Ctx) AddMatcher(m Matcher) error
- func (c *Ctx) AddWaitGroup(v int)
- func (c *Ctx) Buffer() []Match
- func (c *Ctx) DrawCh() chan []Match
- func (c *Ctx) DrawMatches(m []Match)
- func (c *Ctx) ExecQuery() bool
- func (c *Ctx) ExitWith(i int)
- func (c *Ctx) IsBufferOverflowing() bool
- func (c *Ctx) IsRangeMode() bool
- func (c *Ctx) LoadCustomMatcher() error
- func (c *Ctx) LoopCh() chan struct{}
- func (c *Ctx) Matcher() Matcher
- func (c *Ctx) NewBufferReader(r io.ReadCloser) *BufferReader
- func (c *Ctx) NewFilter() *Filter
- func (c *Ctx) NewInput() *Input
- func (c *Ctx) NewSignalHandler() *SignalHandler
- func (c *Ctx) NewView() *View
- func (c *Ctx) PagingCh() chan PagingRequest
- func (c *Ctx) QueryCh() chan string
- func (c *Ctx) ReadConfig(file string) error
- func (c *Ctx) Refresh()
- func (c *Ctx) ReleaseWaitGroup()
- func (c *Ctx) Result() []Match
- func (c *Ctx) SelectedRange() Selection
- func (c *Ctx) SetCurrentMatcher(n string) bool
- func (c *Ctx) SetPrompt(p []rune)
- func (c *Ctx) SetQuery(q []rune)
- func (c *Ctx) StatusMsgCh() chan string
- func (c *Ctx) Stop()
- func (c *Ctx) Terminate()
- func (c *Ctx) WaitDone()
- type CtxOptions
- type CustomMatcher
- type DidMatch
- type Filter
- type IgnoreCaseMatcher
- type Input
- type Keymap
- type Match
- type MatchString
- type Matcher
- type NoMatch
- type PagingRequest
- type RegexpMatcher
- func (m *RegexpMatcher) Match(quit chan struct{}, q string, buffer []Match) []Match
- func (m *RegexpMatcher) MatchAllRegexps(regexps []*regexp.Regexp, line string) [][]int
- func (m *RegexpMatcher) QueryToRegexps(query string) ([]*regexp.Regexp, error)
- func (m *RegexpMatcher) String() string
- func (m *RegexpMatcher) Verify() error
- type Selection
- type SignalHandler
- type Style
- type StyleSet
- type View
Constants ¶
const ( IgnoreCaseMatch = "IgnoreCase" CaseSensitiveMatch = "CaseSensitive" RegexpMatch = "Regexp" )
const NoSelectionRange = -1
Variables ¶
This section is empty.
Functions ¶
func LocateRcfile ¶ added in v0.1.3
Types ¶
type Action ¶ added in v0.2.0
type Action interface { Register(string, ...termbox.Key) RegisterKeySequence(keyseq.KeyList) Execute(*Input, termbox.Event) }
Action describes an action that can be executed upon receiving user input. It's an interface so you can create any kind of Action you need, but most everything is implemented in terms of ActionFunc, which is callback based Action
type ActionFunc ¶ added in v0.2.0
type ActionFunc func(*Input, termbox.Event)
ActionFunc is a type of Action that is basically just a callback.
func (ActionFunc) Execute ¶ added in v0.2.0
func (a ActionFunc) Execute(i *Input, e termbox.Event)
Execute fulfills the Action interface for AfterFunc
func (ActionFunc) Register ¶ added in v0.2.0
func (a ActionFunc) Register(name string, defaultKeys ...termbox.Key)
Register fulfills the Actin interface for AfterFunc. Registers `a` into the global action registry by the name `name`, and maps to default keys via `defaultKeys`
func (ActionFunc) RegisterKeySequence ¶ added in v0.2.0
func (a ActionFunc) RegisterKeySequence(k keyseq.KeyList)
type BufferReader ¶ added in v0.1.12
type BufferReader struct { *Ctx // contains filtered or unexported fields }
BufferReader reads lines from the input, either Stdin or a file. If the incoming data is endless, it keeps reading and adding to the search buffer, as long as it can.
If you would like to limit the number of lines to keep in the buffer, you should set --buffer-size to a number > 0
func (*BufferReader) InputReadyCh ¶ added in v0.2.0
func (b *BufferReader) InputReadyCh() <-chan struct{}
func (*BufferReader) Loop ¶ added in v0.1.12
func (b *BufferReader) Loop()
Loop keeps reading from the input
type CaseSensitiveMatcher ¶ added in v0.1.1
type CaseSensitiveMatcher struct {
*RegexpMatcher
}
func NewCaseSensitiveMatcher ¶ added in v0.1.2
func NewCaseSensitiveMatcher(enableSep bool) *CaseSensitiveMatcher
func (*CaseSensitiveMatcher) String ¶ added in v0.1.1
func (m *CaseSensitiveMatcher) String() string
type Config ¶
type Config struct { // Keymap used to be directly responsible for dispatching // events against user input, but since then this has changed // into something that just records the user's config input Keymap map[string]string `json:"Keymap"` Matcher string `json:"Matcher"` Style StyleSet `json:"Style"` CustomMatcher map[string][]string Prompt string `json:"Prompt"` }
func (*Config) ReadFilename ¶
type Ctx ¶
type Ctx struct { Matchers []Matcher CurrentMatcher int ExitStatus int // contains filtered or unexported fields }
Ctx contains all the important data. while you can easily access data in this struct from anwyehre, only do so via channels
func NewCtx ¶
func NewCtx(o CtxOptions) *Ctx
func (*Ctx) AddMatcher ¶ added in v0.1.2
func (*Ctx) AddWaitGroup ¶
func (*Ctx) DrawMatches ¶
func (*Ctx) IsBufferOverflowing ¶ added in v0.2.0
func (*Ctx) IsRangeMode ¶ added in v0.2.0
func (*Ctx) LoadCustomMatcher ¶ added in v0.1.3
func (*Ctx) NewBufferReader ¶ added in v0.1.12
func (c *Ctx) NewBufferReader(r io.ReadCloser) *BufferReader
func (*Ctx) NewSignalHandler ¶ added in v0.2.0
func (c *Ctx) NewSignalHandler() *SignalHandler
func (*Ctx) PagingCh ¶
func (c *Ctx) PagingCh() chan PagingRequest
func (*Ctx) ReadConfig ¶
func (*Ctx) ReleaseWaitGroup ¶
func (c *Ctx) ReleaseWaitGroup()
func (*Ctx) SelectedRange ¶ added in v0.2.0
func (*Ctx) SetCurrentMatcher ¶ added in v0.1.2
func (*Ctx) StatusMsgCh ¶ added in v0.1.11
type CtxOptions ¶ added in v0.2.0
type CustomMatcher ¶ added in v0.1.3
type CustomMatcher struct {
// contains filtered or unexported fields
}
func NewCustomMatcher ¶ added in v0.1.3
func NewCustomMatcher(enableSep bool, name string, args []string) *CustomMatcher
func (*CustomMatcher) Match ¶ added in v0.1.3
func (m *CustomMatcher) Match(quit chan struct{}, q string, buffer []Match) []Match
func (*CustomMatcher) String ¶ added in v0.1.3
func (m *CustomMatcher) String() string
func (*CustomMatcher) Verify ¶ added in v0.1.11
func (m *CustomMatcher) Verify() error
type DidMatch ¶ added in v0.1.3
type DidMatch struct { *MatchString // contains filtered or unexported fields }
DidMatch contains the actual match, and the indices to the matches in the line
type IgnoreCaseMatcher ¶ added in v0.1.1
type IgnoreCaseMatcher struct {
*RegexpMatcher
}
func NewIgnoreCaseMatcher ¶ added in v0.1.2
func NewIgnoreCaseMatcher(enableSep bool) *IgnoreCaseMatcher
func (*IgnoreCaseMatcher) String ¶ added in v0.1.1
func (m *IgnoreCaseMatcher) String() string
type Keymap ¶
func (Keymap) ApplyKeybinding ¶ added in v0.2.0
func (km Keymap) ApplyKeybinding()
type Match ¶
type Match interface { Buffer() string // Raw buffer, may contain null Line() string // Line to be displayed Output() string // Output string to be displayed after peco is done Indices() [][]int }
Match defines the interface for matches. Note that to make drawing easier, we have a DidMatch and NoMatch types instead of using []Match and []string.
type MatchString ¶ added in v0.1.5
type MatchString struct {
// contains filtered or unexported fields
}
func NewMatchString ¶ added in v0.1.5
func NewMatchString(v string, enableSep bool) *MatchString
func (MatchString) Buffer ¶ added in v0.1.5
func (m MatchString) Buffer() string
func (MatchString) Line ¶ added in v0.1.5
func (m MatchString) Line() string
func (MatchString) Output ¶ added in v0.1.5
func (m MatchString) Output() string
type Matcher ¶ added in v0.1.1
type Matcher interface { // Match takes in three parameters. // // The first chan is the channel where cancel requests are sent. // If you receive a request here, you should stop running your query. // // The second is the query. Do what you want with it // // The third is the buffer in which to match the query against. Match(chan struct{}, string, []Match) []Match String() string // This is fugly. We just added a method only for CustomMatcner. // Must think about this again Verify() error }
Matcher interface defines the API for things that want to match against the buffer
type NoMatch ¶ added in v0.1.3
type NoMatch struct {
*MatchString
}
NoMatch is actually an alias to a regular string. It implements the Match interface, but just returns the underlying string with no matches
func NewNoMatch ¶ added in v0.1.5
type PagingRequest ¶
type PagingRequest int
PagingRequest can be sent to move the selection cursor
const ( // ToNextLine moves the selection to the next line ToNextLine PagingRequest = iota // ToNextPage moves the selection to the next page ToNextPage // ToPrevLine moves the selection to the previous line ToPrevLine // ToPrevPage moves the selection to the previous page ToPrevPage )
type RegexpMatcher ¶ added in v0.1.2
type RegexpMatcher struct {
// contains filtered or unexported fields
}
func NewRegexpMatcher ¶ added in v0.1.2
func NewRegexpMatcher(enableSep bool) *RegexpMatcher
func (*RegexpMatcher) Match ¶ added in v0.1.2
func (m *RegexpMatcher) Match(quit chan struct{}, q string, buffer []Match) []Match
func (*RegexpMatcher) MatchAllRegexps ¶ added in v0.1.2
func (m *RegexpMatcher) MatchAllRegexps(regexps []*regexp.Regexp, line string) [][]int
func (*RegexpMatcher) QueryToRegexps ¶ added in v0.1.2
func (m *RegexpMatcher) QueryToRegexps(query string) ([]*regexp.Regexp, error)
func (*RegexpMatcher) String ¶ added in v0.1.2
func (m *RegexpMatcher) String() string
func (*RegexpMatcher) Verify ¶ added in v0.1.11
func (m *RegexpMatcher) Verify() error
type SignalHandler ¶ added in v0.2.0
type SignalHandler struct { *Ctx // contains filtered or unexported fields }
func (*SignalHandler) Loop ¶ added in v0.2.0
func (s *SignalHandler) Loop()
type Style ¶ added in v0.1.2
type Style struct {
// contains filtered or unexported fields
}