seq

package
v0.0.0-...-4aa4c59 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Byte [limits.BytesPerBuffer]byte
	// contains filtered or unexported fields
}

Buffer defines an I/O buffer for Terminal control/data byte sequences.

func (*Buffer) Cap

func (buf *Buffer) Cap() int

Cap returns the byte capacity of buf.

func (*Buffer) Configure

func (buf *Buffer) Configure(mode eol.Mode) *Buffer

Configure initializes the Buffer configuration.

func (*Buffer) Last

func (buf *Buffer) Last() []byte

func (*Buffer) Len

func (buf *Buffer) Len() int

Len returns the number of bytes in buf.

func (*Buffer) Parse

func (buf *Buffer) Parse(isPasting bool) (r rune, n int)

Parse tries to parse a key sequence from buf. If successful, it returns the key r and its size n in bytes. Otherwise, it returns key.Error and n=0.

Parse does its best to recognize sequences defined by VT10x and xterm line disciplines.

Parse consumes the bytes that contribute to the returned key r. If an entire sequence could not be parsed, no bytes are consumed.

func (*Buffer) Read

func (buf *Buffer) Read(p []byte) (n int, err error)

Read copies up to len(p) unread bytes from buf to p and returns the number of bytes copied.

func (*Buffer) ReadByte

func (buf *Buffer) ReadByte() (b byte, err error)

ReadByte returns the next unread byte from buf and a nil error. If buf is empty, returns 0, io.EOF.

To avoid ambiguous validity of the returned byte, ReadByte will always return either a valid byte and nil error, or an invalid byte and non-nil error. In particular, ReadByte never returns a byte read along with error == io.EOF.

func (*Buffer) ReadFrom

func (buf *Buffer) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom copies bytes from r to buf until all bytes have been read or an error was encountered. Returns the number of bytes successfully copied.

A successful ReadFrom returns err == nil and not err == io.EOF. ReadFrom is defined to read from r until all bytes have been read (io.EOF), so it does not treat io.EOF from r as an error to be reported.

Bytes are copied directly without any buffering, so r and buf must not overlap if both are implemented as buffers of physical memory.

func (*Buffer) Reset

func (buf *Buffer) Reset()

Reset sets the Buffer length to 0.

func (*Buffer) Write

func (buf *Buffer) Write(p []byte) (n int, err error)

Write appends up to len(p) bytes from p to buf and returns the number of bytes copied.

Write will only write to the free space in buf and then return ErrWriteOverflow if all of p could not be copied.

func (*Buffer) WriteByte

func (buf *Buffer) WriteByte(b byte) (err error)

WriteByte appends b to buf and returns nil. If buf is full, returns ErrWriteOverflow.

func (*Buffer) WriteEOL

func (buf *Buffer) WriteEOL() (n int, err error)

WriteEOL appends the configured end of line sequence to buf.

func (*Buffer) WriteTo

func (buf *Buffer) WriteTo(w io.Writer) (n int64, err error)

WriteTo copies bytes from buf to w until all bytes have been written or an error was encountered. Returns the number of bytes successfully copied.

Bytes are copied directly without any buffering, so w and buf must not overlap if both are implemented as buffers of physical memory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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