Source File
inline.go
Belonging Package
github.com/reeflective/readline/internal/display
package displayimport ()// AcceptInline replaces the line buffer with the inline suggestion when one// applies at the cursor, clears the suggestion, and reports whether it did so.// Callers pass the line/cursor to accept onto, since the engine's own line may// point at a minibuffer during completion or search.func ( *Engine) ( *core.Line, *core.Cursor) bool {if !.inlineAcceptable(, ) {return false}.Set([]rune(.inline)...).Set(.Len()).inline = ""return true}// AcceptInlineWord accepts the next word of the inline suggestion, leaving the// rest as a suggestion. It follows forward-word semantics: any leading// whitespace plus the following run of non-whitespace runes are inserted.func ( *Engine) ( *core.Line, *core.Cursor) {if !.inlineAcceptable(, ) {return}:= []rune(.inline):= .Len():= [:]:= 0for < len() && unicode.IsSpace([]) {++}for < len() && !unicode.IsSpace([]) {++}.Set([:+]...).Set(.Len())if + >= len() {.inline = ""}}// inlineAcceptable reports whether the inline suggestion can be accepted onto// the given line: the cursor must be at the end of the line and the suggestion// must extend it (mirrors the display gate in inlineSuggestionApplies).func ( *Engine) ( *core.Line, *core.Cursor) bool {return .inline != "" &&.Pos() == .Len() &&strings.HasPrefix(.inline, string(*)) &&len([]rune(.inline)) > .Len()}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |