Documentation
¶
Index ¶
- Variables
- func EnableSurrogatePair(value bool)
- func IsSurrogatePairEnabled() bool
- func ResetCharWidth()
- func SetCharWidth(c rune, width int)
- type Buffer
- func (B *Buffer) CurrentWord() (string, int)
- func (B *Buffer) CurrentWordTop() (wordTop int)
- func (B *Buffer) Delete(pos int, n int) WidthT
- func (B *Buffer) DrawFromHead()
- func (B *Buffer) GetKey() (string, error)
- func (B *Buffer) GetWidthBetween(from int, to int) WidthT
- func (B *Buffer) GotoHead()
- func (B *Buffer) InsertAndRepaint(str string)
- func (B *Buffer) InsertString(pos int, s string) int
- func (B *Buffer) RefreshColor() ColorSequence
- func (B *Buffer) RepaintAfterPrompt()
- func (B *Buffer) RepaintAll()
- func (B *Buffer) ReplaceAndRepaint(pos int, str string)
- func (B *Buffer) ResetViewStart()
- func (B Buffer) String() string
- func (B *Buffer) SubString(start, end int) string
- func (B *Buffer) ViewWidth() WidthT
- func (B *Buffer) Write(b []byte) (int, error)
- type Cell
- type ColorSequence
- type Coloring
- type Command
- type Editor
- type GoCommand
- type IHistory
- type ITty
- type KeyGoFuncT
- type KeyMap
- func (km *KeyMap) BindKey(key keys.Code, f Command)
- func (km *KeyMap) BindKeyClosure(name string, f func(context.Context, *Buffer) Result) error
- func (km *KeyMap) BindKeyFunc(key string, f Command) error
- func (km *KeyMap) BindKeySymbol(key, funcName string) error
- func (km *KeyMap) GetBindKey(key string) Command
- type Moji
- type Result
- type WidthT
- func GetStringWidth(s string) WidthTdeprecated
Constants ¶
This section is empty.
Variables ¶
var CmdAcceptLine = NewGoCommand("ACCEPT_LINE", cmdAcceptLine)
var CmdBackwardChar = NewGoCommand("BACKWARD_CHAR", cmdBackwardChar)
var CmdBackwardDeleteChar = NewGoCommand("BACKWARD_DELETE_CHAR", cmdBackwardDeleteChar)
var CmdBackwardWord = NewGoCommand("BACKWARD_WORD", cmdBackwardWord)
var CmdBeginningOfLine = NewGoCommand("BEGINNING_OF_LINE", cmdBeginningOfLine)
var CmdClearScreen = NewGoCommand("CLEAR_SCREEN", cmdClearScreen)
var CmdDeleteChar = NewGoCommand("DELETE_CHAR", cmdDeleteChar)
var CmdDeleteOrAbort = NewGoCommand("DELETE_OR_ABORT", cmdDeleteOrAbort)
var CmdEndOfLine = NewGoCommand("END_OF_LINE", cmdEndOfLine)
var CmdForwardChar = NewGoCommand("FORWARD_CHAR", cmdForwardChar)
var CmdForwardWord = NewGoCommand("FORWARD_WORD", cmdForwardWord)
var CmdISearchBackward = NewGoCommand("ISEARCH_BACKWARD", cmdISearchBackward)
var CmdInterrupt = NewGoCommand("INTR", cmdInterrupt)
var CmdKillLine = NewGoCommand("KILL_LINE", cmdKillLine)
var CmdKillWholeLine = NewGoCommand("KILL_WHOLE_LINE", cmdKillWholeLine)
var CmdNextHistory = NewGoCommand("NEXT_HISTORY", cmdNextHistory)
var CmdPreviousHistory = NewGoCommand("PREVIOUS_HISTORY", cmdPreviousHistory)
var CmdQuotedInsert = NewGoCommand("QUOTED_INSERT", cmdQuotedInsert)
var CmdRepaintOnNewline = NewGoCommand("REPAINT_ON_NEWLINE", cmdRepaintOnNewline)
var CmdSwapChar = NewGoCommand("SWAPCHAR", cmdSwapChar)
var CmdUndo = NewGoCommand("UNDO", cmdUndo)
var CmdUnixLineDiscard = NewGoCommand("UNIX_LINE_DISCARD", cmdUnixLineDiscard)
var CmdUnixWordRubout = NewGoCommand("UNIX_WORD_RUBOUT", cmdUnixWordRubout)
var CmdYank = NewGoCommand("YANK", cmdYank)
var CmdYankWithQuote = NewGoCommand("YANK_WITH_QUOTE", cmdYankWithQuote)
var CtrlC = errors.New("^C")
CtrlC is the error when Ctrl-C is pressed.
var Delimiters = "\"'"
Delimiters means the quationmarks. The whitespace enclosed by them are not treat as parameters separator.
Functions ¶
func EnableSurrogatePair ¶ added in v0.11.0
func EnableSurrogatePair(value bool)
func IsSurrogatePairEnabled ¶ added in v0.11.0
func IsSurrogatePairEnabled() bool
func ResetCharWidth ¶
func ResetCharWidth()
func SetCharWidth ¶
Types ¶
type Buffer ¶
type Buffer struct {
*Editor
Buffer []Cell
ViewStart int
// contains filtered or unexported fields
}
Buffer is ReadLine's internal data structure
func (*Buffer) CurrentWord ¶
CurrentWord returns the current word the cursor exists and word's position
func (*Buffer) CurrentWordTop ¶
CurrentWordTop returns the position of the current word the cursor exists
func (*Buffer) Delete ¶
Delete remove Buffer[pos:pos+n]. It returns the width to clear the end of line. It does not update screen.
func (*Buffer) DrawFromHead ¶
func (B *Buffer) DrawFromHead()
DrawFromHead draw all text in viewarea and move screen-cursor to the position where it should be.
func (*Buffer) GetWidthBetween ¶
GetWidthBetween returns the width between start and end
func (*Buffer) GotoHead ¶
func (B *Buffer) GotoHead()
GotoHead move screen-cursor to the top of the viewarea. It should be called before text is changed.
func (*Buffer) InsertAndRepaint ¶
InsertAndRepaint inserts str and repaint the editline.
func (*Buffer) InsertString ¶
InsertString inserts string s at pos (Do not update screen) It returns the count of runes
func (*Buffer) RefreshColor ¶ added in v0.6.0
func (B *Buffer) RefreshColor() ColorSequence
func (*Buffer) RepaintAfterPrompt ¶
func (B *Buffer) RepaintAfterPrompt()
RepaintAfterPrompt repaints the all characters in the editline except for prompt.
func (*Buffer) RepaintAll ¶
func (B *Buffer) RepaintAll()
RepaintAll repaints the all characters in the editline including prompt.
func (*Buffer) ReplaceAndRepaint ¶
ReplaceAndRepaint replaces the string between `pos` and cursor's position to `str`
func (*Buffer) ResetViewStart ¶
func (B *Buffer) ResetViewStart()
ResetViewStart set ViewStart the new value which should be. It does not update screen.
type Cell ¶ added in v0.9.0
type Cell struct {
Moji Moji
// contains filtered or unexported fields
}
type ColorSequence ¶ added in v0.10.0
type ColorSequence int64
const ( Black ColorSequence = 3 | ((30 + iota) << colorCodeBitSize) | (49 << (colorCodeBitSize * 2)) | (1 << (colorCodeBitSize * 3)) Red Green Yellow Blue Magenta Cyan White DefaultForeGroundColor )
const ( DarkGray ColorSequence = 3 | ((30 + iota) << colorCodeBitSize) | (22 << (colorCodeBitSize * 2)) | (49 << (colorCodeBitSize * 3)) DarkRed DarkGree DarkYellow DarkBlue DarkMagenta DarkCyan DarkWhite )
func SGR1 ¶ added in v0.6.3
func SGR1(n1 int) ColorSequence
func SGR2 ¶ added in v0.6.3
func SGR2(n1, n2 int) ColorSequence
func SGR3 ¶ added in v0.6.3
func SGR3(n1, n2, n3 int) ColorSequence
func SGR4 ¶ added in v0.6.3
func SGR4(n1, n2, n3, n4 int) ColorSequence
type Coloring ¶ added in v0.6.0
type Coloring interface {
// Reset has to initialize receiver's fields and return default color.
Init() ColorSequence
// Next has to return color for the given rune.
Next(rune) ColorSequence
}
type Editor ¶
type Editor struct {
KeyMap
History IHistory
Writer io.Writer
Out *bufio.Writer
Prompt func() (int, error)
Default string
Cursor int
LineFeed func(Result)
Tty ITty
Coloring Coloring
HistoryCycling bool
}
Editor is the main class to hold the parameter for ReadLine
func (*Editor) GetBindKey ¶ added in v0.8.4
GetBindKey returns the function assigned to given key
type GoCommand ¶ added in v0.11.1
GoCommand is the implement of Command which has a name and a function
func NewGoCommand ¶ added in v0.11.1
type IHistory ¶
IHistory is the interface ReadLine can use as container for history. It can be set to Editor.History field
type KeyMap ¶
KeyMap is the class for key-bindings
var GlobalKeyMap KeyMap
GlobalKeyMap is the global keymap for users' customizing
func (*KeyMap) BindKeyClosure ¶
BindKeyClosure binds closure to key by name
func (*KeyMap) BindKeyFunc ¶
BindKeyFunc binds function to key
func (*KeyMap) BindKeySymbol ¶
BindKeySymbol assigns function to key by names.
func (*KeyMap) GetBindKey ¶
GetBindKey returns the function assigned to given key
type Moji ¶
func StringToMoji ¶ added in v0.9.0
type Result ¶
type Result int
Result is the type for readline's result.
const ( // CONTINUE is returned by key-functions to continue the line editor CONTINUE Result = iota // ENTER is returned by key-functions when Enter key is pressed ENTER Result = iota // ABORT is returned by key-functions when Ctrl-D is pressed with no command-line ABORT Result = iota // INTR is returned by key-functions when Ctrl-C is pressed INTR Result = iota )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
example1
command
|
|
|
farmer
command
|
|
|
runeview
command
|
|
|
internal
|
|
|
test
|
|
|
color-default-symbol
command
|
|
|
color-sgr
command
|
|
|
unicodetest
command
|
|

