Documentation ¶
Index ¶
- Constants
- func CachedQuery(qu Querier, qs string, tty TTY, p Parser, prIn, prOut environ.Proprietor) (string, error)
- func DisableDrawer(name string)
- func DisableTerminal(name string)
- func Draw(img image.Image, bounds image.Rectangle, rsz Resizer, term *Terminal) error
- func DrawWith(img image.Image, bounds image.Rectangle, dr Drawer, rsz Resizer, ...) error
- func GetCursorQuery(qu Querier, tty TTY) (widthCells, heightCells uint, err error)
- func QueryDeviceAttributes(qu Querier, tty TTY, prIn, prOut environ.Proprietor) error
- func RegisterDrawer(d Drawer)
- func RegisterTermChecker(t TermChecker)
- func ResetDrawerList()
- func ResetTerminalCheckerList()
- func SetCursorQuery(widthCells, heightCells uint, qu Querier, tty TTY) (err error)
- func SizeInCellsAndPixels(tty TTY) (widthCells, heightCells, widthPixels, heightPixels uint, err error)
- func SizeInCellsQuery(qu Querier, tty TTY) (widthCells, heightCells uint, e error)
- func SizeInPixelsQuery(qu Querier, tty TTY) (widthPixels, heightPixels uint, e error)
- func XTGetTCap(tcap string, qu Querier, tty TTY, prIn, prOut environ.Proprietor) (string, error)
- type CachedQuerier
- type Drawer
- type DrawerCheckerInput
- type Image
- func (i *Image) At(x, y int) color.Color
- func (i *Image) Bounds() image.Rectangle
- func (i *Image) ColorModel() color.Model
- func (i *Image) Decode() error
- func (i *Image) Fit(bounds image.Rectangle, rsz Resizer, sv Surveyor) error
- func (i *Image) GetInband(placementCells image.Rectangle, d Drawer, t *Terminal) (string, error)
- func (i *Image) Image() (image.Image, error)
- func (i *Image) SaveAsFile(t *Terminal, fileExt string, enc ImageEncoder) (rm func() error, err error)
- func (i *Image) SetInband(placementCells image.Rectangle, inband string, d Drawer, t *Terminal) error
- type ImageEncoder
- type Options
- type Parser
- type ParserFunc
- type PartialSurveyor
- type Querier
- type Resizer
- type Surveyor
- type SurveyorDefault
- func (s *SurveyorDefault) GetCursorQuery(qu Querier, tty TTY) (widthCells, heightCells uint, err error)
- func (s *SurveyorDefault) IsPartialSurveyor()
- func (s *SurveyorDefault) SetCursorQuery(xPosCells, yPosCells uint, qu Querier, tty TTY) (err error)
- func (s *SurveyorDefault) SizeInCellsAndPixels(tty TTY) (widthCells, heightCells, widthPixels, heightPixels uint, err error)
- func (s *SurveyorDefault) SizeInCellsQuery(qu Querier, tty TTY) (widthCells, heightCells uint, e error)
- func (s *SurveyorDefault) SizeInPixelsQuery(qu Querier, tty TTY) (widthPixels, heightPixels uint, e error)
- type SurveyorLight
- type SurveyorNoANSI
- type SurveyorNoTIOCGWINSZ
- type TTY
- type TTYProvider
- type TermChecker
- type Terminal
- func (t *Terminal) CellSize() (width, height float64, err error)
- func (t *Terminal) Close() error
- func (t *Terminal) CreateTemp(pattern string) (*os.File, error)
- func (t *Terminal) Draw(img image.Image, bounds image.Rectangle) error
- func (t *Terminal) Drawers() []Drawer
- func (t *Terminal) Exe() string
- func (t *Terminal) GetCursor() (xPosCells, yPosCells uint, err error)
- func (t *Terminal) Name() string
- func (t *Terminal) Printf(format string, a ...any) (int, error)
- func (t *Terminal) Query(qs string, p Parser) (string, error)
- func (t *Terminal) SetCursor(xPosCells, yPosCells uint) (err error)
- func (t *Terminal) SizeInCells() (width, height uint, err error)
- func (t *Terminal) SizeInPixels() (width, height uint, err error)
- func (t *Terminal) Window() wm.Window
- func (t *Terminal) Write(p []byte) (n int, err error)
- func (t *Terminal) WriteString(s string) (n int, err error)
Constants ¶
const ( CheckTermPassed = `passed` CheckTermFailed = `failed` CheckTermDummy = `dummy` // promoted dummy core method )
const ( QueryStringDA1 = "\033[0c" // https://terminalguide.namepad.de/seq/csi_sc/ QueryStringDA2 = "\033[>0c" // https://terminalguide.namepad.de/seq/csi_sc__q/ QueryStringDA3 = "\033[=0c" // https://terminalguide.namepad.de/seq/csi_sc__r/ )
Variables ¶
This section is empty.
Functions ¶
func CachedQuery ¶
func DisableDrawer ¶
func DisableDrawer(name string)
func DisableTerminal ¶
func DisableTerminal(name string)
func DrawWith ¶
func DrawWith(img image.Image, bounds image.Rectangle, dr Drawer, rsz Resizer, term *Terminal) error
DrawWith ...
func GetCursorQuery ¶
GetCursorQuery
func QueryDeviceAttributes ¶
func QueryDeviceAttributes(qu Querier, tty TTY, prIn, prOut environ.Proprietor) error
func ResetDrawerList ¶
func ResetDrawerList()
func SetCursorQuery ¶
SetCursorQuery
func SizeInCellsAndPixels ¶
func SizeInCellsQuery ¶
SizeInCellsQuery - dtterm window manipulation CSI 18 t
func SizeInPixelsQuery ¶
SizeInPixelsQuery - dtterm window manipulation CSI 14 t
Types ¶
type CachedQuerier ¶
type CachedQuerier interface {
CachedQuery(string, TTY, Parser, environ.Proprietor) (string, error)
}
CachedQuerier ...
func NewCachedQuerier ¶
func NewCachedQuerier(qu Querier) CachedQuerier
type Drawer ¶
type Drawer interface { Name() string New() Drawer IsApplicable(DrawerCheckerInput) bool Draw(img image.Image, bounds image.Rectangle, rsz Resizer, term *Terminal) error // TODO }
Drawer ...
func EnabledDrawers ¶
func EnabledDrawers() []Drawer
EnabledDrawers returns all enabled registered drawers
func GetRegDrawerByName ¶
GetRegDrawerByName returns registered drawers
type DrawerCheckerInput ¶
type Image ¶
type Image struct { Original image.Image Resized image.Image Fitted image.Image InBand map[string]inBandString FileName string // lazily loaded Encoded []byte // lazily loaded DrawerSpec map[string]any internal.Closer // contains filtered or unexported fields }
Image ...
func NewImageBytes ¶
NewImageBytes - for lazy loading the file
func NewImageFileName ¶
NewImageFileName - for lazy loading the file
func (*Image) Decode ¶
Decode decodes and stores the image file in the struct. this is not required for some drawers where the file path is passed to the terminal.
Decode requires registration of image decoders.
func (*Image) SaveAsFile ¶
func (i *Image) SaveAsFile(t *Terminal, fileExt string, enc ImageEncoder) (rm func() error, err error)
SaveAsFile writes the image to a temporary file. Defer Image.Close() or call rm() when no longer needed.
type ImageEncoder ¶
type ImageEncoder = internal.ImageEncoder
type Options ¶ added in v0.0.2
type Options struct { PTYName string TTY TTY TTYFallback TTY TTYProvFallback TTYProvider // for NewTerminal() Querier Querier QuerierFallback Querier PartialSurveyor PartialSurveyor PartialSurveyorFallback PartialSurveyor WindowProvider wm.WindowProvider WindowProviderFallback wm.WindowProvider Resizer Resizer Proprietor environ.Proprietor TerminalName string // for ComposeTerminal() Exe string // for ComposeTerminal() Arger internal.Arger // for ComposeTerminal() Drawers []Drawer // for ComposeTerminal() Window wm.Window // for ComposeTerminal() }
func (*Options) CreateTerminal ¶ added in v0.0.2
func (c *Options) CreateTerminal(ch TermChecker) (*Terminal, error)
func (*Options) NewTerminal ¶ added in v0.0.2
func (c *Options) NewTerminal(ch TermChecker) (*Terminal, error)
type ParserFunc ¶
ParserFunc returns true when end of terminal reply is reached.
var StopOnAlpha ParserFunc = func(r rune) bool {
return (r >= 'A' && r <= 'Z') || (r >= 'a' && r <= 'z')
}
StopOnAlpha ...
func (ParserFunc) Parse ¶
func (f ParserFunc) Parse(r rune) bool
Parse returns true when end of terminal reply is reached.
type PartialSurveyor ¶
type PartialSurveyor interface { // TODO doc // TODO wm.Window func IsPartialSurveyor() }
PartialSurveyor implements some of:
- CellSize(tty TTY) (width, height float64, err error)
- CellSizeQuery(qu Querier, tty TTY) (width, height float64, err error)
- SizeInCells(tty TTY) (widthCells, heightCells uint, err error)
- SizeInCellsQuery(qu Querier, tty TTY) (widthCells, heightCells uint, err error)
- SizeInPixels(tty TTY) (widthPixels, heightPixels uint, err error)
- SizeInPixelsQuery(qu Querier, tty TTY) (widthPixels, heightPixels uint, err error)
- SizeInPixelsWindow(w wm.Window) (widthPixels, heightPixels uint, err error)
- SizeInCellsAndPixels(tty TTY) (widthCells, heightCells, widthPixels, heightPixels uint, err error)
- GetCursor(tty TTY) (xPosCells, yPosCells uint, err error)
- GetCursorQuery(qu Querier, tty TTY) (widthCells, heightCells uint, err error)
- SetCursor(xPosCells, yPosCells uint, tty TTY) (err error)
- SetCursorQuery(xPosCells, yPosCells uint, qu Querier, tty TTY) (err error)
type Surveyor ¶
type Surveyor interface { // passes stored TTY, Querier, wm.Window, Proprietor to a SurveyorLight CellSize() (width, height float64, err error) SizeInCells() (width, height uint, err error) SizeInPixels() (width, height uint, err error) GetCursor() (xPosCells, yPosCells uint, err error) SetCursor(xPosCells, yPosCells uint) (err error) }
Surveyor is implemented by Terminal
type SurveyorDefault ¶
type SurveyorDefault struct { }
func (*SurveyorDefault) GetCursorQuery ¶
func (s *SurveyorDefault) GetCursorQuery(qu Querier, tty TTY) (widthCells, heightCells uint, err error)
GetCursorQuery
func (*SurveyorDefault) IsPartialSurveyor ¶
func (s *SurveyorDefault) IsPartialSurveyor()
func (*SurveyorDefault) SetCursorQuery ¶
func (s *SurveyorDefault) SetCursorQuery(xPosCells, yPosCells uint, qu Querier, tty TTY) (err error)
SetCursorQuery
func (*SurveyorDefault) SizeInCellsAndPixels ¶
func (s *SurveyorDefault) SizeInCellsAndPixels(tty TTY) (widthCells, heightCells, widthPixels, heightPixels uint, err error)
SizeInCellsAndPixels ...
func (*SurveyorDefault) SizeInCellsQuery ¶
func (s *SurveyorDefault) SizeInCellsQuery(qu Querier, tty TTY) (widthCells, heightCells uint, e error)
SizeInCellsQuery - dtterm window manipulation CSI 18 t
func (*SurveyorDefault) SizeInPixelsQuery ¶
func (s *SurveyorDefault) SizeInPixelsQuery(qu Querier, tty TTY) (widthPixels, heightPixels uint, e error)
SizeInPixelsQuery - dtterm window manipulation CSI 14 t
type SurveyorLight ¶
type SurveyorLight interface { CellSize(TTY, Querier, wm.Window, environ.Proprietor) (width, height float64, err error) SizeInCells(TTY, Querier, wm.Window, environ.Proprietor) (width, height uint, err error) SizeInPixels(TTY, Querier, wm.Window, environ.Proprietor) (width, height uint, err error) GetCursor(TTY, Querier, wm.Window, environ.Proprietor) (xPosCells, yPosCells uint, err error) SetCursor(xPosCells, yPosCells uint, tty TTY, qu Querier, w wm.Window, pr environ.Proprietor) (err error) }
type SurveyorNoANSI ¶
type SurveyorNoANSI struct{}
func (*SurveyorNoANSI) IsPartialSurveyor ¶
func (s *SurveyorNoANSI) IsPartialSurveyor()
func (*SurveyorNoANSI) SizeInCellsAndPixels ¶
func (s *SurveyorNoANSI) SizeInCellsAndPixels(tty TTY) (widthCells, heightCells, widthPixels, heightPixels uint, err error)
SizeInCellsAndPixels ...
type SurveyorNoTIOCGWINSZ ¶
type SurveyorNoTIOCGWINSZ struct{}
func (*SurveyorNoTIOCGWINSZ) IsPartialSurveyor ¶
func (s *SurveyorNoTIOCGWINSZ) IsPartialSurveyor()
func (*SurveyorNoTIOCGWINSZ) SizeInCellsQuery ¶
func (s *SurveyorNoTIOCGWINSZ) SizeInCellsQuery(qu Querier, tty TTY) (widthCells, heightCells uint, e error)
SizeInCellsQuery - dtterm window manipulation CSI 18 t
func (*SurveyorNoTIOCGWINSZ) SizeInPixelsQuery ¶
func (s *SurveyorNoTIOCGWINSZ) SizeInPixelsQuery(qu Querier, tty TTY) (widthPixels, heightPixels uint, e error)
SizeInPixelsQuery - dtterm window manipulation CSI 14 t
type TTY ¶
type TTY interface { TTYDevName() string // TODO -> io.ReadWriteCloser io.Writer // Write(p []byte) (n int, err error) // io.Writer ReadRune() (r rune, size int, err error) // bufio.Reader.ReadRune() // TODO -> io.Reader Close() error // io.Closer }
TTY ...
type TTYProvider ¶
type TermChecker ¶
type TermChecker interface { // TODO: implement all optional methods through the core and check for nil? // The following methods are implemented by embedded *termCheckerCore. Name() string CheckExclude(environ.Proprietor) (mightBe bool, p environ.Proprietor) CheckIsQuery(Querier, TTY, environ.Proprietor) (is bool, p environ.Proprietor) CheckIsWindow(wm.Window) (is bool, p environ.Proprietor) Check(qu Querier, tty TTY, inp environ.Proprietor) (is bool, p environ.Proprietor) NewTerminal(*Options) (*Terminal, error) CreateTerminal(*Options) (*Terminal, error) Init(tc TermChecker) // called during registration }
TermChecker must implement at least one of CheckExclude, CheckIs, CheckWindow. For passing on properties create a new Proprietor with NewProprietor. CheckExclude is a preliminary check if the to be checked terminal might be the matching terminal of the TermChecker. CheckExclude can set properties for later exclusion of CheckIs checks, etc, no ANSI querying shall be done during this stage. CheckIs is the final check, ANSI querying is allowed, if not prohibited by the TerminalCheckerInput properties. Alternatively a wm.Window can be compared against with CheckWindow.
- CheckExclude(TerminalCheckerInput) (mightBe bool, p Proprietor)
- CheckIs(Querier, TTY, TerminalCheckerInput) (is bool, p Proprietor)
- CheckWindow(wm.Window) (is bool, p Proprietor)
A new TermChecker has to embed NewTermCheckerCore(name string) providing the TermChecker type identity and the Name() method.
RegisterTermChecker(TermChecker) is used for the registration of the new TermChecker.
Optional methods for setting specific implementations:
- TTY(pytName string, ci environ.Proprietor) (TTY, error)
- Querier(environ.Proprietor) Querier
- Surveyor(environ.Proprietor) PartialSurveyor
- Window(environ.Proprietor) (wm.Window, error)
- Args(environ.Proprietor) []string
- Exe(environ.Proprietor) string
func AllTerminalCheckers ¶
func AllTerminalCheckers() []TermChecker
AllTerminals returns all enabled registered dummy terminals
func GetAllRegTermCheckers ¶
func GetAllRegTermCheckers() []TermChecker
func GetRegTermChecker ¶
func GetRegTermChecker(name string) TermChecker
GetRegTermChecker returns registered terminal checker
func NewTermCheckerCore ¶
func NewTermCheckerCore(name string) TermChecker
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
func ComposeTerminal ¶
ComposeTerminal manually composes a Terminal ignoring any incongruities.
func NewTerminal ¶
NewTerminal tries to recognize the terminal that manages the device ptyName and matches w. It will use non-zero implementations provided by the optional TerminalChecker methods:
- TTY(ptyName string, ci environ.Proprietor) (TTY, error)
- Querier(environ.Proprietor) Querier
- Surveyor(environ.Proprietor) PartialSurveyor
- Window(environ.Proprietor) (wm.Window, error)
- Args(environ.Proprietor) []string
- Exe(environ.Proprietor) string // alternative executable name if it differs from Name()
The optional Options.…Fallback fields are applied in case the enforced Creator fields are nil and the TermChecker also doesn't return a suggestion.
func (*Terminal) CreateTemp ¶
CreateTemp ...