Documentation
¶
Overview ¶
Package buffer 提供终端输出缓冲区与解析功能
包含 ANSI 转义序列解析、颜色处理与缓冲区管理
Index ¶
- func FormatSGR(params ...int) string
- func ParseANSI(s string) string
- type Attributes
- type Buffer
- func (b *Buffer) Clear()
- func (b *Buffer) GetCell(row, col int) (Cell, error)
- func (b *Buffer) GetContent() string
- func (b *Buffer) GetCursor() (x, y int)
- func (b *Buffer) GetLine(row int) (string, error)
- func (b *Buffer) GetSize() (rows, cols int)
- func (b *Buffer) Reader() io.Reader
- func (b *Buffer) Resize(rows, cols int)
- func (b *Buffer) RestoreCursor()
- func (b *Buffer) SaveCursor()
- func (b *Buffer) SetCursor(x, y int)
- func (b *Buffer) SetScrollRegion(top, bottom int)
- func (b *Buffer) Write(p []byte) (n int, err error)
- func (b *Buffer) WriteRune(r rune)
- type Cell
- type Color
- type Parser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attributes ¶
type Attributes uint16
Attributes 表示字符属性
const ( AttrBold Attributes = 1 << iota AttrDim AttrItalic AttrUnderline AttrBlink AttrReverse AttrHidden AttrStrikethrough )
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer 表示终端缓冲区
func (*Buffer) SetScrollRegion ¶
SetScrollRegion 设置滚动区域
type Cell ¶
type Cell struct {
Char rune
FG Color // 前景色
BG Color // 背景色
Attrs Attributes
}
Cell 表示终端中的一个字符单元
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser VT/XTerm 转义序列解析器,将终端输出字节流转换为 Buffer 操作。 状态机使用 4 个状态处理不同种类的转义序列:
stateNormal - 普通文本内容,直接写入 Buffer stateEscape - 收到 ESC (0x1B),等待后续命令字节 stateCSI - CSI 序列 (ESC [ params... command),最常用的控制序列 stateOSC - OSC 序列 (ESC ] ... ST/BEL),操作系统命令,暂时忽略
CSI 命令包括光标移动 (A/B/C/D/H/f)、清屏 (J)、清行 (K)、 颜色属性 (m) 以及滚动区域设置 (r) 等终端常用控制指令
Click to show internal directories.
Click to hide internal directories.