readline

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CharNull      = 0
	CharLineStart = 1
	CharBackward  = 2
	CharInterrupt = 3
	CharDelete    = 4
	CharLineEnd   = 5
	CharForward   = 6
	CharBell      = 7
	CharCtrlH     = 8
	CharTab       = 9
	CharCtrlJ     = 10
	CharKill      = 11
	CharCtrlL     = 12
	CharEnter     = 13
	CharNext      = 14
	CharPrev      = 16
	CharBckSearch = 18
	CharFwdSearch = 19
	CharTranspose = 20
	CharCtrlU     = 21
	CharCtrlW     = 23
	CharCtrlY     = 25
	CharCtrlZ     = 26
	CharEsc       = 27
	CharSpace     = 32
	CharEscapeEx  = 91
	CharBackspace = 127
)
View Source
const (
	KeyDel    = 51
	KeyUp     = 65
	KeyDown   = 66
	KeyRight  = 67
	KeyLeft   = 68
	MetaEnd   = 70
	MetaStart = 72
)
View Source
const (
	CursorUp    = "\033[1A"
	CursorDown  = "\033[1B"
	CursorRight = "\033[1C"
	CursorLeft  = "\033[1D"

	CursorSave    = "\033[s"
	CursorRestore = "\033[u"

	CursorUpN    = "\033[%dA"
	CursorDownN  = "\033[%dB"
	CursorRightN = "\033[%dC"
	CursorLeftN  = "\033[%dD"

	CursorEOL  = "\033[E"
	CursorBOL  = "\033[1G"
	CursorHide = "\033[?25l"
	CursorShow = "\033[?25h"

	ClearToEOL  = "\033[K"
	ClearLine   = "\033[2K"
	ClearScreen = "\033[2J"
	CursorReset = "\033[0;0f"

	ColorGrey    = "\033[38;5;245m"
	ColorDefault = "\033[0m"

	StartBracketedPaste = "\033[?2004h"
	EndBracketedPaste   = "\033[?2004l"
)
View Source
const (
	CharBracketedPaste      = 50
	CharBracketedPasteStart = "00~"
	CharBracketedPasteEnd   = "01~"
)

Variables

View Source
var (
	ErrInterrupt = errors.New("Interrupt")
)

Functions

func IsTerminal

func IsTerminal(fd int) bool

IsTerminal returns true if the given file descriptor is a terminal.

func UnsetRawMode

func UnsetRawMode(fd int, termios any) error

Types

type Buffer

type Buffer struct {
	Pos       int
	Buf       *arraylist.List
	Prompt    *Prompt
	LineWidth int
	Width     int
	Height    int
}

func NewBuffer

func NewBuffer(prompt *Prompt) (*Buffer, error)

func (*Buffer) Add

func (b *Buffer) Add(r rune)

func (*Buffer) ClearScreen

func (b *Buffer) ClearScreen()

func (*Buffer) Delete

func (b *Buffer) Delete()

func (*Buffer) DeleteBefore

func (b *Buffer) DeleteBefore()

func (*Buffer) DeleteRemaining

func (b *Buffer) DeleteRemaining()

func (*Buffer) DeleteWord

func (b *Buffer) DeleteWord()

func (*Buffer) IsEmpty

func (b *Buffer) IsEmpty() bool

func (*Buffer) MoveLeft

func (b *Buffer) MoveLeft()

func (*Buffer) MoveLeftWord

func (b *Buffer) MoveLeftWord()

func (*Buffer) MoveRight

func (b *Buffer) MoveRight()

func (*Buffer) MoveRightWord

func (b *Buffer) MoveRightWord()

func (*Buffer) MoveToEnd

func (b *Buffer) MoveToEnd()

func (*Buffer) MoveToStart

func (b *Buffer) MoveToStart()

func (*Buffer) Remove

func (b *Buffer) Remove()

func (*Buffer) Replace

func (b *Buffer) Replace(r []rune)

func (*Buffer) Size

func (b *Buffer) Size() int

func (*Buffer) String

func (b *Buffer) String() string

func (*Buffer) StringN

func (b *Buffer) StringN(n int) string

func (*Buffer) StringNM

func (b *Buffer) StringNM(n, m int) string

type History

type History struct {
	Buf      *arraylist.List
	Autosave bool
	Pos      int
	Limit    int
	Filename string
	Enabled  bool
}

func NewHistory

func NewHistory() (*History, error)

func (*History) Add

func (h *History) Add(l []rune)

func (*History) Clear

func (h *History) Clear()

func (*History) Compact

func (h *History) Compact()

func (*History) Init

func (h *History) Init() error

func (*History) Next

func (h *History) Next() []rune

func (*History) Prev

func (h *History) Prev() []rune

func (*History) Save

func (h *History) Save() error

func (*History) Size

func (h *History) Size() int

type Instance

type Instance struct {
	Prompt   *Prompt
	Terminal *Terminal
	History  *History
	Pasting  bool
}

func New

func New(prompt Prompt) (*Instance, error)

func (*Instance) HistoryDisable

func (i *Instance) HistoryDisable()

func (*Instance) HistoryEnable

func (i *Instance) HistoryEnable()

func (*Instance) Readline

func (i *Instance) Readline() (string, error)

type InterruptError

type InterruptError struct {
	Line []rune
}

func (*InterruptError) Error

func (*InterruptError) Error() string

type Prompt

type Prompt struct {
	Prompt         string
	AltPrompt      string
	Placeholder    string
	AltPlaceholder string
	UseAlt         bool
}

type Terminal

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

func NewTerminal

func NewTerminal() (*Terminal, error)

func (*Terminal) Read

func (t *Terminal) Read() (rune, error)

type Termios

type Termios syscall.Termios

func SetRawMode

func SetRawMode(fd int) (*Termios, error)

Jump to

Keyboard shortcuts

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