termutil

package
v0.0.0-...-1be313f Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MouseModeNone MouseMode = iota
	MouseModeX10
	MouseModeVT200
	MouseModeVT200Highlight
	MouseModeButtonEvent
	MouseModeAnyEvent
	MouseExtNone MouseExtMode = iota
	MouseExtUTF
	MouseExtSGR
	MouseExtURXVT
)
View Source
const (
	MainBuffer     uint8 = 0
	AltBuffer      uint8 = 1
	InternalBuffer uint8 = 2
)
View Source
const TabSize = 8

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Image  image.Image
	Text   string
	Width  float64 // Width in cells
	Height float64 // Height in cells
}

type Buffer

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

func NewBuffer

func NewBuffer(width, height uint16, maxLines uint64, fg tcell.Color, bg tcell.Color) *Buffer

NewBuffer creates a new terminal buffer

func (*Buffer) BottomMargin

func (buffer *Buffer) BottomMargin() uint

func (*Buffer) ClearHighlight

func (buffer *Buffer) ClearHighlight()

func (*Buffer) ClearSelection

func (buffer *Buffer) ClearSelection()

func (*Buffer) CursorColumn

func (buffer *Buffer) CursorColumn() uint16

Column returns cursor column

func (*Buffer) CursorLine

func (buffer *Buffer) CursorLine() uint16

CursorLine returns cursor line (in Origin Mode it is relative to the top margin)

func (*Buffer) CursorLineAbsolute

func (buffer *Buffer) CursorLineAbsolute() uint16

CursorLineAbsolute returns absolute cursor line coordinate (ignoring Origin Mode) - view format

func (*Buffer) ExtendSelectionToEntireLines

func (buffer *Buffer) ExtendSelectionToEntireLines()

func (*Buffer) FindWordAt

func (buffer *Buffer) FindWordAt(pos Position, runeMatcher RuneMatcher) (start Position, end Position, text string, textIndex int, found bool)

returns raw lines

func (*Buffer) GetBoundedTextAtPosition

func (buffer *Buffer) GetBoundedTextAtPosition(pos Position) (start Position, end Position, text string, textIndex int, found bool)

func (*Buffer) GetCell

func (buffer *Buffer) GetCell(viewCol uint16, viewRow uint16) *Cell

func (*Buffer) GetCursorShape

func (buffer *Buffer) GetCursorShape() CursorShape

func (*Buffer) GetHighlightAnnotation

func (buffer *Buffer) GetHighlightAnnotation() *Annotation

func (*Buffer) GetMaxLines

func (buffer *Buffer) GetMaxLines() uint64

func (*Buffer) GetScrollOffset

func (buffer *Buffer) GetScrollOffset() uint

func (*Buffer) GetSelection

func (buffer *Buffer) GetSelection() (string, *Selection)

func (*Buffer) GetVPosition

func (buffer *Buffer) GetVPosition() int

func (*Buffer) GetViewHighlight

func (buffer *Buffer) GetViewHighlight() (start Position, end Position, exists bool)

func (*Buffer) GetVisibleLines

func (buffer *Buffer) GetVisibleLines() []Line

func (*Buffer) GetVisibleSixels

func (b *Buffer) GetVisibleSixels() []VisibleSixel

func (*Buffer) HasScrollableRegion

func (buffer *Buffer) HasScrollableRegion() bool

func (*Buffer) Height

func (buffer *Buffer) Height() int

func (*Buffer) Highlight

func (buffer *Buffer) Highlight(start Position, end Position, annotation *Annotation)

takes raw coords

func (*Buffer) InScrollableRegion

func (buffer *Buffer) InScrollableRegion() bool

func (*Buffer) InSelection

func (buffer *Buffer) InSelection(pos Position) bool

func (*Buffer) IsApplicationCursorKeysModeEnabled

func (buffer *Buffer) IsApplicationCursorKeysModeEnabled() bool

func (*Buffer) IsCursorVisible

func (buffer *Buffer) IsCursorVisible() bool

func (*Buffer) IsNewLineMode

func (buffer *Buffer) IsNewLineMode() bool

func (*Buffer) IsTabSetAtCursor

func (buffer *Buffer) IsTabSetAtCursor() bool

func (*Buffer) RawLine

func (buffer *Buffer) RawLine() uint64

cursor Y (raw)

func (*Buffer) ScrollDown

func (buffer *Buffer) ScrollDown(lines uint)

func (*Buffer) ScrollToEnd

func (buffer *Buffer) ScrollToEnd()

func (*Buffer) ScrollUp

func (buffer *Buffer) ScrollUp(lines uint)

func (*Buffer) SelectWordAt

func (buffer *Buffer) SelectWordAt(pos Position, runeMatcher RuneMatcher)

func (*Buffer) SetCursorShape

func (buffer *Buffer) SetCursorShape(shape CursorShape)

func (*Buffer) SetScrollOffset

func (buffer *Buffer) SetScrollOffset(offset uint)

func (*Buffer) SetSelectionEnd

func (buffer *Buffer) SetSelectionEnd(pos Position)

func (*Buffer) SetSelectionStart

func (buffer *Buffer) SetSelectionStart(pos Position)

func (*Buffer) TopMargin

func (buffer *Buffer) TopMargin() uint

func (*Buffer) ViewHeight

func (buffer *Buffer) ViewHeight() uint16

func (*Buffer) ViewWidth

func (buffer *Buffer) ViewWidth() uint16

func (*Buffer) Width

func (buffer *Buffer) Width() uint16

Width returns the width of the buffer in columns

type Cell

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

func (*Cell) Dirty

func (cell *Cell) Dirty() bool

func (*Cell) Rune

func (cell *Cell) Rune() MeasuredRune

func (*Cell) SetDirty

func (cell *Cell) SetDirty(d bool)

func (*Cell) Style

func (cell *Cell) Style() tcell.Style

type Colour

type Colour uint8
const (
	ColourBlack Colour = iota
	ColourRed
	ColourGreen
	ColourYellow
	ColourBlue
	ColourMagenta
	ColourCyan
	ColourWhite
	ColourBrightBlack
	ColourBrightRed
	ColourBrightGreen
	ColourBrightYellow
	ColourBrightBlue
	ColourBrightMagenta
	ColourBrightCyan
	ColourBrightWhite
	ColourBackground
	ColourForeground
	ColourSelectionBackground
	ColourSelectionForeground
	ColourCursorForeground
	ColourCursorBackground
)

See https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit

type CursorShape

type CursorShape uint8
const (
	CursorShapeDefault CursorShape = iota
	CursorShapeBlinkingBlock
	CursorShapeSteadyBlock
	CursorShapeBlinkingUnderline
	CursorShapeSteadyUnderline
	CursorShapeBlinkingBar
	CursorShapeSteadyBar
)

type EventTitle

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

func (*EventTitle) Title

func (ev *EventTitle) Title() string

func (*EventTitle) When

func (ev *EventTitle) When() time.Time

type Line

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

func (*Line) Len

func (line *Line) Len() uint16

func (*Line) String

func (line *Line) String() string

type MeasuredRune

type MeasuredRune struct {
	Rune  rune
	Width int
}

type Modes

type Modes struct {
	ShowCursor            bool
	ApplicationCursorKeys bool
	BlinkingCursor        bool
	ReplaceMode           bool // overwrite character at cursor or insert new
	OriginMode            bool // see DECOM docs - whether cursor is positioned within the margins or not
	LineFeedMode          bool
	ScreenMode            bool // DECSCNM (black on white background)
	AutoWrap              bool
	BracketedPasteMode    bool
}

type MouseExtMode

type MouseExtMode uint

type MouseMode

type MouseMode uint

type Option

type Option func(t *Terminal)

func WithTheme

func WithTheme(theme *Theme) Option

func WithWindowManipulator

func WithWindowManipulator(m WindowManipulator) Option

type Position

type Position struct {
	Line uint64
	Col  uint16
}

type RuneMatcher

type RuneMatcher func(r rune) bool

type Selection

type Selection struct {
	Start Position
	End   Position
}

type Sixel

type Sixel struct {
	X    uint16
	Y    uint64 // raw line
	Data []byte
}

type Terminal

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

Terminal communicates with the underlying terminal

func New

func New(options ...Option) *Terminal

NewTerminal creates a new terminal instance

func (*Terminal) GetActiveBuffer

func (t *Terminal) GetActiveBuffer() *Buffer

func (*Terminal) GetMouseExtMode

func (t *Terminal) GetMouseExtMode() MouseExtMode

func (*Terminal) GetMouseMode

func (t *Terminal) GetMouseMode() MouseMode

func (*Terminal) GetTitle

func (t *Terminal) GetTitle() string

func (*Terminal) Pty

func (t *Terminal) Pty() *os.File

Pty exposes the underlying terminal pty, if it exists

func (*Terminal) Run

func (t *Terminal) Run(c *exec.Cmd, rows uint16, cols uint16, attr *syscall.SysProcAttr, eventCh chan tcell.Event) error

Run starts the terminal/shell proxying process

func (*Terminal) SetRedraw

func (t *Terminal) SetRedraw(b bool)

func (*Terminal) SetSize

func (t *Terminal) SetSize(rows, cols uint16) error

func (*Terminal) SetWindowManipulator

func (t *Terminal) SetWindowManipulator(m WindowManipulator)

func (*Terminal) ShouldRedraw

func (t *Terminal) ShouldRedraw() bool

func (*Terminal) Theme

func (t *Terminal) Theme() *Theme

func (*Terminal) Write

func (t *Terminal) Write(data []byte) (n int, err error)

write takes data from StdOut of the child shell and processes it

func (*Terminal) WriteToPty

func (t *Terminal) WriteToPty(data []byte) error

type Theme

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

func (*Theme) ColourFrom24Bit

func (t *Theme) ColourFrom24Bit(r, g, b string) (tcell.Color, error)

func (*Theme) ColourFrom4Bit

func (t *Theme) ColourFrom4Bit(code uint8) tcell.Color

func (*Theme) ColourFrom8Bit

func (t *Theme) ColourFrom8Bit(n string) (tcell.Color, error)

func (*Theme) ColourFromAnsi

func (t *Theme) ColourFromAnsi(ansi []string) (tcell.Color, error)

func (*Theme) CursorBackground

func (t *Theme) CursorBackground() tcell.Color

func (*Theme) CursorForeground

func (t *Theme) CursorForeground() tcell.Color

func (*Theme) DefaultBackground

func (t *Theme) DefaultBackground() tcell.Color

func (*Theme) DefaultForeground

func (t *Theme) DefaultForeground() tcell.Color

type ThemeFactory

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

func NewThemeFactory

func NewThemeFactory() *ThemeFactory

func (*ThemeFactory) Build

func (t *ThemeFactory) Build() *Theme

func (*ThemeFactory) WithColour

func (t *ThemeFactory) WithColour(key Colour, colour tcell.Color) *ThemeFactory

type VisibleSixel

type VisibleSixel struct {
	ViewLineOffset int
	Sixel          Sixel
}

type WindowManipulator

type WindowManipulator interface {
	State() WindowState
	Minimise()
	Maximise()
	Restore()
	SetTitle(title string)
	Position() (int, int)
	SizeInPixels() (int, int)
	CellSizeInPixels() (int, int)
	SizeInChars() (int, int)
	ResizeInPixels(int, int)
	ResizeInChars(int, int)
	ScreenSizeInPixels() (int, int)
	ScreenSizeInChars() (int, int)
	Move(x, y int)
	IsFullscreen() bool
	SetFullscreen(enabled bool)
	GetTitle() string
	SaveTitleToStack()
	RestoreTitleFromStack()
	ReportError(err error)
}

type WindowState

type WindowState uint8
const (
	StateUnknown WindowState = iota
	StateMinimised
	StateNormal
	StateMaximised
)

Jump to

Keyboard shortcuts

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