package strutil
Import Path
github.com/reeflective/readline/internal/strutil (on go.dev)
Dependency Relation
imports 14 packages, and imported by 6 packages
Package-Level Type Names (only one)
KeywordSwitcher is a function modifying a given word, returning:
@done => If true, the handler performed a change.
@switched => The updated word.
@bpos => Offset to begin position.
@epos => Offset to end position.
func KeywordSwitchers() []KeywordSwitcher
Package-Level Functions (total 14)
AdjustNumberOperatorPos returns an adjusted cursor position when
the word around the cursor is an expression with an operator.
AdjustSurroundQuotes returns the correct mark and cursor positions when
we want to know where a shell word enclosed with quotes (and potentially
having inner ones) starts and ends.
ConvertMeta recursively searches for metafied keys in a sequence,
and replaces them with an esc prefix and their unmeta equivalent.
FormatTabs replaces all '\t' occurrences in a string with 6 spaces each.
GetQuotedWordStart returns the position of the outmost containing quote
of the word (going backward from the end of the provided line), if the
current word is a shell word that is not closed yet.
Ex: `this 'quote contains "surrounded" words`. the outermost quote is the single one.
IsBracket returns true if the character is an opening/closing bracket/brace/parenthesis.
IsSurround returns true if the character is a quote or a bracket/brace, etc.
KeywordSwitchers returns all keywordSwitchers of the shell.
LineSpan computes the number of columns and lines that are needed for a given line,
accounting for any ANSI escapes/color codes, and tabulations replaced with 4 spaces.
MatchSurround returns the matching character of a rune that
is either a bracket/brace/parenthesis, or a single/double quote.
Quote translates one rune in its printable version,
which might be different for Control/Meta characters.
Returns the "translated" string and new length. (eg 0x04 => ^C = len:2).
RealLength returns the real length of a string (the number of terminal
columns used to render the line, which may contain special graphemes).
Before computing the width, it replaces tabs with (4) spaces, and strips colors.
Split splits a string according to /bin/sh's word-splitting rules. It
supports backslash-escapes, single-quotes, and double-quotes. Notably it does
not support the $” style of quoting. It also doesn't attempt to perform any
other sort of expansion, including brace expansion, shell expansion, or
pathname expansion.
If the given input has an unterminated quoted string or ends in a
backslash-escape, one of UnterminatedSingleQuoteError,
UnterminatedDoubleQuoteError, or UnterminatedEscapeError is returned.
SurroundType says if the character is a pairing one (first boolean),
and if the character is the closing part of the pair (second boolean).
Package-Level Variables (only one)
NewlineMatcher is a regular expression matching all newlines or returned newlines.
![]() |
The pages are generated with Golds v0.8.2. (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. |