mterm

package module
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 10 Imported by: 0

README

mterm

WIP: mterm implements a virtual terminal

Usage

package main

import "github.com/stdiopt/mterm"


func main() {
    t := mterm.New(24,80)
    fmt.Fprintf(t, "Hello %s", "World")

    // renders the full 24x80 cells in Ansi
    output := t.GetScreenAsAnsi()

    os.Stdout.Write(output)
}

Documentation

Index

Constants

View Source
const (
	Color16  = 1
	Color256 = 2
	Color16M = 3
)
View Source
const (
	FlagBold uint8 = 1 << iota
	FlagUnderline
	FlagBlink
	FlagInverse
	FlagInvisible
	FlagStrike
	FlagItalic
	FlagUnderlineColor
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

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

Cell is a single cell in the terminal

type Color

type Color [3]byte

type EscapeError

type EscapeError struct {
	Err    error
	Offset int
}

func (EscapeError) Error

func (e EscapeError) Error() string

type Terminal

type Terminal struct {
	CursorLine int
	CursorCol  int

	Title   string
	MaxCols int
	MaxRows int

	TabSize int
	// contains filtered or unexported fields
}

Terminal is an in memory terminal emulator

func New

func New(rows, cols int) *Terminal

New returns a new terminal with the given rows and cols

func (*Terminal) Cells

func (t *Terminal) Cells() []Cell

Cells returns a copy of the underlying screen cells

func (*Terminal) Clear

func (t *Terminal) Clear()

Clear clears the terminal moving cursor to 0,0

func (*Terminal) DBG

func (t *Terminal) DBG() []byte

DBG Similar to GetScreenAsAnsi but with a cursor

func (*Terminal) DBGStateFn

func (t *Terminal) DBGStateFn() string

DBGStateFn returns the state func name

func (*Terminal) GetScreenAsAnsi

func (t *Terminal) GetScreenAsAnsi() []byte

func (*Terminal) Put

func (t *Terminal) Put(r rune) error

Put processes a single rune in the terminal

func (*Terminal) Resize

func (t *Terminal) Resize(rows, cols int)

Reset resizes and resets the terminal to the default state

func (*Terminal) Updates

func (t *Terminal) Updates() int

Updates returns a sequence number that is incremented every time the screen cells are updated

func (*Terminal) Write

func (t *Terminal) Write(p []byte) (int, error)

Write implements io.Writer and writes the given bytes to the terminal

Jump to

Keyboard shortcuts

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