tinyterm

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: BSD-3-Clause Imports: 7 Imported by: 20

README

tinyterm - TinyGo Terminal Emulator

Build

A minimal terminal for TinyGo devices supporting 256-color ANSI escape codes.

examples/colors/main.go running on PyPortal

How to compile examples

Most of the examples will work with any of the following hardware:

basic

Displays basic text.

tinygo flash -target pyportal ./examples/basic
colors

Displays ANSI colors.

tinygo flash -target pyportal ./examples/colors
httpclient

Connects to an http server and displays the results. Runs on PyPortal and WioTerminal only, since it requires a connected WiFi coprocessor.

tinygo flash -target pyportal -ldflags="-X main.ssid=MYSSID -X main.pass=MYPASS" ./examples/httpclient

Documentation

Overview

package tinyterm is for TinyGo developers who want to use a terminal style user interface for any display that supports the Displayer interface. This includes several different displays in the TinyGo Drivers repo.

Index

Constants

View Source
const (
	SGRReset = iota
	SGRBold
	SGRFaint
	SGRItalic
	SGRUnderline
	SGRSlowBlink
	SGRRapidBlink
	SGRReverseVideo
	SGRConceal
	SGRCrossedOut
	SGRPrimaryFont
	SGRAltFont1
	SGRAltFont2
	SGRAltFont3
	SGRAltFont4
	SGRAltFont5
	SGRAltFont6
	SGRAltFont7
	SGRAltFont8
	SGRAltFont9
	SGRFraktur
	SGRDoubleUnderline
	SGRNormal
	SGRNotItalicNotFraktur
	SGRUnderlineOff
	SGRBlinkOff
	SGRInverseOff
	SGRReveal
	SGRNotCrossedOut

	SGRFgBlack
	SGRFgRed
	SGRFgGreen
	SGRFgYellow
	SGRFgBlue
	SGRFgMagenta
	SGRFgCyan
	SGRFgWhite
	SGRSetFgColor
	SGRDefaultFgColor
	SGRBgBlack
	SGRBgRed
	SGRBgGreen
	SGRBgYellow
	SGRBgBlue
	SGRBgMagenta
	SGRBgCyan
	SGRBgWhite
	SGRSetBgColor
	SGRDefaultBgColor
	SGRFramed
	SGREncircled
	SGROverlined
	SGRIdeogramUnderline
	SGRIdeogramDblUnderline
	SGRIdeogramOverline
	SGRIdeogramStress
	SGRIdeogramAttrOff
)
View Source
const Version = "0.3.0"

Version returns a user-readable string showing the version of the TinyTerm package for support purposes.

Update this value before release of new version of software.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color uint8
const (
	ColorBlack Color = iota
	ColorRed
	ColorGreen
	ColorYellow
	ColorBlue
	ColorMagenta
	ColorCyan
	ColorWhite
	ColorBrBlack
	ColorBrRed
	ColorBrGreen
	ColorBrYellow
	ColorBrBlue
	ColorBrMagenta
	ColorBrCyan
	ColorBrWhite
)

type Config

type Config struct {
	// the font to be used for the terminal
	Font *tinyfont.Font

	// font height for the terminal
	FontHeight int16

	// font offset for the terminal
	FontOffset int16

	// UseSoftwareScroll when true will blank the display an start again at
	// the top when running out of space, instead of using whatever hardware
	// scrolling is available on the display.
	UseSoftwareScroll bool
}

Config contains the configuration for a Terminal.

type Displayer

type Displayer interface {
	drivers.Displayer
	FillRectangle(x, y, width, height int16, c color.RGBA) error
	SetScroll(line int16)
}

Displayer is a wrapper around the TinyGo drivers repo's Displayer interface.

type Terminal

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

Terminal is a terminal interface that can be used on any display that supports the Displayer interface.

func NewTerminal

func NewTerminal(display Displayer) *Terminal

NewTerminal returns a new Terminal. The Terminal will need to have Configure called on it to be used.

func (*Terminal) Configure

func (t *Terminal) Configure(config *Config)

Configure needs to be called for a new Terminal before it can be used.

func (*Terminal) Printf

func (t *Terminal) Printf(format string, args ...interface{}) (n int, err error)

Printf wraps the fmt package function of the same name, and outputs the result to the terminal.

func (*Terminal) Println

func (t *Terminal) Println(args ...interface{}) (n int, err error)

Println wraps the fmt package function of the same name, and outputs the result to the terminal.

func (*Terminal) Write

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

Write some data to the terminal.

func (*Terminal) WriteByte

func (t *Terminal) WriteByte(b byte) error

Write a single byte to the terminal.

Directories

Path Synopsis
examples
httpclient
This example opens a TCP connection using a device with WiFiNINA firmware and sends a HTTP request to retrieve a webpage, based on the following Arduino example:
This example opens a TCP connection using a device with WiFiNINA firmware and sends a HTTP request to retrieve a webpage, based on the following Arduino example:
fonts
vga

Jump to

Keyboard shortcuts

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