screen

package
v0.0.0-...-799c34b Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorForeground uint8 = iota
	ColorBackground
	ColorSpecial
)
View Source
const RGBMask = 1 << 31

Variables

View Source
var JSConst []byte

JSConst will contain a javascript representation of the constants above.

Functions

func EncodedInt

func EncodedInt(n int) []byte

EncodedInt creates 1-5 bytes representing a 32 bit integer depending on the value. This allows for integers to be sent using only the bytes necessary to represent their values, instead of using a fixed byte size. Each byte contributes 7 bits, with the high bit (0x80) used to indicate that the next byte contributes to the value.

Types

type Attr

type Attr uint8

Attr is a set of screen cell attributes.

const (
	AttrReverse Attr = 1 << iota
	AttrItalic
	AttrBold
	AttrUnderline
	AttrUndercurl
	AttrEnd
)

Cell attributes

type Cell

type Cell struct {
	Char rune
	Sent bool
	*CellAttrs
}

type CellAttrs

type CellAttrs struct {
	Attrs Attr
	Fg    Color
	Bg    Color
	Sp    Color
	// contains filtered or unexported fields
}

type Color

type Color int32

Color can represent a 24 bit RGB color or indexed color.

func ColorFromBytes

func ColorFromBytes(b []byte) Color

func (Color) B

func (c Color) B() uint8

func (Color) Bytes

func (c Color) Bytes() []byte

func (Color) G

func (c Color) G() uint8

func (Color) R

func (c Color) R() uint8

func (Color) String

func (c Color) String() string

func (Color) Term

func (c Color) Term() uint8

type Mode

type Mode uint8

Mode is the Neovim mode and other state information.

const (
	ModeBusy Mode = 1 << iota
	ModeMouseOn
	ModeNormal
	ModeInsert
	ModeReplace
	ModeRedraw
	ModeEnd
)

Modes

type Op

type Op uint8

Op is the screen operation type.

const (
	OpResize Op = iota + 1
	OpClear
	OpKeyboard
	OpCursor
	OpPalette
	OpStyle
	OpPut
	OpPutRep
	OpTitle
	OpIcon
	OpBell
	OpScroll
	OpFlush
	OpLog
	OpEnd
)

Screen operations.

type Screen

type Screen struct {
	Size   Vector2 // Screen size.
	Cursor Vector2 // Cursor postion.

	Title string

	// Current mode.
	Mode Mode

	// Mouse state. This updates Mode.
	Mouse bool

	// Busy state. This updates Mode.
	Busy bool

	// Default attributes for updating attributes.
	DefaultAttrs *CellAttrs

	// Current attributes for new characters.
	CurAttrs *CellAttrs

	// The rendered screen.
	Buffer []Cell
	// contains filtered or unexported fields
}

func NewScreen

func NewScreen(w, h int) *Screen

NewScreen creates a new screen.

func (*Screen) RedrawHandler

func (s *Screen) RedrawHandler(updates ...[]interface{})

RedrawHandler deals with the msgpack input from Neovim

func (*Screen) SetSink

func (s *Screen) SetSink(w io.Writer)

SetSink sets the writer to receive operation writes. The full screen is sent to the new client.

type ScrollRegion

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

type StreamBuffer

type StreamBuffer struct {
	bytes.Buffer
}

StreamBuffer is the same as bytes.Buffer with a few additions.

func (*StreamBuffer) WriteColor

func (s *StreamBuffer) WriteColor(c Color) (int, error)

func (*StreamBuffer) WriteEncodedInt

func (s *StreamBuffer) WriteEncodedInt(n int) (int, error)

func (*StreamBuffer) WriteEncodedInts

func (s *StreamBuffer) WriteEncodedInts(run ...int) (n int, err error)

func (*StreamBuffer) WriteOp

func (s *StreamBuffer) WriteOp(op Op) error

func (*StreamBuffer) WriteRuneRun

func (s *StreamBuffer) WriteRuneRun(str []rune) (n int, err error)

WriteRuneRun writes a run of runes by prefixing the bytes with a length.

func (*StreamBuffer) WriteStringRun

func (s *StreamBuffer) WriteStringRun(str string) (n int, err error)

WriteStringRun is a convenience for WriteRuneRun.

type Vector2

type Vector2 struct {
	X int
	Y int
}

Jump to

Keyboard shortcuts

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