package inputrc

Import Path
	github.com/reeflective/readline/inputrc (on go.dev)

Dependency Relation
	imports 13 packages, and imported by 11 packages

Involved Source Files bind.go config.go constants.go Package inputrc parses readline inputrc files. parse.go
Code Examples package main import ( "os/user" "github.com/reeflective/readline/inputrc" ) func main() { u, err := user.Current() if err != nil { panic(err) } cfg := inputrc.NewDefaultConfig() if err := inputrc.UserDefault(u, cfg, inputrc.WithApp("bash")); err != nil { panic(err) } } package main import ( "fmt" "strings" "github.com/reeflective/readline/inputrc" ) func main() { const example = ` set editing-mode vi $if Usql set keymap vi-insert "\r": a-usql-action "\d": 'echo test\n' $endif ` cfg := inputrc.NewDefaultConfig() if err := inputrc.Parse(strings.NewReader(example), cfg, inputrc.WithApp("usql")); err != nil { panic(err) } fmt.Println("editing mode:", cfg.GetString("editing-mode")) fmt.Println("vi-insert:") fmt.Printf(" %s: %s\n", inputrc.Escape(string(inputrc.Return)), cfg.Binds["vi-insert"][string(inputrc.Return)].Action) fmt.Printf(" %s: '%s'\n", inputrc.Escape(string(inputrc.Delete)), inputrc.EscapeMacro(cfg.Binds["vi-insert"][string(inputrc.Delete)].Action)) }
Package-Level Type Names (total 8)
/* sort by: | */
Bind represents a key binding. Action string Macro bool func DefaultBinds() map[string]map[string]Bind func github.com/reeflective/readline/internal/history.(*Sources).Last() Bind func github.com/reeflective/readline/internal/keymap.MatchLocal(eng *keymap.Engine) (bind Bind, command func(), prefix bool) func github.com/reeflective/readline/internal/keymap.MatchMain(eng *keymap.Engine) (bind Bind, command func(), prefix bool) func github.com/reeflective/readline/internal/keymap.(*Engine).ActiveCommand() Bind func github.com/reeflective/readline/internal/history.(*Sources).SaveWithCommand(bind Bind)
Config is a inputrc config handler. Binds map[string]map[string]Bind Funcs map[string]func(string, string) error ReadFileFunc func(string) ([]byte, error) Vars map[string]interface{} Bind satisfies the Handler interface. Do satisfies the Handler interface. Get satisfies the Handler interface. GetBool returns the var name as a bool. GetInt returns the var name as a int. GetString returns the var name as a string. ReadFile satisfies the Handler interface. Set satisfies the Handler interface. *Config : Handler func NewConfig() *Config func NewDefaultConfig(opts ...ConfigOption) *Config func github.com/reeflective/readline/internal/keymap.NewEngine(keys *core.Keys, i *core.Iterations, opts ...Option) (*keymap.Engine, *Config) func UserDefault(u *user.User, cfg *Config, opts ...Option) error func github.com/reeflective/readline/internal/completion.NewEngine(h *ui.Hint, km *keymap.Engine, o *Config) *completion.Engine func github.com/reeflective/readline/internal/core.WaitAvailableKeys(keys *core.Keys, cfg *Config) func github.com/reeflective/readline/internal/display.NewEngine(k *core.Keys, s *core.Selection, h *history.Sources, p *ui.Prompt, i *ui.Hint, c *completion.Engine, opts *Config) *display.Engine func github.com/reeflective/readline/internal/history.NewSources(line *core.Line, cur *core.Cursor, hint *ui.Hint, opts *Config) *history.Sources func github.com/reeflective/readline/internal/ui.NewPrompt(line *core.Line, cursor *core.Cursor, keymaps *keymap.Engine, opts *Config) *ui.Prompt
ConfigOption is a inputrc config handler option. func WithConfigReadFileFunc(readFileFunc func(string) ([]byte, error)) ConfigOption func NewDefaultConfig(opts ...ConfigOption) *Config
Error is a error. Error satisfies the error interface. Error : error const ErrBindMissingClosingQuote const ErrElseWithoutMatchingIf const ErrEndifWithoutMatchingIf const ErrInvalidEditingMode const ErrInvalidKeymap const ErrMacroMissingClosingQuote const ErrMissingColon const ErrUnknownModifier
Handler is the handler interface. Bind binds a key sequence to an action for the current keymap. Do handles $constructs. Get gets the value. ReadFile reads a file. Set sets the value. *Config func Parse(r io.Reader, h Handler, opts ...Option) error func ParseBytes(buf []byte, h Handler, opts ...Option) error func ParseFile(name string, h Handler, opts ...Option) error func (*Parser).Parse(stream io.Reader, handler Handler) error
Option is a parser option. func WithApp(app string) Option func WithHaltOnErr(haltOnErr bool) Option func WithMode(mode string) Option func WithName(name string) Option func WithStrict(strict bool) Option func WithTerm(term string) Option func New(opts ...Option) *Parser func Parse(r io.Reader, h Handler, opts ...Option) error func ParseBytes(buf []byte, h Handler, opts ...Option) error func ParseFile(name string, h Handler, opts ...Option) error func UserDefault(u *user.User, cfg *Config, opts ...Option) error func github.com/reeflective/readline.NewShell(opts ...Option) *readline.Shell func github.com/reeflective/readline/internal/keymap.NewEngine(keys *core.Keys, i *core.Iterations, opts ...Option) (*keymap.Engine, *Config) func github.com/reeflective/readline/internal/keymap.(*Engine).ReloadConfig(opts ...Option) (err error)
ParseError is a parse error. Err error Line int Name string Text string Error satisfies the error interface. Unwrap satisfies the errors.Unwrap call. *ParseError : error *ParseError : golang.org/x/xerrors.Wrapper
Parser is a inputrc parser. Errs returns the parse errors encountered. Parse parses inputrc data from the reader, passing sets and binding keys to h based on the configured options. func New(opts ...Option) *Parser
Package-Level Functions (total 25)
Decontrol decodes a Control-c code.
DefaultBinds are the default readline bind keymaps. see: INPUTRC=/dev/null bash -c 'bind -pm <keymap>'
DefaultVars are the default readline vars. see: INPUTRC=/dev/null bash -c 'bind -v'
Demeta decodes a Meta-c code.
Encontrol encodes a Control-c code.
Enmeta encodes a Meta-c code.
Escape escapes a inputrc string.
EscapeMacro escapes a inputrc macro.
IsControl returns true when c is a Control-c code.
IsMeta returns true when c is a Meta-c code.
New creates a new inputrc parser.
NewConfig creates a new inputrc config.
NewDefaultConfig creates a new inputrc config with default values.
Parse parses inputrc data from r.
ParseBytes parses inputrc data from buf.
ParseFile parses inputrc data from a file name.
Unescape unescapes a inputrc string.
UserDefault loads default inputrc settings for the user.
WithApp is a parser option to set the app name.
WithConfigReadFileFunc is a inputrc config option to set the func used for ReadFile operations.
WithHaltOnErr is a parser option to set halt on every encountered error.
WithMode is a parser option to set the mode name.
WithName is a parser option to set the file name.
WithStrict is a parser option to set strict keymap parsing.
WithTerm is a parser option to set the term name.
Package-Level Constants (total 20)
Keys.
Keys.
Keys.
Keys.
ErrBindMissingClosingQuote is the bind missing closing quote error.
ErrElseWithoutMatchingIf is the $else without matching $if error.
ErrEndifWithoutMatchingIf is the $endif without matching $if error.
ErrInvalidEditingMode is the invalid editing mode error.
ErrInvalidKeymap is the invalid keymap error.
ErrMacroMissingClosingQuote is the macro missing closing quote error.
ErrMissingColon is the missing : error.
ErrUnknownModifier is the unknown modifier error.
Keys.
Keys.
Keys.
Keys.
Keys.
Keys.
Keys.
Keys.