tcell

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2021 License: ISC Imports: 4 Imported by: 7

README

gruid-tcell

pkg.go.dev godocs.io

The gruid-tcell module provides a gruid Driver for building terminal full-window applications.

The provided driver tcell package depends on the tcell terminal library, which uses the permissive enough Apache License v2. The library is pure Go, so no special steps are required to install it, and it allows for easy cross-compilation.

You only need to look into the tcell.Style type documentation to define the styling that has to be used by the Driver.

Note that the terminal grid is not a true grid: some characters are two-cell wide (such as wide east-asian characters). The character width can be computed thanks to the go-runewidth package, so it can be taken into account, but it is a bit cumbersome and ad hoc with respect to the graphical drivers which could handle this problem more easily (the tile width can be adjusted to fit any wanted character). Currently, runes with zero value are ignored by this terminal driver, so they can be placed after a wide character. A portable solution is to always pass wide-characters twice, but with different attributes, and then handle this in each driver, either replacing the second one with a zero rune (for this driver), or a different image (for graphical drivers).

Documentation

Overview

Package tcell provides a gruid Driver for making terminal apps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StyleManager StyleManager // for cell styling (required)
	DisableMouse bool         // disable mouse-related messages
	RuneManager  RuneManager  // optional custom mapping for runes
	Tty          tcell.Tty    // optional Tty (see tcell documentation)
}

Config contains configurations options for the driver.

type Driver

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

Driver implements gruid.Driver using the tcell terminal library.

func NewDriver

func NewDriver(cfg Config) *Driver

NewDriver returns a new driver with given configuration options.

func (*Driver) Close

func (dr *Driver) Close()

Close implements gruid.Driver.Close. It finalizes the screen and releases resources.

func (*Driver) Flush

func (dr *Driver) Flush(frame gruid.Frame)

Flush implements gruid.Driver.Flush.

func (*Driver) Init

func (dr *Driver) Init() error

Init implements gruid.Driver.Init. It initializes a screen using the tcell terminal library.

func (*Driver) PollMsgs

func (dr *Driver) PollMsgs(ctx context.Context, msgs chan<- gruid.Msg) error

PollMsgs implements gruid.Driver.PollMsgs. It does not report KP_5 keypad key when numlock is off.

func (*Driver) PreventQuit

func (dr *Driver) PreventQuit()

PreventQuit will make next call to Close keep the same tcell screen. It can be used to chain two applications with the same screen. It is then your reponsibility to either run another application or call Close manually to properly quit.

type RuneManager

type RuneManager interface {
	GetRune(gruid.Cell) rune
}

RuneManager is optional and allows for custom mapping of runes.

type StyleManager

type StyleManager interface {
	// GetAttributes returns a mask of text attributes for a given cell
	// style.
	GetStyle(gruid.Style) tcell.Style
}

StyleManager allows for retrieving of styling information.

Jump to

Keyboard shortcuts

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