Documentation ¶
Index ¶
- Constants
- Variables
- func FixedToImagePoint(fp fixed.Point26_6) image.Point
- func FixedToImageRect(fr fixed.Rectangle26_6) image.Rectangle
- func NewImageTranslate(offset image.Point, img draw.Image) *imageTranslate
- type Attr
- type Color
- type Colorizer
- type Config
- type Cursor
- type Device
- func (d *Device) Clear(x1, y1, x2, y2 int)
- func (d *Device) ColsRemaining() int
- func (d *Device) HandleCSISequence(seq []rune)
- func (d *Device) HandleEscSequence(seq []rune)
- func (d *Device) HandleOSCSequence(seq []rune)
- func (d *Device) Image() image.Image
- func (d *Device) MoveCursorAbs(x, y int)
- func (d *Device) MoveCursorRel(x, y int)
- func (d *Device) RenderRunes(sym []rune)
- func (d *Device) Scroll(amount int)
- func (d *Device) ScrollToCursor()
- func (d *Device) VisualBell()
- func (d *Device) Write(data []byte) (n int, err error)
- func (d *Device) WriteAt(p []byte, off int64) (n int, err error)
- type Property
- type Render
- type TileSet
- func (ts TileSet) Close() error
- func (ts TileSet) Glyph(dot fixed.Point26_6, r rune) (dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ...)
- func (ts TileSet) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool)
- func (ts TileSet) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool)
- func (ts TileSet) Kern(r0, r1 rune) fixed.Int26_6
- func (ts TileSet) LoadTileFromFile(r rune, file string)
- func (ts TileSet) LoadTileFromReader(r rune, rd io.Reader)
- func (ts TileSet) Metrics() font.Metrics
Constants ¶
const ( CursorBlock = iota CursorBeam CursorUnderscore )
Variables ¶
var ( ColorBlack = NewOpaqueColor(0, 0, 0) ColorBrightBlack = NewOpaqueColor(85, 85, 85) ColorRed = NewOpaqueColor(127, 0, 0) ColorBrightRed = NewOpaqueColor(255, 0, 0) ColorGreen = NewOpaqueColor(0, 170, 0) ColorBrightGreen = NewOpaqueColor(85, 255, 85) ColorYellow = NewOpaqueColor(170, 85, 0) ColorBrightYellow = NewOpaqueColor(255, 255, 85) ColorBlue = NewOpaqueColor(0, 0, 170) ColorBrightBlue = NewOpaqueColor(85, 85, 255) ColorMagenta = NewOpaqueColor(170, 0, 170) ColorBrightMagenta = NewOpaqueColor(255, 85, 255) ColorCyan = NewOpaqueColor(0, 170, 170) ColorBrightCyan = NewOpaqueColor(85, 255, 255) // Okay, I deviated from VGA colors here. VGA "white" is way too gray. ColorWhite = NewOpaqueColor(240, 240, 240) // ColorWhite = NewOpaqueColor(170, 170, 170) ColorBrightWhite = NewOpaqueColor(255, 255, 255) )
var AttrDefault = Attr{ Fg: ColorWhite, Bg: ColorBlack, }
var Colors256 = [256]Color{}/* 256 elements not displayed */
Colors256 defines the default set of 256 Colors
var ConfigDefault = Config{
TabSize: 8,
}
var EmptyTile = image.NewAlpha(image.Rect(0, 0, 8, 16))
var ErrEscapeSequenceIncomplete = errors.New("escape sequence incomplete")
Functions ¶
func FixedToImageRect ¶
func FixedToImageRect(fr fixed.Rectangle26_6) image.Rectangle
fixed.Rectangle26_6 to image.Image rectangle
Types ¶
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color both implements color.Color and image.Image. image.Image needs a color.Model, so for convenience's sake, Color also implements color.Model so it can simply have ColorModel() return itself. The main purpose of Color is so there is no need to instantiate an image.Unform everytime we need to draw something in a particular color.
func NewOpaqueColor ¶
func (Color) ColorModel ¶
type Colorizer ¶
the tinygo.org/x/drivers/pixel package has a somewhat incompatible color interface with the color.Color interface. This type definition and it's associated function allows a pixel.Color's RGBA method to be cast so that it implements the color.Color interface. Example: pixelColor := pixel.NewColor[pixel.RGB888](127,127,127) drawImage.Set(xPos,yPos, Colorizer(pixelColor.RGBA))
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor is used to track the cursor.
type Device ¶
type Device struct { // BellFunc is called if it is non-null and the terminal would // display a bell character // TODO: Implement affirmative beep (default) and negative acknowledge beep // Negative acknowledge is produced when \a is sent while in SHIFT-OUT mode. // Affirmative: C-G (quarter notes?) // NAK: C♭ (whole note?) BellFunc func() // Config species the runtime configurable features of fansiterm. Config Config // Render collects together all the graphical rendering fields. Render Render // Miscellaneous properties, like "Window Title" Properties map[Property]string // Output specifies the program attached to the terminal. This should be the // same interface that the input mechanism (whatever that may be) uses to write // to the program. On POSIX systems, this would be equivalent to Stdin. // Default is io.Discard. Setting to nil will cause Escape Sequences that // write a response to panic. Output io.Writer // contains filtered or unexported fields }
func New ¶
New returns an initialized *Device. If buf is nil, an internal buffer is used. Otherwise if you specify a hardware backed draw.Image, writes to Device will immediately be written to the backing hardware--whether this is instaneous or buffered is up to the device and the device driver.
func NewAtResolution ¶
NewAtResolution is like New, but rather than specifying the columns and rows, you specify the desired resolution. The maximum rows and cols will be determined automatically and the terminal rendered in the center. TODO: allow offset to be manually specified
func (*Device) Clear ¶
Clear writes a block of current background color in a rectangular shape, specified in units of cells (rows and columns). So (*Device).Clear(0,0, (*Device).cols, (*Device).rows) would clear the whole screen.
func (*Device) ColsRemaining ¶
ColsRemaining returns how many columns are remaining until EOL
func (*Device) HandleCSISequence ¶
func (*Device) HandleEscSequence ¶
HandleEscSequence handles escape sequences. This should be the whole complete sequence. Bounds are not checked so an incomplete sequence will cause a panic.
func (*Device) HandleOSCSequence ¶
func (*Device) MoveCursorAbs ¶
func (*Device) MoveCursorRel ¶
func (*Device) RenderRunes ¶
RenderRunes does not do *any* interpretation of escape codes or control characters like \r or \n. It simply renders a slice of runes (as a string) at the cursor position. It is up to the caller of RenderRunes to ensure there's enough space for the runes on the buffer and to process any control sequences.
func (*Device) ScrollToCursor ¶
func (d *Device) ScrollToCursor()
func (*Device) VisualBell ¶
func (d *Device) VisualBell()
VisualBell inverts the screen for a quarter second.
func (*Device) Write ¶
Write implements io.Write and is the main way to interract with with (*fansiterm).Device. This is essentially writing to the "terminal." Writes are more or less unbuffered with the exception of escape sequences. If a partial escape sequence is written to Device, the beginning will be bufferred and prepended to the next write.
func (*Device) WriteAt ¶
WriteAt works like calling the save cursor position escape sequence, then the absolute set cursor position escape sequence, writing to the terminal, and then finally restoring cursor position. The offset is just the i'th character on screen. Negative offset values are set to 0, values larger than d.rows * d.cols are set to d.rows*d.cols.
type TileSet ¶
TileSet implements the golang.org/x/image/font.Face interface. It is a simple map of rune to image.Image. The images work best as an image.Alpha, that is, image data consisting solely of alpha channel. TODO: implement variable sized tiles, currently only 8x16 is supported
func NewTileSet ¶
func NewTileSet() TileSet