cli

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HistoryFilename = ".wsget_history"
	HistoryLimit    = 100

	MacOSDeleteKey = 127

	HideCursor = "\x1b[?25l"
	ShowCursor = "\x1b[?25h"

	Bell = "\a"
)
View Source
const (
	LineUp         = "\x1b[1A"
	LineClear      = "\x1b[2K"
	NewLine        = '\n'
	ReturnCarriege = "\r"
	Backspace      = "\b"
)
View Source
const (
	HistoryFileRigths = 0o644
)
View Source
const (
	KeyboardBufferSize = 10
)
View Source
const (
	PastingTimingThresholdInMicrosec = 250
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

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

func NewCLI

func NewCLI(wsConn *ws.Connection, input Inputer, output io.Writer) (*CLI, error)

func (*CLI) RequestMod added in v0.2.0

func (c *CLI) RequestMod(keysEvents <-chan keyboard.KeyEvent) error

func (*CLI) Run

func (c *CLI) Run(opts RunOptions) error

type Content added in v0.2.0

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

func NewContent added in v0.2.0

func NewContent() *Content

func (*Content) Clear added in v0.2.0

func (c *Content) Clear() string

func (*Content) GetLinesAfterPosition added in v0.2.0

func (c *Content) GetLinesAfterPosition(pos int) (startOfLine int, lines []string)

func (*Content) InsertSymbol added in v0.2.0

func (c *Content) InsertSymbol(symbol rune) string

func (*Content) MovePositionLeft added in v0.2.0

func (c *Content) MovePositionLeft() string

func (*Content) MovePositionRight added in v0.2.0

func (c *Content) MovePositionRight() string

func (*Content) MoveToEnd added in v0.2.0

func (c *Content) MoveToEnd() string

func (*Content) PrevSymbol added in v0.2.0

func (c *Content) PrevSymbol() rune

func (*Content) RemoveSymbol added in v0.2.0

func (c *Content) RemoveSymbol() string

func (*Content) ReplaceText added in v0.2.0

func (c *Content) ReplaceText(text string) string

func (*Content) String added in v0.2.0

func (c *Content) String() string

func (*Content) ToRequest added in v0.2.0

func (c *Content) ToRequest() string

type Editor added in v0.2.0

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

func NewEditor added in v0.2.0

func NewEditor(output io.Writer, history *History) *Editor

func (*Editor) EditRequest added in v0.2.0

func (ed *Editor) EditRequest(keyStream <-chan keyboard.KeyEvent, initBuffer string) (string, error)

type History

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

func NewHistory

func NewHistory(fileName string, limit uint) *History

func (*History) AddRequest

func (h *History) AddRequest(request string)

func (*History) NextRequst added in v0.2.0

func (h *History) NextRequst() string

func (*History) PrevRequst added in v0.2.0

func (h *History) PrevRequst() string

func (*History) ResetPosition added in v0.2.0

func (h *History) ResetPosition()

func (*History) SaveToFile added in v0.1.2

func (h *History) SaveToFile() error

type Inputer added in v0.2.0

type Inputer interface {
	GetKeys() (<-chan keyboard.KeyEvent, error)
	Close()
}

type Keyboard added in v0.2.0

type Keyboard struct{}

func NewKeyboard added in v0.2.0

func NewKeyboard() *Keyboard

func (*Keyboard) Close added in v0.2.0

func (k *Keyboard) Close()

func (*Keyboard) GetKeys added in v0.2.0

func (k *Keyboard) GetKeys() (<-chan keyboard.KeyEvent, error)

type RunOptions added in v0.2.0

type RunOptions struct {
	OutputFile  *os.File
	StartEditor bool
}

Jump to

Keyboard shortcuts

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