goterm

package module
v0.0.0-...-1449223 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2018 License: MIT Imports: 6 Imported by: 2

README

Package goterm provides a simple terminal emulator.

Build Status Report Status

Copyright 2018- Tatsuhiro Aoshima (hiro4bbh@gmail.com).

Introduction

Package goterm provides a simple terminal emulator. It supports full-width (zenkaku in Japanese) characters (other implementations support them partially or incorrectly).

See goterm's document on GoDoc. You can test the examples:

go run example/main.go

Documentation

Overview

Package goterm provides a simple terminal emulator.

Index

Constants

This section is empty.

Variables

View Source
var RuneTwoWidthTables = []*unicode.RangeTable{
	unicode.Han, unicode.Hangul, unicode.Hiragana, unicode.Katakana,
	{R16: []unicode.Range16{{0x3000, 0x303f, 1}}},
	{R16: []unicode.Range16{{0x30a0, 0x30ff, 1}}},
	{R16: []unicode.Range16{{0xff01, 0xff60, 1}}},
}

RuneTwoWidthTables is the slice of unicode.RangeTable containing the unicode characters whose display width is two. Notice that, hankaku (half-width) katakana (in Japanese) characters are contained in unicode.Katakana, but the display width should be one.

View Source
var RuneZeroWidthTables = []*unicode.RangeTable{
	unicode.Mn, unicode.Me, unicode.Cc, unicode.Cf,
}

RuneZeroWidthTables is the slice of unicode.RangeTable containing the unicode characters whose display width is zero.

Functions

func IsTerminal

func IsTerminal(w io.Writer) bool

IsTerminal returns ture if w writes to a terminal.

func RuneWidth

func RuneWidth(r rune) int

RuneWidth returns the display width of the given rune.

Types

type Config

type Config struct {
	// History indicates whether the input history is enabled.
	History bool
}

Config is configure settings for a Term.

type Term

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

Term is the terminal emulator supporting full-width (zenkaku in Japanese) characters.

func New

func New(f *os.File, prompt string, config *Config) (*Term, error)

New returns a new Term.

func (*Term) ReadLine

func (term *Term) ReadLine() (string, error)

ReadLine returns the read line ending with '\n'. If EOF is hit, the empty string and no error are returned.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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