terminal

package module
v0.0.0-...-83b67b5 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 5 Imported by: 0

README

goterminal

Documentation

Index

Constants

View Source
const (
	DefaultCursorX int = 0
	DefaultCursorY
	DefaultXBegin
	DefaultXEnd

	ColorDefault termbox.Attribute = termbox.ColorDefault
	ColorBlack   termbox.Attribute = termbox.ColorBlack
	ColorRed     termbox.Attribute = termbox.ColorRed
	ColorGreen   termbox.Attribute = termbox.ColorGreen
	ColorYellow  termbox.Attribute = termbox.ColorYellow
	ColorBlue    termbox.Attribute = termbox.ColorBlue
	ColorMagenta termbox.Attribute = termbox.ColorMagenta
	ColorCyan    termbox.Attribute = termbox.ColorCyan
	ColorWhite   termbox.Attribute = termbox.ColorWhite
)

Variables

This section is empty.

Functions

func LogFile

func LogFile(str ...string)

func StringToCells

func StringToCells(s string) [][]Cell

func StringToCellsWithColor

func StringToCellsWithColor(s string, fg, bg termbox.Attribute) [][]Cell

Types

type Cell

type Cell struct {
	Ch rune
	Fg termbox.Attribute // 文字颜色
	Bg termbox.Attribute // 背景颜色
	// contains filtered or unexported fields
}

func (*Cell) IsEmpty

func (c *Cell) IsEmpty() bool

func (*Cell) Position

func (c *Cell) Position() (int, int)

func (*Cell) Width

func (c *Cell) Width() int

type Cursor

type Cursor struct {
	X, Y          int
	Width, Height int
	// contains filtered or unexported fields
}

type Event

type Event struct {
	PreCh rune
	Ch    rune
}

type Mode

type Mode uint8
const (
	ModeNormal Mode = iota
	ModeInsert
)

type Pane

type Pane struct {
	Width, Height int // 窗口的宽高

	CursorX, CursorY int // 光标坐标

	PageWidth, PageHeight    int // 内容的宽高
	PageOffsetX, PageOffsetY int // 内容和窗口的偏移坐标
	E                        *Event
	Mode                     Mode
	// contains filtered or unexported fields
}

func (*Pane) AppendCellFromString

func (p *Pane) AppendCellFromString(s string)

func (*Pane) AppendCellFromStringWithColor

func (p *Pane) AppendCellFromStringWithColor(s string, fg, bg termbox.Attribute)

func (*Pane) GetLine

func (p *Pane) GetLine(y int) []Cell

func (*Pane) Line

func (p *Pane) Line() []Cell

func (*Pane) MoveCursor

func (p *Pane) MoveCursor(x, y int)

启动光标

func (*Pane) Rendering

func (p *Pane) Rendering()

渲染

func (*Pane) ResetCellPosition

func (p *Pane) ResetCellPosition()

func (*Pane) ResetPageSize

func (p *Pane) ResetPageSize()

func (*Pane) ResetViewCells

func (p *Pane) ResetViewCells()

重置显示的 cell 集合

func (*Pane) SetCellBeforeCursor

func (p *Pane) SetCellBeforeCursor(ch rune, fg, bg termbox.Attribute)

func (*Pane) SetMode

func (p *Pane) SetMode(m Mode)

func (*Pane) Size

func (p *Pane) Size() (int, int)

type Terminal

type Terminal struct {
	CursorX, CursorY int

	PageWidth, PageHeight    int
	PageOffsetX, PageOffsetY int
	E                        *Event
	Mode                     Mode
	// contains filtered or unexported fields
}

func New

func New(s string) (*Terminal, error)

func (*Terminal) AddPaneLandscape

func (t *Terminal) AddPaneLandscape(s string)

func (*Terminal) AppendCellFromString

func (t *Terminal) AppendCellFromString(str string)

func (*Terminal) AppendCellFromStringWithColor

func (t *Terminal) AppendCellFromStringWithColor(str string, fg, bg termbox.Attribute)

func (*Terminal) Close

func (t *Terminal) Close()

func (*Terminal) Delete

func (t *Terminal) Delete(length int)

func (*Terminal) HasCursorPane

func (t *Terminal) HasCursorPane() *Pane

func (*Terminal) Insert

func (t *Terminal) Insert(ch rune)

func (*Terminal) ListenKeyBoardLikeVim

func (t *Terminal) ListenKeyBoardLikeVim(e termbox.Event)

func (*Terminal) ListenKeyBorad

func (t *Terminal) ListenKeyBorad(e termbox.Event)

func (*Terminal) MoveCursorDown

func (t *Terminal) MoveCursorDown()

func (*Terminal) MoveCursorLeft

func (t *Terminal) MoveCursorLeft()

func (*Terminal) MoveCursorRight

func (t *Terminal) MoveCursorRight()

func (*Terminal) MoveCursorToFirstLine

func (t *Terminal) MoveCursorToFirstLine()

func (*Terminal) MoveCursorToLastCell

func (t *Terminal) MoveCursorToLastCell()

func (*Terminal) MoveCursorToLastLine

func (t *Terminal) MoveCursorToLastLine()

func (*Terminal) MoveCursorToLineBegin

func (t *Terminal) MoveCursorToLineBegin()

func (*Terminal) MoveCursorToLineEnd

func (t *Terminal) MoveCursorToLineEnd()

func (*Terminal) MoveCursorUp

func (t *Terminal) MoveCursorUp()

func (*Terminal) PollEvent

func (t *Terminal) PollEvent() termbox.Event

func (*Terminal) Rendering

func (t *Terminal) Rendering()

渲染

func (*Terminal) Resize

func (t *Terminal) Resize(w, h int)

func (*Terminal) Run

func (t *Terminal) Run(onCh func(ch rune), onKey func(key termbox.Key))

func (*Terminal) SetCursor

func (t *Terminal) SetCursor(x, y int)

func (*Terminal) SetLineRange

func (t *Terminal) SetLineRange(begin, end int)

func (*Terminal) SetMode

func (t *Terminal) SetMode(m Mode)

func (*Terminal) Size

func (t *Terminal) Size() (int, int)

Directories

Path Synopsis
_demo
git
vim

Jump to

Keyboard shortcuts

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