term

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package term provides functions for controlling the terminal using ANSI escape sequences.

The current functionality has been tested with the Linux TELNET client, Windows TELNET client and Putty.

Index

Constants

View Source
const (
	ED  = text.CSI + "2J" // Erase in display (whole screen)
	EL  = text.CSI + "0K" // Erase line (cursor to end)
	DSR = text.CSI + "6n" // Device Status Report

	DECSC = text.ESC + "7" // DEC Save Cursor
	DECRC = text.ESC + "8" // DEC Restore Cursor
)

Variables

View Source
var (
	// Position Cursor (row, column)
	CUP = func(r, c int) string {
		return text.CSI + strconv.Itoa(r) + ";" + strconv.Itoa(c) + "H"
	}

	// DEC Set Scroll Region (top, bottom)
	DECSTBM = func(t, b int) string {
		return text.CSI + strconv.Itoa(t) + ";" + strconv.Itoa(b) + "r"
	}
)

Functions

func GetSize

func GetSize(rw io.ReadWriter) (width, height int)

GetSize attempts to retrieve the current terminal's width and height (columns and lines). If the size cannot be determined a default of 80x25 will be returned.

func Input

func Input(height int) []byte

Input returns a []byte that should prefix any data writen to the input area.

func Output

func Output(height int) []byte

Output returns a []byte that should prefix any data writen to the output area.

func Reset

func Reset(height int) []byte

Reset returns a []byte that resets the scroll area and text colours to try and leave the terminal in a reasonable state when the client quits.

func Setup

func Setup(width, height int) []byte

Setup returns a []byte to display the initial status and input areas.

func Status

func Status(height, width int) []byte

Status returns a []byte that should prefix any data writen to the status area.

Types

This section is empty.

Jump to

Keyboard shortcuts

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