Documentation
¶
Index ¶
- Constants
- func Extend(word *WordType, wordPos int, extStr string, complete bool) utilfn.StrWithPos
- func ResetWordOffsets(words []*WordType, startIdx int)
- func SimpleVarNamePrefix(ectx ExpandContext, word *WordType, pos int) (string, bool)
- type CmdType
- type CompletionPos
- type ExpandContext
- type ExpandInfo
- type QuoteContext
- type WordType
Constants ¶
View Source
const ( CompTypeCommandMeta = "command-meta" CompTypeCommand = "command" CompTypeArg = "command-arg" CompTypeInvalid = "invalid" CompTypeVar = "var" CompTypeAssignment = "assignment" CompTypeBasic = "basic" CompTypeFile = "file" CompTypeDir = "dir" )
View Source
const ( WordTypeRaw = "raw" WordTypeLit = "lit" // (can-extend) WordTypeOp = "op" // single: & ; | ( ) < > \n multi(2): && || ;; << >> <& >& <> >| (( multi(3): <<- ('((' requires special processing) WordTypeKey = "key" // if then else elif fi do done case esac while until for in { } ! (( [[ WordTypeGroup = "grp" // contains other words e.g. "hello"foo'bar'$x (has-subs) (can-extend) WordTypeSimpleVar = "svar" // simplevar $ (can-extend) WordTypeDQ = "dq" // " (quote-context) (can-extend) (has-subs) WordTypeDDQ = "ddq" // $" (can-extend) (has-subs) (for quotecontext, uses WordTypeDQ) WordTypeVarBrace = "varb" // ${ (quote-context) (can-extend) (internals not parsed) WordTypeDP = "dp" // $( (quote-context) (has-subs) WordTypeBQ = "bq" // ` (quote-context) (has-subs) WordTypeSQ = "sq" // ' (can-extend) WordTypeDSQ = "dsq" // $' (can-extend) WordTypeDPP = "dpp" // $(( (internals not parsed) WordTypePP = "pp" // (( (internals not parsed) WordTypeDB = "db" // $[ (internals not parsed) )
can-extend: WordTypeLit, WordTypeSimpleVar, WordTypeVarBrace, WordTypeDQ, WordTypeDDQ, WordTypeSQ, WordTypeDSQ
View Source
const ( CmdTypeNone = "none" // holds control structures: '(' ')' 'for' 'while' etc. CmdTypeSimple = "simple" // holds real commands )
View Source
const MaxExpandLen = 64 * 1024
Variables ¶
This section is empty.
Functions ¶
func ResetWordOffsets ¶
func SimpleVarNamePrefix ¶
func SimpleVarNamePrefix(ectx ExpandContext, word *WordType, pos int) (string, bool)
returns varname (no '$') and ok (whether this is a valid varname expansion)
Types ¶
type CmdType ¶
type CmdType struct { Type string AssignmentWords []*WordType Words []*WordType NoneComplete bool // set to true when last-word is a "separator" }
func ParseCommands ¶
type CompletionPos ¶
type CompletionPos struct { RawPos int // the raw position of cursor SuperOffset int // adjust all offsets in Cmd and CmdWord by SuperOffset CompType string // see CompType* constants Cmd *CmdType // nil if between commands or a special completion (otherwise will be a SimpleCommand) // index into cmd.Words (only set when Cmd is not nil, otherwise we look at CompCommand) // 0 means command-word // negative means assignment-words. // can be past the end of Words (means start new word). CmdWordPos int CompWord *WordType // set to the word we are completing (nil if we are starting a new word) CompWordOffset int // offset into compword (only if CmdWord is not nil) }
func FindCompletionPos ¶
func FindCompletionPos(cmds []*CmdType, pos int) CompletionPos
func (CompletionPos) Extend ¶
func (cpos CompletionPos) Extend(origStr utilfn.StrWithPos, extensionStr string, extensionComplete bool) utilfn.StrWithPos
type ExpandContext ¶
type ExpandContext struct {
HomeDir string
}
type ExpandInfo ¶
type ExpandInfo struct { HasTilde bool // only ~ as the first character when SimpleExpandContext.HomeDir is set HasVar bool // $x, $$, ${...} HasGlob bool // *, ?, [, { HasExtGlob bool // ?(...) ... ?*+@! HasHistory bool // ! (anywhere) HasSpecial bool // subshell, arith }
func SimpleExpand ¶
func SimpleExpand(ectx ExpandContext, word *WordType) (string, ExpandInfo)
func SimpleExpandPrefix ¶
func SimpleExpandPrefix(ectx ExpandContext, word *WordType, pos int) (string, ExpandInfo)
type QuoteContext ¶
type QuoteContext []string
type WordType ¶
type WordType struct { Type string Offset int QC QuoteContext Raw []rune Complete bool Prefix []rune Subs []*WordType }
func CommandsToWords ¶
func MakeEmptyWord ¶
func MakeEmptyWord(wtype string, qc QuoteContext, offset int, complete bool) *WordType
Click to show internal directories.
Click to hide internal directories.