readline

package
v0.0.0-...-d78e010 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration for display

func GetTerminalSize

func GetTerminalSize() (width, height int, err error)

GetTerminalSize returns the current terminal size

func IsTerminal

func IsTerminal(fd int) bool

IsTerminal checks if the given file descriptor is a terminal

func ParsePortRange

func ParsePortRange(portRange string) ([]int, error)

ParsePortRange parses a port range string like "80-443" or "22,80,443"

func ShellSyntaxHighlighter

func ShellSyntaxHighlighter(input string) string

ShellSyntaxHighlighter provides syntax highlighting for shell commands

Types

type CompletionResult

type CompletionResult struct {
	Text        string
	Description string
	Type        string
}

CompletionResult represents a completion match

type EditMode

type EditMode int

EditMode represents the editing mode (emacs or vi)

const (
	EmacsMode EditMode = iota
	ViInsertMode
	ViCommandMode
)

type Editor

type Editor struct {
	// contains filtered or unexported fields
}

Editor represents a readline editor with rlwrap-like features

func NewEditor

func NewEditor() *Editor

NewEditor creates a new readline editor with rlwrap-like features

func (*Editor) AcceptAutoSuggestion

func (e *Editor) AcceptAutoSuggestion()

AcceptAutoSuggestion accepts the current auto-suggestion

func (*Editor) AcceptAutoSuggestionWord

func (e *Editor) AcceptAutoSuggestionWord()

AcceptAutoSuggestionWord accepts one word from auto-suggestion

func (*Editor) AddAlias

func (e *Editor) AddAlias(alias, command string)

AddAlias adds a command alias

func (*Editor) AddCompletion

func (e *Editor) AddCompletion(word string)

AddCompletion adds a static completion word

func (*Editor) AddFilter

func (e *Editor) AddFilter(filter Filter)

AddFilter adds an input/output filter

func (*Editor) AddHistoryEntry

func (e *Editor) AddHistoryEntry(entry string)

AddHistoryEntry adds a command to history with deduplication

func (*Editor) AddToKillRing

func (e *Editor) AddToKillRing(text string)

AddToKillRing adds text to the kill ring

func (*Editor) CapitalizeWord

func (e *Editor) CapitalizeWord()

CapitalizeWord capitalizes word

func (*Editor) ClearHistory

func (e *Editor) ClearHistory()

ClearHistory clears the command history

func (*Editor) CopyRegion

func (e *Editor) CopyRegion()

CopyRegion copies selected text to kill ring

func (*Editor) EnableAutoSuggestion

func (e *Editor) EnableAutoSuggestion(enabled bool)

EnableAutoSuggestion enables fish-like auto-suggestions from history

func (*Editor) EnableBracketMatching

func (e *Editor) EnableBracketMatching(enabled bool)

EnableBracketMatching enables bracket matching highlighting

func (*Editor) EnableMultiLine

func (e *Editor) EnableMultiLine(enabled bool)

EnableMultiLine enables multi-line editing

func (*Editor) EndMacro

func (e *Editor) EndMacro()

EndMacro stops recording and saves the macro

func (*Editor) GetAliases

func (e *Editor) GetAliases() map[string]string

GetAliases returns all defined aliases

func (*Editor) GetHistory

func (e *Editor) GetHistory() []string

GetHistory returns a copy of the command history

func (*Editor) GetSelection

func (e *Editor) GetSelection() string

GetSelection returns selected text between mark and cursor

func (*Editor) IncrementalSearch

func (e *Editor) IncrementalSearch(forward bool)

IncrementalSearch performs incremental search through history

func (*Editor) KillRegion

func (e *Editor) KillRegion()

KillRegion cuts selected text to kill ring

func (*Editor) LowercaseWord

func (e *Editor) LowercaseWord()

LowercaseWord converts word to lowercase

func (*Editor) PlayMacro

func (e *Editor) PlayMacro(key rune)

PlayMacro plays a recorded macro

func (*Editor) Readline

func (e *Editor) Readline() (string, error)

Readline reads a line from stdin with rlwrap-like features

func (*Editor) Redo

func (e *Editor) Redo()

Redo reapplies undone change

func (*Editor) RemoveAlias

func (e *Editor) RemoveAlias(alias string)

RemoveAlias removes a command alias

func (*Editor) SetCompletionFunction

func (e *Editor) SetCompletionFunction(fn func(string) []string)

SetCompletionFunction sets a custom completion function

func (*Editor) SetCompletions

func (e *Editor) SetCompletions(words []string)

SetCompletions sets the list of completion words

func (*Editor) SetEditMode

func (e *Editor) SetEditMode(mode EditMode)

SetEditMode sets the editing mode (emacs or vi)

func (*Editor) SetEmacsMode

func (e *Editor) SetEmacsMode()

SetEmacsMode enables emacs editing mode (default)

func (*Editor) SetHintFunction

func (e *Editor) SetHintFunction(fn func(string) string)

SetHintFunction sets a function that provides hints while typing

func (*Editor) SetHistoryFile

func (e *Editor) SetHistoryFile(path string)

SetHistoryFile sets the history file path for persistent history

func (*Editor) SetIgnoreCase

func (e *Editor) SetIgnoreCase(ignore bool)

SetIgnoreCase sets case sensitivity for completions and search

func (*Editor) SetMark

func (e *Editor) SetMark()

SetMark sets the mark for selection

func (*Editor) SetMaxHistory

func (e *Editor) SetMaxHistory(max int)

SetMaxHistory sets the maximum number of history entries

func (*Editor) SetPrompt

func (e *Editor) SetPrompt(prompt string)

SetPrompt sets the prompt string with optional color

func (*Editor) SetPromptColor

func (e *Editor) SetPromptColor(enabled bool, c *color.Color)

SetPromptColor enables/disables colored prompt

func (*Editor) SetSyntaxHighlighter

func (e *Editor) SetSyntaxHighlighter(fn SyntaxHighlighter)

SetSyntaxHighlighter sets a custom syntax highlighter function

func (*Editor) SetValidator

func (e *Editor) SetValidator(fn func(string) bool)

SetValidator sets a function that validates input before accepting

func (*Editor) SetViMode

func (e *Editor) SetViMode()

SetViMode enables vi editing mode

func (*Editor) SetWordBreakChars

func (e *Editor) SetWordBreakChars(chars string)

SetWordBreakChars sets the characters that break words

func (*Editor) StartMacro

func (e *Editor) StartMacro(key rune)

StartMacro starts recording a keyboard macro

func (*Editor) TransposeChars

func (e *Editor) TransposeChars()

TransposeChars swaps character before cursor with character at cursor

func (*Editor) TransposeWords

func (e *Editor) TransposeWords()

TransposeWords swaps word before cursor with word after cursor

func (*Editor) Undo

func (e *Editor) Undo()

Undo reverts to previous state

func (*Editor) UppercaseWord

func (e *Editor) UppercaseWord()

UppercaseWord converts word to uppercase

func (*Editor) ViModeIndicator

func (e *Editor) ViModeIndicator() string

ViModeIndicator returns a string indicating current vi mode

func (*Editor) YankFromKillRing

func (e *Editor) YankFromKillRing()

YankFromKillRing pastes from kill ring

func (*Editor) YankPop

func (e *Editor) YankPop()

YankPop cycles through kill ring

type Filter

type Filter interface {
	ProcessInput(input string) string
	ProcessOutput(output string) string
	ProcessPrompt(prompt string) string
}

Filter represents an input/output filter similar to rlwrap filters

type PasswordFilter

type PasswordFilter struct {
	// contains filtered or unexported fields
}

Simple password filter that hides password prompts

func NewPasswordFilter

func NewPasswordFilter(patterns []string) *PasswordFilter

NewPasswordFilter creates a new password filter

func (*PasswordFilter) ProcessInput

func (pf *PasswordFilter) ProcessInput(input string) string

func (*PasswordFilter) ProcessOutput

func (pf *PasswordFilter) ProcessOutput(output string) string

func (*PasswordFilter) ProcessPrompt

func (pf *PasswordFilter) ProcessPrompt(prompt string) string

type SyntaxHighlighter

type SyntaxHighlighter func(input string) string

SyntaxHighlighter is a function that colorizes input

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL