Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateColumnWidth(allText []string, screenWidth int, minColumns int, gutterWidth int) (int, int)
- type BasicHistoryIterator
- type BasicHistoryManager
- type CompletionFunc
- type FileLock
- type HistoryIterator
- type HistoryManager
- type PersistedHistoryManager
- type Position
- type Reader
- type ReaderConfig
- type Size
- type Suggestion
- type Suggestions
Constants ¶
View Source
const ( KEY_CTRL_C = "\x03" // Signal interrupt KEY_CTRL_D = "\x04" // Signal EOF KEY_CTRL_L = "\x0C" // Clear terminal KEY_TAB = "\x09" KEY_ENTER = "\x0D" KEY_CTRL_R = "\x12" // Search backward KEY_CTRL_T = "\x14" KEY_ESCAPE = "\x1B" KEY_BACKSPACE = "\x7F" KEY_DEL = "\x1B[3~" KEY_END = "\x1B[F" KEY_HOME = "\x1B[H" KEY_UP_ARROW = "\x1B[A" KEY_DOWN_ARROW = "\x1B[B" KEY_RIGHT_ARROW = "\x1B[C" KEY_LEFT_ARROW = "\x1B[D" )
Variables ¶
View Source
var ( ErrInterrupt = errors.New("interrupt") ErrEof = errors.New("eof") )
Functions ¶
Types ¶
type BasicHistoryIterator ¶ added in v1.0.0
type BasicHistoryIterator struct {
// contains filtered or unexported fields
}
func (*BasicHistoryIterator) Backward ¶ added in v1.0.0
func (bhi *BasicHistoryIterator) Backward() string
func (*BasicHistoryIterator) Forward ¶ added in v1.0.0
func (bhi *BasicHistoryIterator) Forward() string
type BasicHistoryManager ¶ added in v1.0.0
type BasicHistoryManager struct {
// contains filtered or unexported fields
}
func NewBasicHistoryManager ¶ added in v1.0.0
func NewBasicHistoryManager(maxKeep int) *BasicHistoryManager
func (*BasicHistoryManager) Exit ¶ added in v1.0.0
func (h *BasicHistoryManager) Exit()
func (*BasicHistoryManager) GetIterator ¶ added in v1.0.0
func (h *BasicHistoryManager) GetIterator() HistoryIterator
func (*BasicHistoryManager) Push ¶ added in v1.0.0
func (h *BasicHistoryManager) Push(value string)
func (*BasicHistoryManager) Search ¶ added in v1.0.0
func (h *BasicHistoryManager) Search(pattern string) []string
type CompletionFunc ¶ added in v1.0.0
type CompletionFunc func(beforeCursor string, afterCursor string, full string) *Suggestions
type FileLock ¶ added in v1.0.0
type FileLock struct {
// contains filtered or unexported fields
}
func NewFileLock ¶ added in v1.0.0
type HistoryIterator ¶ added in v1.0.0
type HistoryManager ¶ added in v1.0.0
type HistoryManager interface { Exit() GetIterator() HistoryIterator Push(string) Search(string) []string }
type PersistedHistoryManager ¶ added in v1.0.0
type PersistedHistoryManager struct { *BasicHistoryManager // contains filtered or unexported fields }
func NewPersistedHistoryManager ¶ added in v1.0.0
func NewPersistedHistoryManager(maxKeep int, filename string) *PersistedHistoryManager
func (*PersistedHistoryManager) Exit ¶ added in v1.0.0
func (pm *PersistedHistoryManager) Exit()
func (*PersistedHistoryManager) Push ¶ added in v1.0.0
func (pm *PersistedHistoryManager) Push(value string)
type Reader ¶ added in v1.0.0
type Reader struct {
// contains filtered or unexported fields
}
func NewReader ¶ added in v1.0.0
func NewReader(config ReaderConfig) *Reader
func (*Reader) GetWindowSize ¶ added in v1.0.0
func (*Reader) MoveCursorToRenderEnd ¶ added in v1.0.0
func (*Reader) MoveCursorToRenderStart ¶ added in v1.0.0
func (r *Reader) MoveCursorToRenderStart()
func (*Reader) ReadLoop ¶ added in v1.0.0
ReadLoop reads commands from the standard input and blocks until exit
func (*Reader) SetEditCursorPosition ¶ added in v1.0.0
type ReaderConfig ¶ added in v1.0.0
type ReaderConfig struct { CompletionFunction CompletionFunc ProcessFunction func(string) error HistoryManager HistoryManager PromptFunction func() string Debug bool LogFile string }
type Suggestion ¶ added in v1.0.0
func NewSuggestion ¶ added in v1.0.1
func NewSuggestion(display string, value string) *Suggestion
type Suggestions ¶ added in v1.0.0
type Suggestions struct { Total int // reflects the total (could be longer than len(.Items) Items []*Suggestion }
func NewSuggestions ¶ added in v1.0.1
func NewSuggestions() *Suggestions
func (*Suggestions) Add ¶ added in v1.0.1
func (s *Suggestions) Add(suggestion *Suggestion)
Add will always reset the total after the suggestion is added, thus it is necessary to set the total after, if it is different than the length of suggestions
Source Files
¶
Click to show internal directories.
Click to hide internal directories.