Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidLayoutType(v LayoutType) bool
- func IsValidVerticalAnchor(anchor VerticalAnchor) bool
- func LocateRcfile() (string, error)
- func NewSignalHandler(loopCh chan struct{}, onEnd, onSignalReceived func()) *signalHandler
- type Action
- type ActionFunc
- type AnchorSettings
- type BasicLayout
- type BufferReader
- type CLI
- type CLIOptions
- type Config
- type Ctx
- func (c *Ctx) AddRawLine(l *RawLine)
- func (c *Ctx) AddWaitGroup(v int)
- func (c *Ctx) CaretPos() int
- func (c *Ctx) DrawPrompt()
- func (c *Ctx) Error() error
- func (c *Ctx) ExecQuery() bool
- func (c *Ctx) ExitWith(err error)
- func (c *Ctx) Filter() QueryFilterer
- func (c Ctx) GetCurrentLineBuffer() LineBuffer
- func (c Ctx) GetRawLineBufferSize() int
- func (c *Ctx) IsRangeMode() bool
- func (c *Ctx) IsSingleKeyJumpMode() bool
- func (c *Ctx) LoadCustomFilter() error
- func (c *Ctx) MoveCaretPos(offset int)
- func (c *Ctx) NewBufferReader(r io.ReadCloser) *BufferReader
- func (c *Ctx) NewFilter() *Filter
- func (c *Ctx) NewInput() *Input
- func (c *Ctx) NewView() *View
- func (c *Ctx) ReadConfig(file string) error
- func (c *Ctx) ReleaseWaitGroup()
- func (c *Ctx) ResetActiveLineBuffer()
- func (c *Ctx) ResetSelectedFilter()
- func (c *Ctx) ResultCh() <-chan Line
- func (c *Ctx) RotateFilter()
- func (c *Ctx) SelectionAdd(x int)
- func (c *Ctx) SelectionClear()
- func (c *Ctx) SelectionContains(n int) bool
- func (c *Ctx) SelectionLen() int
- func (c *Ctx) SelectionRemove(x int)
- func (c *Ctx) SetActiveLineBuffer(l *RawLineBuffer, runningQuery bool)
- func (c *Ctx) SetCaretPos(where int)
- func (c *Ctx) SetCurrentFilterByName(name string) error
- func (c *Ctx) SetPrompt(p string)
- func (c *Ctx) SetQuery(q []rune)
- func (c *Ctx) SetSavedQuery(q []rune)
- func (c *Ctx) ToggleSingleKeyJumpMode()
- func (c *Ctx) WaitDone()
- type CtxOptions
- type CustomFilterConfig
- type ExternalCmdFilter
- func (ecf *ExternalCmdFilter) Accept(p Pipeliner)
- func (sp ExternalCmdFilter) Cancel()
- func (sp ExternalCmdFilter) CancelCh() chan struct{}
- func (ecf ExternalCmdFilter) Clone() QueryFilterer
- func (sp ExternalCmdFilter) OutputCh() chan Line
- func (sp ExternalCmdFilter) Pipeline() (chan struct{}, chan Line)
- func (ecf *ExternalCmdFilter) SetQuery(q string)
- func (ecf ExternalCmdFilter) String() string
- func (ecf *ExternalCmdFilter) Verify() error
- type Filter
- type FilterQuery
- type FilterSet
- type FilteredLineBuffer
- func (flb *FilteredLineBuffer) Accept(p Pipeliner)
- func (flb *FilteredLineBuffer) Append(l Line) (Line, error)
- func (sp FilteredLineBuffer) Cancel()
- func (sp FilteredLineBuffer) CancelCh() chan struct{}
- func (flb *FilteredLineBuffer) InvalidateUpTo(x int)
- func (flb FilteredLineBuffer) LineAt(i int) (Line, error)
- func (sp FilteredLineBuffer) OutputCh() chan Line
- func (sp FilteredLineBuffer) Pipeline() (chan struct{}, chan Line)
- func (flb *FilteredLineBuffer) Register(lb LineBuffer)
- func (flb *FilteredLineBuffer) SelectSourceLineAt(i int)
- func (flb FilteredLineBuffer) Size() int
- func (flb *FilteredLineBuffer) Unregister(lb LineBuffer)
- type Hub
- func (h *Hub) Batch(f func())
- func (h *Hub) DrawCh() chan HubReq
- func (h *Hub) LoopCh() chan struct{}
- func (h *Hub) PagingCh() chan HubReq
- func (h *Hub) QueryCh() chan HubReq
- func (h *Hub) SendDraw(runningQuery bool)
- func (h *Hub) SendDrawPrompt()
- func (h *Hub) SendPaging(x PagingRequest)
- func (h *Hub) SendPurgeDisplayCache()
- func (h *Hub) SendQuery(q string)
- func (h *Hub) SendStatusMsg(q string)
- func (h *Hub) SendStatusMsgAndClear(q string, clearDelay time.Duration)
- func (h *Hub) StatusMsgCh() chan HubReq
- func (h *Hub) Stop()
- type HubReq
- type Input
- type JumpToLineRequest
- type Keymap
- type Keyseq
- type Layout
- type LayoutType
- type Line
- type LineBuffer
- type ListArea
- type MatchedLine
- type PageCrop
- type PageInfo
- type PagingRequest
- type PagingRequestType
- type Pipeliner
- type QueryFilterer
- type RawLine
- type RawLineBuffer
- func (rlb *RawLineBuffer) Accept(p Pipeliner)
- func (rlb *RawLineBuffer) Append(l Line) (Line, error)
- func (rlb *RawLineBuffer) AppendLine(l Line) (Line, error)
- func (sp RawLineBuffer) Cancel()
- func (sp RawLineBuffer) CancelCh() chan struct{}
- func (rlb RawLineBuffer) InvalidateUpTo(_ int)
- func (rlb RawLineBuffer) LineAt(i int) (Line, error)
- func (sp RawLineBuffer) OutputCh() chan Line
- func (sp RawLineBuffer) Pipeline() (chan struct{}, chan Line)
- func (rlb *RawLineBuffer) Register(lb LineBuffer)
- func (rlb *RawLineBuffer) Replay() error
- func (rlb *RawLineBuffer) SetCapacity(capacity int)
- func (rlb RawLineBuffer) Size() int
- func (rlb *RawLineBuffer) Unregister(lb LineBuffer)
- type RegexpFilter
- func (rf *RegexpFilter) Accept(p Pipeliner)
- func (sp RegexpFilter) Cancel()
- func (sp RegexpFilter) CancelCh() chan struct{}
- func (rf RegexpFilter) Clone() QueryFilterer
- func (sp RegexpFilter) OutputCh() chan Line
- func (sp RegexpFilter) Pipeline() (chan struct{}, chan Line)
- func (rf *RegexpFilter) SetQuery(q string)
- func (rf RegexpFilter) String() string
- type Screen
- type Selection
- type SelectionFilter
- type SingleKeyJumpConfig
- type StatusBar
- type StatusMsgRequest
- type Style
- type StyleSet
- type Termbox
- func (t Termbox) Close() error
- func (t Termbox) Flush() error
- func (t Termbox) Init() error
- func (t Termbox) PollEvent() chan termbox.Event
- func (t Termbox) PostInit() error
- func (t Termbox) SendEvent(_ termbox.Event)
- func (t Termbox) SetCell(x, y int, ch rune, fg, bg termbox.Attribute)
- func (t Termbox) Size() (int, int)
- type UserPrompt
- type VerticalAnchor
- type View
Constants ¶
const ( IgnoreCaseMatch = "IgnoreCase" CaseSensitiveMatch = "CaseSensitive" SmartCaseMatch = "SmartCase" RegexpMatch = "Regexp" )
These are used as keys in the config file
const ( // LayoutTypeTopDown is the default. All the items read from top to bottom LayoutTypeTopDown = "top-down" // LayoutTypeBottomUp changes the layout to read from bottom to up LayoutTypeBottomUp = "bottom-up" )
const DefaultCustomFilterBufferThreshold = 100
DefaultCustomFilterBufferThreshold is the default value for BufferThreshold setting on CustomFilters.
Variables ¶
var ErrBufferOutOfRange = errors.New("error: Specified index is out of range")
ErrBufferOutOfRange is returned when the index within the buffer that was queried was out of the containing buffer's range
var ErrFilterDidNotMatch = errors.New("error: filter did not match against given line")
var ErrFilterNotFound = errors.New("specified filter was not found")
var ErrSignalReceived = errors.New("received signal")
var ErrUserCanceled = errors.New("canceled")
ErrUserCanceled is used to signal that the user deliberately canceled using peco
Functions ¶
func IsValidLayoutType ¶ added in v0.2.5
func IsValidLayoutType(v LayoutType) bool
IsValidLayoutType checks if a string is a supported layout type
func IsValidVerticalAnchor ¶ added in v0.2.6
func IsValidVerticalAnchor(anchor VerticalAnchor) bool
IsValidVerticalAnchor checks if the specified anchor is supported
func LocateRcfile ¶ added in v0.1.3
LocateRcfile attempts to find the config file in various locations
func NewSignalHandler ¶ added in v0.3.4
func NewSignalHandler(loopCh chan struct{}, onEnd, onSignalReceived func()) *signalHandler
Types ¶
type Action ¶ added in v0.2.0
type Action interface { Register(string, ...termbox.Key) RegisterKeySequence(string, 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 Action 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(name string, k keyseq.KeyList)
RegisterKeySequence satisfies the Action interface for AfterFunc. Registers the action to be mapped against a key sequence
type AnchorSettings ¶ added in v0.2.5
type AnchorSettings struct {
// contains filtered or unexported fields
}
AnchorSettings groups items that are required to control where an anchored item is actually placed
func NewAnchorSettings ¶ added in v0.2.6
func NewAnchorSettings(anchor VerticalAnchor, offset int) *AnchorSettings
NewAnchorSettings creates a new AnchorSetting struct. Panics if an unknown VerticalAnchor is sent
func (AnchorSettings) AnchorPosition ¶ added in v0.2.5
func (as AnchorSettings) AnchorPosition() int
AnchorPosition returns the starting y-offset, based on the anchor type and offset
type BasicLayout ¶ added in v0.2.5
BasicLayout is... the basic layout :) At this point this is the only struct for layouts, which means that while the position of components may be configurable, the actual types of components that are used are set and static
func NewBottomUpLayout ¶ added in v0.2.5
func NewBottomUpLayout(ctx *Ctx) *BasicLayout
NewBottomUpLayout creates a new Layout in bottom-up format
func NewDefaultLayout ¶ added in v0.2.5
func NewDefaultLayout(ctx *Ctx) *BasicLayout
NewDefaultLayout creates a new Layout in the default format (top-down)
func (*BasicLayout) CalculatePage ¶ added in v0.2.5
func (l *BasicLayout) CalculatePage(perPage int) error
CalculatePage calculates which page we're displaying
func (*BasicLayout) DrawPrompt ¶ added in v0.2.9
func (l *BasicLayout) DrawPrompt()
DrawPrompt draws the prompt to the terminal
func (*BasicLayout) DrawScreen ¶ added in v0.2.5
func (l *BasicLayout) DrawScreen(runningQuery bool)
DrawScreen draws the entire screen
func (*BasicLayout) MovePage ¶ added in v0.2.5
func (l *BasicLayout) MovePage(p PagingRequest) (moved bool)
MovePage scrolls the screen
func (*BasicLayout) PurgeDisplayCache ¶ added in v0.3.4
func (l *BasicLayout) PurgeDisplayCache()
type BufferReader ¶ added in v0.1.12
type BufferReader struct { *Ctx // contains filtered or unexported fields }
BufferReader reads from either stdin or a file. In case of stdin, it also handles possible infinite source.
func (*BufferReader) InputReadyCh ¶ added in v0.2.0
func (b *BufferReader) InputReadyCh() <-chan struct{}
InputReadyCh returns a channel which, when the input starts coming in, sends a struct{}{}
func (*BufferReader) Loop ¶ added in v0.1.12
func (b *BufferReader) Loop()
Loop keeps reading from the input
type CLIOptions ¶ added in v0.3.0
type CLIOptions struct { OptHelp bool `short:"h" long:"help" description:"show this help message and exit"` OptTTY string `long:"tty" description:"path to the TTY (usually, the value of $TTY)"` OptQuery string `long:"query" description:"initial value for query"` OptRcfile string `long:"rcfile" description:"path to the settings file"` OptVersion bool `long:"version" description:"print the version and exit"` OptBufferSize int `long:"buffer-size" short:"b" description:"number of lines to keep in search buffer"` OptEnableNullSep bool `long:"null" description:"expect NUL (\\0) as separator for target/output"` OptInitialIndex int `long:"initial-index" description:"position of the initial index of the selection (0 base)"` OptInitialMatcher string `long:"initial-matcher" description:"specify the default matcher (deprecated)"` OptInitialFilter string `long:"initial-filter" description:"specify the default filter"` OptPrompt string `long:"prompt" description:"specify the prompt string"` OptLayout string `long:"layout" description:"layout to be used 'top-down' (default) or 'bottom-up'" default:"top-down"` OptSelect1 bool `long:"select-1" description:"select first item and immediately exit if the input contains only 1 item"` }
func (CLIOptions) BufferSize ¶ added in v0.3.0
func (o CLIOptions) BufferSize() int
BufferSize returns the specified buffer size. Fulfills CtxOptions
func (CLIOptions) EnableNullSep ¶ added in v0.3.0
func (o CLIOptions) EnableNullSep() bool
EnableNullSep returns true if --null was specified. Fulfills CtxOptions
func (CLIOptions) InitialIndex ¶ added in v0.3.0
func (o CLIOptions) InitialIndex() int
func (CLIOptions) LayoutType ¶ added in v0.3.0
func (o CLIOptions) LayoutType() string
type Config ¶
type Config struct { Action map[string][]string `json:"Action"` // 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"` // Deprecated. InitialMatcher string `json:"InitialMatcher"` // Use this instead of Matcher InitialFilter string `json:"InitialFilter"` Style *StyleSet `json:"Style"` Prompt string `json:"Prompt"` Layout string `json:"Layout"` CustomMatcher map[string][]string CustomFilter map[string]CustomFilterConfig QueryExecutionDelay int StickySelection bool // If this is true, then the prefix for single key jump mode // is displayed by default. SingleKeyJump SingleKeyJumpConfig `json:"SingleKeyJump"` }
Config holds all the data that can be configured in the external configuran file
func (*Config) ReadFilename ¶
ReadFilename reads the config from the given file, and does the appropriate processing, if any
type Ctx ¶
type Ctx struct { *Hub *FilterQuery // contains filtered or unexported fields }
Ctx contains all the important data. while you can easily access data in this struct from anywhere, only do so via channels
func NewCtx ¶
func NewCtx(o CtxOptions) *Ctx
func (*Ctx) AddRawLine ¶ added in v0.3.0
func (*Ctx) AddWaitGroup ¶
func (*Ctx) DrawPrompt ¶ added in v0.2.9
func (c *Ctx) DrawPrompt()
func (*Ctx) Filter ¶ added in v0.3.0
func (c *Ctx) Filter() QueryFilterer
func (Ctx) GetCurrentLineBuffer ¶ added in v0.3.0
func (c Ctx) GetCurrentLineBuffer() LineBuffer
func (Ctx) GetRawLineBufferSize ¶ added in v0.3.0
func (*Ctx) IsRangeMode ¶ added in v0.2.0
func (*Ctx) IsSingleKeyJumpMode ¶ added in v0.3.4
func (*Ctx) LoadCustomFilter ¶ added in v0.3.0
func (*Ctx) MoveCaretPos ¶ added in v0.2.11
func (*Ctx) NewBufferReader ¶ added in v0.1.12
func (c *Ctx) NewBufferReader(r io.ReadCloser) *BufferReader
func (*Ctx) ReadConfig ¶
func (*Ctx) ReleaseWaitGroup ¶
func (c *Ctx) ReleaseWaitGroup()
func (*Ctx) ResetActiveLineBuffer ¶ added in v0.3.0
func (c *Ctx) ResetActiveLineBuffer()
func (*Ctx) ResetSelectedFilter ¶ added in v0.3.3
func (c *Ctx) ResetSelectedFilter()
func (*Ctx) RotateFilter ¶ added in v0.3.0
func (c *Ctx) RotateFilter()
func (*Ctx) SelectionAdd ¶ added in v0.2.11
func (*Ctx) SelectionClear ¶ added in v0.2.11
func (c *Ctx) SelectionClear()
func (*Ctx) SelectionContains ¶ added in v0.2.11
func (*Ctx) SelectionLen ¶ added in v0.2.11
func (*Ctx) SelectionRemove ¶ added in v0.2.11
func (*Ctx) SetActiveLineBuffer ¶ added in v0.3.0
func (c *Ctx) SetActiveLineBuffer(l *RawLineBuffer, runningQuery bool)
func (*Ctx) SetCaretPos ¶ added in v0.2.11
func (*Ctx) SetCurrentFilterByName ¶ added in v0.3.0
func (*Ctx) SetSavedQuery ¶ added in v0.2.11
func (*Ctx) ToggleSingleKeyJumpMode ¶ added in v0.3.4
func (c *Ctx) ToggleSingleKeyJumpMode()
type CtxOptions ¶ added in v0.2.0
type CtxOptions interface { // EnableNullSep should return if the null separator is // enabled (--null) EnableNullSep() bool // BufferSize should return the buffer size. By default (i.e. // when it returns 0), the buffer size is unlimited. // (--buffer-size) BufferSize() int // InitialIndex is the line number to put the cursor on // when peco starts InitialIndex() int // LayoutType returns the name of the layout to use LayoutType() string }
CtxOptions is the interface that defines that options can be passed in from the command line
type CustomFilterConfig ¶ added in v0.3.0
type CustomFilterConfig struct { // Cmd is the name of the command to invoke Cmd string // TODO: need to check if how we use this is correct Args []string // BufferThreshold defines how many lines peco buffers before // invoking the external command. If this value is big, we // will execute the external command fewer times, but the // results will not be generated for longer periods of time. // If this value is small, we will execute the external command // more often, but you pay the penalty of invoking that command // more times. BufferThreshold int }
CustomFilterConfig is used to specify configuration parameters to CustomFilters
type ExternalCmdFilter ¶ added in v0.3.0
type ExternalCmdFilter struct {
// contains filtered or unexported fields
}
func NewExternalCmdFilter ¶ added in v0.3.0
func NewExternalCmdFilter(name, cmd string, args []string, threshold int, enableSep bool) *ExternalCmdFilter
func (*ExternalCmdFilter) Accept ¶ added in v0.3.0
func (ecf *ExternalCmdFilter) Accept(p Pipeliner)
func (ExternalCmdFilter) CancelCh ¶ added in v0.3.0
func (sp ExternalCmdFilter) CancelCh() chan struct{}
func (ExternalCmdFilter) Clone ¶ added in v0.3.0
func (ecf ExternalCmdFilter) Clone() QueryFilterer
func (ExternalCmdFilter) OutputCh ¶ added in v0.3.0
func (sp ExternalCmdFilter) OutputCh() chan Line
func (ExternalCmdFilter) Pipeline ¶ added in v0.3.0
func (sp ExternalCmdFilter) Pipeline() (chan struct{}, chan Line)
func (*ExternalCmdFilter) SetQuery ¶ added in v0.3.0
func (ecf *ExternalCmdFilter) SetQuery(q string)
func (ExternalCmdFilter) String ¶ added in v0.3.0
func (ecf ExternalCmdFilter) String() string
func (*ExternalCmdFilter) Verify ¶ added in v0.3.0
func (ecf *ExternalCmdFilter) Verify() error
type Filter ¶
type Filter struct {
*Ctx
}
Filter is responsible for the actual "grep" part of peco
type FilterQuery ¶ added in v0.2.6
type FilterQuery struct {
// contains filtered or unexported fields
}
func (*FilterQuery) AppendQuery ¶ added in v0.2.6
func (q *FilterQuery) AppendQuery(r rune)
func (*FilterQuery) InsertQueryAt ¶ added in v0.2.6
func (q *FilterQuery) InsertQueryAt(ch rune, where int)
func (FilterQuery) Query ¶ added in v0.2.6
func (q FilterQuery) Query() []rune
func (FilterQuery) QueryLen ¶ added in v0.2.6
func (q FilterQuery) QueryLen() int
func (FilterQuery) QueryString ¶ added in v0.2.9
func (q FilterQuery) QueryString() string
func (FilterQuery) SavedQuery ¶ added in v0.2.11
func (q FilterQuery) SavedQuery() []rune
type FilterSet ¶ added in v0.3.0
type FilterSet struct {
// contains filtered or unexported fields
}
func (*FilterSet) Add ¶ added in v0.3.0
func (fs *FilterSet) Add(qf QueryFilterer) error
func (*FilterSet) GetCurrent ¶ added in v0.3.0
func (fs *FilterSet) GetCurrent() QueryFilterer
func (*FilterSet) SetCurrentByName ¶ added in v0.3.0
type FilteredLineBuffer ¶ added in v0.3.0
type FilteredLineBuffer struct {
// contains filtered or unexported fields
}
FilteredLineBuffer holds a "filtered" buffer. It holds a reference to the source buffer (note: should be immutable) and a list of indices into the source buffer
func NewFilteredLineBuffer ¶ added in v0.3.0
func NewFilteredLineBuffer(src LineBuffer) *FilteredLineBuffer
func (*FilteredLineBuffer) Accept ¶ added in v0.3.0
func (flb *FilteredLineBuffer) Accept(p Pipeliner)
func (*FilteredLineBuffer) Append ¶ added in v0.3.0
func (flb *FilteredLineBuffer) Append(l Line) (Line, error)
func (FilteredLineBuffer) CancelCh ¶ added in v0.3.0
func (sp FilteredLineBuffer) CancelCh() chan struct{}
func (*FilteredLineBuffer) InvalidateUpTo ¶ added in v0.3.0
func (flb *FilteredLineBuffer) InvalidateUpTo(x int)
func (FilteredLineBuffer) LineAt ¶ added in v0.3.0
func (flb FilteredLineBuffer) LineAt(i int) (Line, error)
LineAt returns the line at index `i`. Note that the i-th element in this filtered buffer may actually correspond to a totally different line number in the source buffer.
func (FilteredLineBuffer) OutputCh ¶ added in v0.3.0
func (sp FilteredLineBuffer) OutputCh() chan Line
func (FilteredLineBuffer) Pipeline ¶ added in v0.3.0
func (sp FilteredLineBuffer) Pipeline() (chan struct{}, chan Line)
func (*FilteredLineBuffer) Register ¶ added in v0.3.0
func (flb *FilteredLineBuffer) Register(lb LineBuffer)
func (*FilteredLineBuffer) SelectSourceLineAt ¶ added in v0.3.0
func (flb *FilteredLineBuffer) SelectSourceLineAt(i int)
func (FilteredLineBuffer) Size ¶ added in v0.3.0
func (flb FilteredLineBuffer) Size() int
Size returns the number of lines in the buffer
func (*FilteredLineBuffer) Unregister ¶ added in v0.3.0
func (flb *FilteredLineBuffer) Unregister(lb LineBuffer)
type Hub ¶ added in v0.2.1
type Hub struct {
// contains filtered or unexported fields
}
Hub acts as the messaging hub between components -- that is, it controls how the communication that goes through channels are handled.
func (*Hub) Batch ¶ added in v0.2.1
func (h *Hub) Batch(f func())
Batch allows you to synchronously send messages during the scope of f() being executed.
func (*Hub) LoopCh ¶ added in v0.2.1
func (h *Hub) LoopCh() chan struct{}
LoopCh returns the channel to control the main execution loop. Nothing should ever be sent through this channel. The only way the channel communicates anything to its receivers is when it is closed -- which is when peco is done.
func (*Hub) SendDrawPrompt ¶ added in v0.2.9
func (h *Hub) SendDrawPrompt()
SendDrawPrompt sends a request to redraw the prompt only
func (*Hub) SendPaging ¶ added in v0.2.1
func (h *Hub) SendPaging(x PagingRequest)
SendPaging sends a request to move the cursor around
func (*Hub) SendPurgeDisplayCache ¶ added in v0.3.4
func (h *Hub) SendPurgeDisplayCache()
func (*Hub) SendQuery ¶ added in v0.2.1
SendQuery sends the query string to be processed by the Filter
func (*Hub) SendStatusMsg ¶ added in v0.2.1
SendStatusMsg sends a string to be displayed in the status message
func (*Hub) SendStatusMsgAndClear ¶ added in v0.2.10
SendStatusMsgAndClear sends a string to be displayed in the status message, as well as a delay until the message should be cleared
func (*Hub) StatusMsgCh ¶ added in v0.2.1
StatusMsgCh returns the channel to update the status message
type HubReq ¶ added in v0.2.1
type HubReq struct {
// contains filtered or unexported fields
}
HubReq is a wrapper around the actual request value that needs to be passed. It contains an optional channel field which can be filled to force synchronous communication between the sender and receiver
func (HubReq) DataInterface ¶ added in v0.2.1
func (hr HubReq) DataInterface() interface{}
DataInterface returns the underlying data as interface{}
func (HubReq) DataString ¶ added in v0.2.1
DataString returns the underlying data as a string. Panics if type conversion fails.
type Input ¶
type Input struct { *Ctx // contains filtered or unexported fields }
Input handles input events from termbox.
type JumpToLineRequest ¶ added in v0.3.4
type JumpToLineRequest uint
func (JumpToLineRequest) Line ¶ added in v0.3.4
func (jlr JumpToLineRequest) Line() int
func (JumpToLineRequest) Type ¶ added in v0.3.4
func (jlr JumpToLineRequest) Type() PagingRequestType
type Keymap ¶
type Keymap struct { Config map[string]string Action map[string][]string // custom actions // contains filtered or unexported fields }
Keymap holds all the key sequence to action map
func (Keymap) ApplyKeybinding ¶ added in v0.2.0
func (km Keymap) ApplyKeybinding()
ApplyKeybinding applies all of the custom key bindings on top of the default key bindings
func (Keymap) LookupAction ¶ added in v0.3.4
LookupAction returns the appropriate action for the given termbox event
type Layout ¶ added in v0.2.5
type Layout interface { PrintStatus(string, time.Duration) DrawPrompt() DrawScreen(bool) MovePage(PagingRequest) (moved bool) PurgeDisplayCache() }
Layout represents the component that controls where elements are placed on screen
type LayoutType ¶ added in v0.2.5
type LayoutType string
LayoutType describes the types of layout that peco can take
type Line ¶ added in v0.2.11
type Line interface { btree.Item ID() uint64 // Buffer returns the raw buffer Buffer() string // DisplayString returns the string to be displayed. This means if you have // a null separator, the contents after the separator are not included // in this string DisplayString() string // Indices return the matched portion(s) of a string after filtering. // Note that while Indices may return nil, that just means that there are // no substrings to be highlighted. It doesn't mean there were no matches Indices() [][]int // Output returns the string to be display as peco finishes up doing its // thing. This means if you have null separator, the contents before the // separator are not included in this string Output() string // IsDirty returns true if this line should be forcefully redrawn IsDirty() bool // SetDirty sets the dirty flag on or off SetDirty(bool) }
Line represents each of the line that peco uses to display and match against queries.
type LineBuffer ¶ added in v0.3.0
type LineBuffer interface { Pipeliner LineAt(int) (Line, error) Size() int // Register registers another LineBuffer that is dependent on // this buffer. Register(LineBuffer) Unregister(LineBuffer) // InvalidateUpTo is called when a source buffer invalidates // some lines. The argument is the largest line number that // should be invalidated (so anything up to that line is no // longer valid in the source) InvalidateUpTo(int) }
LineBuffer represents a set of lines. This could be the raw data read in, or filtered data, such as result of running a match, or applying a selection by the user
Buffers should be immutable.
type ListArea ¶ added in v0.2.5
type ListArea struct { *Ctx *AnchorSettings // contains filtered or unexported fields }
ListArea represents the area where the actual line buffer is displayed in the screen
func NewListArea ¶ added in v0.2.5
func NewListArea(ctx *Ctx, anchor VerticalAnchor, anchorOffset int, sortTopDown bool) *ListArea
NewListArea creates a new ListArea struct
type MatchedLine ¶ added in v0.2.11
type MatchedLine struct { Line // contains filtered or unexported fields }
MatchedLine contains the indices to the matches
func NewMatchedLine ¶ added in v0.2.11
func NewMatchedLine(rl Line, matches [][]int) *MatchedLine
NewMatchedLine creates a new MatchedLine
func (MatchedLine) Indices ¶ added in v0.2.11
func (ml MatchedLine) Indices() [][]int
Indices returns the indices in the buffer that matched
type PageCrop ¶ added in v0.3.0
type PageCrop struct {
// contains filtered or unexported fields
}
PageCrop filters out a new LineBuffer based on entries per page and the page number
func (PageCrop) Crop ¶ added in v0.3.0
func (pf PageCrop) Crop(in LineBuffer) LineBuffer
Crop returns a new LineBuffer whose contents are bound within the given range
type PagingRequest ¶
type PagingRequest interface {
Type() PagingRequestType
}
type PagingRequestType ¶ added in v0.3.4
type PagingRequestType int
PagingRequest can be sent to move the selection cursor
const ( // ToLineAbove moves the selection to the line above ToLineAbove PagingRequestType = iota // ToScrollPageDown moves the selection to the next page ToScrollPageDown // ToLineBelow moves the selection to the line below ToLineBelow // ToScrollPageUp moves the selection to the previous page ToScrollPageUp // ToScrollLeft scrolls screen to the left ToScrollLeft // ToScrollRight scrolls screen to the right ToScrollRight // ToLineInPage jumps to a particular line on the page ToLineInPage )
func (PagingRequestType) Type ¶ added in v0.3.4
func (prt PagingRequestType) Type() PagingRequestType
type QueryFilterer ¶ added in v0.3.0
type QueryFilterer interface { Pipeliner Cancel() Clone() QueryFilterer Accept(Pipeliner) SetQuery(string) String() string }
type RawLine ¶ added in v0.2.11
type RawLine struct {
// contains filtered or unexported fields
}
RawLine is the input line as sent to peco, before filtering and what not.
func NewRawLine ¶ added in v0.2.11
NewRawLine creates a new RawLine. The `enableSep` flag tells it if we should search for a null character to split the string to display and the string to emit upon selection of of said line
func (RawLine) DisplayString ¶ added in v0.2.11
DisplayString returns the string to be displayed
func (RawLine) Indices ¶ added in v0.2.11
Indices fulfills the Line interface, but for RawLine it always returns nil
func (RawLine) IsDirty ¶ added in v0.3.0
IsDirty returns true if this line must be redrawn on the terminal
type RawLineBuffer ¶ added in v0.3.0
type RawLineBuffer struct {
// contains filtered or unexported fields
}
RawLineBuffer holds the raw set of lines as read into peco.
func NewRawLineBuffer ¶ added in v0.3.0
func NewRawLineBuffer() *RawLineBuffer
func (*RawLineBuffer) Accept ¶ added in v0.3.0
func (rlb *RawLineBuffer) Accept(p Pipeliner)
func (*RawLineBuffer) Append ¶ added in v0.3.0
func (rlb *RawLineBuffer) Append(l Line) (Line, error)
func (*RawLineBuffer) AppendLine ¶ added in v0.3.0
func (rlb *RawLineBuffer) AppendLine(l Line) (Line, error)
func (RawLineBuffer) InvalidateUpTo ¶ added in v0.3.0
func (rlb RawLineBuffer) InvalidateUpTo(_ int)
func (RawLineBuffer) LineAt ¶ added in v0.3.0
func (rlb RawLineBuffer) LineAt(i int) (Line, error)
LineAt returns the line at index `i`
func (RawLineBuffer) Pipeline ¶ added in v0.3.0
func (sp RawLineBuffer) Pipeline() (chan struct{}, chan Line)
func (*RawLineBuffer) Register ¶ added in v0.3.0
func (rlb *RawLineBuffer) Register(lb LineBuffer)
func (*RawLineBuffer) Replay ¶ added in v0.3.0
func (rlb *RawLineBuffer) Replay() error
func (*RawLineBuffer) SetCapacity ¶ added in v0.3.0
func (rlb *RawLineBuffer) SetCapacity(capacity int)
func (RawLineBuffer) Size ¶ added in v0.3.0
func (rlb RawLineBuffer) Size() int
Size returns the number of lines in the buffer
func (*RawLineBuffer) Unregister ¶ added in v0.3.0
func (rlb *RawLineBuffer) Unregister(lb LineBuffer)
type RegexpFilter ¶ added in v0.3.0
type RegexpFilter struct {
// contains filtered or unexported fields
}
func NewCaseSensitiveFilter ¶ added in v0.3.0
func NewCaseSensitiveFilter() *RegexpFilter
func NewIgnoreCaseFilter ¶ added in v0.3.0
func NewIgnoreCaseFilter() *RegexpFilter
func NewRegexpFilter ¶ added in v0.3.0
func NewRegexpFilter() *RegexpFilter
func NewSmartCaseFilter ¶ added in v0.3.0
func NewSmartCaseFilter() *RegexpFilter
SmartCaseFilter turns ON the ignore-case flag in the regexp if the query contains a upper-case character
func (*RegexpFilter) Accept ¶ added in v0.3.0
func (rf *RegexpFilter) Accept(p Pipeliner)
func (RegexpFilter) Clone ¶ added in v0.3.0
func (rf RegexpFilter) Clone() QueryFilterer
func (RegexpFilter) Pipeline ¶ added in v0.3.0
func (sp RegexpFilter) Pipeline() (chan struct{}, chan Line)
func (*RegexpFilter) SetQuery ¶ added in v0.3.0
func (rf *RegexpFilter) SetQuery(q string)
func (RegexpFilter) String ¶ added in v0.3.0
func (rf RegexpFilter) String() string
type Screen ¶ added in v0.2.6
type Screen interface { Init() error Close() error Flush() error PollEvent() chan termbox.Event SetCell(int, int, rune, termbox.Attribute, termbox.Attribute) Size() (int, int) SendEvent(termbox.Event) }
Screen hides termbox from the consuming code so that it can be swapped out for testing
type Selection ¶ added in v0.1.3
Selection stores the line ids that were selected by the user. The contents of the Selection is always sorted from smallest to largest line ID
func NewSelection ¶ added in v0.2.11
func NewSelection() *Selection
NewSelection creates a new empty Selection
type SelectionFilter ¶ added in v0.3.0
type SelectionFilter struct {
// contains filtered or unexported fields
}
func (SelectionFilter) Name ¶ added in v0.3.0
func (sf SelectionFilter) Name() string
type SingleKeyJumpConfig ¶ added in v0.3.4
type StatusBar ¶ added in v0.2.5
type StatusBar struct { *Ctx *AnchorSettings // contains filtered or unexported fields }
StatusBar draws the status message bar
func NewStatusBar ¶ added in v0.2.5
func NewStatusBar(ctx *Ctx, anchor VerticalAnchor, anchorOffset int) *StatusBar
NewStatusBar creates a new StatusBar struct
type StatusMsgRequest ¶ added in v0.2.10
type StatusMsgRequest struct {
// contains filtered or unexported fields
}
StatusMsgRequest specifies the string to be drawn on the status message bar and an optional delay that tells the view to clear that message
type Style ¶ added in v0.1.2
type Style struct {
// contains filtered or unexported fields
}
Style describes termbox styles
func (*Style) UnmarshalJSON ¶ added in v0.1.2
UnmarshalJSON satisfies json.RawMessage.
type StyleSet ¶ added in v0.1.2
type StyleSet struct { Basic Style `json:"Basic"` SavedSelection Style `json:"SavedSelection"` Selected Style `json:"Selected"` Query Style `json:"Query"` Matched Style `json:"Matched"` }
StyleSet holds styles for various sections
func NewStyleSet ¶ added in v0.1.2
func NewStyleSet() *StyleSet
NewStyleSet creates a new StyleSet struct
type Termbox ¶ added in v0.2.6
type Termbox struct{}
Termbox just hands out the processing to the termbox library
func (Termbox) PollEvent ¶ added in v0.2.6
func (t Termbox) PollEvent() chan termbox.Event
PollEvent returns a channel that you can listen to for termbox's events. The actual polling is done in a separate gouroutine
func (Termbox) SendEvent ¶ added in v0.3.0
func (t Termbox) SendEvent(_ termbox.Event)
SendEvent is used to allow programmers generate random events, but it's only useful for testing purposes. When interactiving with termbox-go, this method is a noop
type UserPrompt ¶ added in v0.2.5
type UserPrompt struct { *Ctx *AnchorSettings // contains filtered or unexported fields }
UserPrompt draws the prompt line
func NewUserPrompt ¶ added in v0.2.5
func NewUserPrompt(ctx *Ctx, anchor VerticalAnchor, anchorOffset int) *UserPrompt
NewUserPrompt creates a new UserPrompt struct
type VerticalAnchor ¶ added in v0.2.5
type VerticalAnchor int
VerticalAnchor describes the direction to which elements in the layout are anchored to
const ( // AnchorTop anchors elements towards the top of the screen AnchorTop VerticalAnchor = iota + 1 // AnchorBottom anchors elements towards the bottom of the screen AnchorBottom )