terminal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

pkg/backend/terminal/color.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer represents a screen buffer

func NewBuffer

func NewBuffer(size geometry.Size) *Buffer

NewBuffer creates a new buffer with the given size

func (*Buffer) Clear

func (b *Buffer) Clear()

Clear clears the buffer

func (*Buffer) CopyFrom

func (b *Buffer) CopyFrom(other *Buffer)

CopyFrom copies the contents of another buffer

func (*Buffer) GetCell

func (b *Buffer) GetCell(x, y int) (Cell, bool)

GetCell gets a cell from the buffer

func (*Buffer) GetCursor

func (b *Buffer) GetCursor() geometry.Point

GetCursor returns the current cursor position

func (*Buffer) MoveCursor

func (b *Buffer) MoveCursor(dx, dy int)

MoveCursor moves the cursor relative to its current position

func (*Buffer) Resize

func (b *Buffer) Resize(size geometry.Size)

Resize resizes the buffer

func (*Buffer) SetCell

func (b *Buffer) SetCell(x, y int, ch rune, combining []rune, style tcell.Style)

SetCell sets a cell in the buffer

func (*Buffer) SetCursor

func (b *Buffer) SetCursor(x, y int)

SetCursor sets the cursor position

func (*Buffer) Size

func (b *Buffer) Size() geometry.Size

Size returns the current size of the buffer

type Capabilities

type Capabilities struct {
	ColorMode      ColorMode
	Unicode        bool
	Italic         bool
	Strikethrough  bool
	Mouse          bool
	ModifiedKeys   bool
	BracketedPaste bool
	URLs           bool
	Title          bool
}

Capabilities represents what the terminal supports

func DetectCapabilities

func DetectCapabilities(screen tcell.Screen) Capabilities

DetectCapabilities returns the terminal's capabilities

type Cell

type Cell struct {
	Rune      rune
	Style     tcell.Style
	Combining []rune
	Width     int
}

Cell represents a single character cell in the buffer

type ClipboardProvider

type ClipboardProvider interface {
	Get() (string, error)
	Set(content string) error
}

ClipboardProvider defines the interface for clipboard operations

type ColorMode

type ColorMode int

ColorMode represents the level of color support

const (
	ColorNone ColorMode = iota
	Color16
	Color256
	ColorTrueColor
)

type ColorOptimizer

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

ColorOptimizer handles color optimization and caching

func NewColorOptimizer

func NewColorOptimizer(mode ColorMode) *ColorOptimizer

func (*ColorOptimizer) GetColor

func (co *ColorOptimizer) GetColor(c color.Color) tcell.Color

GetColor returns an optimized tcell.Color for the given core_color.Color

type Config

type Config struct {
	EnableMouse   bool
	MouseMode     MouseMode
	ColorMode     tcell.Color
	PollInterval  time.Duration
	HandleSuspend bool
	HandleResize  bool
	CaptureEvents bool
}

Config holds terminal configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default terminal configuration

type Event

type Event interface {
	When() time.Time
}

Event represents a terminal event

type FallbackClipboard

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

FallbackClipboard provides in-memory clipboard when system clipboard is unavailable

func (*FallbackClipboard) Get

func (c *FallbackClipboard) Get() (string, error)

func (*FallbackClipboard) Set

func (c *FallbackClipboard) Set(content string) error

type KeyEvent

type KeyEvent struct {
	Key       tcell.Key
	Rune      rune
	Modifiers tcell.ModMask
	// contains filtered or unexported fields
}

Event types for the terminal

func (KeyEvent) When

func (e KeyEvent) When() time.Time

type MouseEvent

type MouseEvent struct {
	Buttons  tcell.ButtonMask
	Position geometry.Point
	// contains filtered or unexported fields
}

func (MouseEvent) When

func (e MouseEvent) When() time.Time

type MouseMode

type MouseMode int

MouseMode represents different mouse handling modes

const (
	MouseDisabled MouseMode = iota
	MouseClick
	MouseDrag
	MouseMotion
)

type StyleMask

type StyleMask uint16

StyleMask represents different text style attributes

const (
	StyleBold StyleMask = 1 << iota
	StyleBlink
	StyleReverse
	StyleUnderline
	StyleDim
	StyleItalic
	StyleStrikethrough
)

type SystemClipboard

type SystemClipboard struct{}

SystemClipboard implements platform-specific clipboard operations

func (*SystemClipboard) Get

func (c *SystemClipboard) Get() (string, error)

func (*SystemClipboard) Set

func (c *SystemClipboard) Set(content string) error

type Terminal

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

Terminal represents a terminal backend

func New

func New() (*Terminal, error)

New creates a new terminal with default configuration

func NewWithConfig

func NewWithConfig(config *Config) (*Terminal, error)

NewWithConfig creates a new terminal with the provided configuration

func NewWithScreen

func NewWithScreen(screen tcell.Screen, config *Config) (*Terminal, error)

NewWithScreen creates a new terminal with a provided screen

func (*Terminal) Capabilities

func (t *Terminal) Capabilities() Capabilities

func (*Terminal) Clear

func (t *Terminal) Clear()

func (*Terminal) ColorMode

func (t *Terminal) ColorMode() ColorMode

func (*Terminal) DisableCombiningChars

func (t *Terminal) DisableCombiningChars()

func (*Terminal) DisableMouse

func (t *Terminal) DisableMouse()

func (*Terminal) DisableUnicode

func (t *Terminal) DisableUnicode()

func (*Terminal) DrawCell

func (t *Terminal) DrawCell(x, y int, ch rune, fg, bg color.Color)

func (*Terminal) DrawRegion

func (t *Terminal) DrawRegion(region geometry.Rect, style tcell.Style, ch rune)

func (*Terminal) DrawStyledCell

func (t *Terminal) DrawStyledCell(x, y int, ch rune, fg, bg color.Color, style StyleMask)

func (*Terminal) DrawText

func (t *Terminal) DrawText(x, y int, text string, fg, bg color.Color, style StyleMask)

DrawText draws a string of text, handling combining characters appropriately

func (*Terminal) EnableCombiningChars

func (t *Terminal) EnableCombiningChars()

func (*Terminal) EnableMouse

func (t *Terminal) EnableMouse()

func (*Terminal) EnableUnicode

func (t *Terminal) EnableUnicode()

func (*Terminal) EnterAltScreen

func (t *Terminal) EnterAltScreen() error

func (*Terminal) ExitAltScreen

func (t *Terminal) ExitAltScreen() error

func (*Terminal) GetClipboard

func (t *Terminal) GetClipboard() (string, error)

GetClipboard retrieves the clipboard content

func (*Terminal) GetCursor

func (t *Terminal) GetCursor() geometry.Point

func (*Terminal) GetTitle

func (t *Terminal) GetTitle() string

GetTitle returns the current terminal window title

func (*Terminal) HandleEvents

func (t *Terminal) HandleEvents(handler func(Event) bool)

Add this new method

func (*Terminal) HideCursor

func (t *Terminal) HideCursor()

func (*Terminal) Init

func (t *Terminal) Init() error

func (*Terminal) OnFocusChange

func (t *Terminal) OnFocusChange(callback func(bool))

func (*Terminal) OnResize

func (t *Terminal) OnResize(callback func(geometry.Size))

func (*Terminal) OnResume

func (t *Terminal) OnResume(callback func())

func (*Terminal) OnSuspend

func (t *Terminal) OnSuspend(callback func())

func (*Terminal) Present

func (t *Terminal) Present() error

func (*Terminal) Resume

func (t *Terminal) Resume() error

func (*Terminal) SetClipboard

func (t *Terminal) SetClipboard(content string) error

SetClipboard sets the clipboard content

func (*Terminal) SetCursor

func (t *Terminal) SetCursor(x, y int)

func (*Terminal) SetMouseMode

func (t *Terminal) SetMouseMode(mode MouseMode)

func (*Terminal) SetTitle

func (t *Terminal) SetTitle(title string)

SetTitle sets the terminal window title

func (*Terminal) Shutdown

func (t *Terminal) Shutdown() error

func (*Terminal) Size

func (t *Terminal) Size() geometry.Size

func (*Terminal) StringWidth

func (t *Terminal) StringWidth(s string) int

func (*Terminal) SupportsColor

func (t *Terminal) SupportsColor() bool

func (*Terminal) SupportsTrueColor

func (t *Terminal) SupportsTrueColor() bool

func (*Terminal) SupportsUnicode

func (t *Terminal) SupportsUnicode() bool

func (*Terminal) Suspend

func (t *Terminal) Suspend() error

func (*Terminal) SwapBuffers

func (t *Terminal) SwapBuffers()

SwapBuffers swaps the front and back buffers

func (*Terminal) Sync

func (t *Terminal) Sync()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳