Documentation
¶
Overview ¶
Package ansi 输出 ansi 控制码
// 包装一个 stderr。 w := ansi.NewWriter(os.Stderr) w.Left(5) w.Printf("%s", "string") w.Move(1,1)
Index ¶
- Constants
- type ESC
- func B256Color(color uint8) ESC
- func BTrueColor(r, g, b uint8) ESC
- func CHA(n int) ESC
- func CNL(n int) ESC
- func CPL(n int) ESC
- func CSI(end byte, v ...int) ESC
- func CUB(n int) ESC
- func CUD(n int) ESC
- func CUF(n int) ESC
- func CUP(x, y int) ESC
- func CUU(n int) ESC
- func DSR() ESC
- func ED(n int) ESC
- func EL(n int) ESC
- func F256Color(color uint8) ESC
- func FTrueColor(r, g, b uint8) ESC
- func RCP() ESC
- func SCP() ESC
- func SD(n int) ESC
- func SGR(args ...int) ESC
- func SU(n int) ESC
- type Writer
- func (w *Writer) B256Color(color uint8) *Writer
- func (w *Writer) BTrueColor(r, g, b uint8) *Writer
- func (w *Writer) Color256(f, b uint8) *Writer
- func (w *Writer) Down(n int) *Writer
- func (w *Writer) Erase(n int) *Writer
- func (w *Writer) EraseLine(n int) *Writer
- func (w *Writer) Err() error
- func (w *Writer) F256Color(color uint8) *Writer
- func (w *Writer) FTrueColor(r, g, b uint8) *Writer
- func (w *Writer) Left(n int) *Writer
- func (w *Writer) Move(x, y int) *Writer
- func (w *Writer) Print(args ...any) *Writer
- func (w *Writer) Printf(format string, args ...any) *Writer
- func (w *Writer) Println(args ...any) *Writer
- func (w *Writer) RestoreCursor() *Writer
- func (w *Writer) Right(n int) *Writer
- func (w *Writer) SGR(sgr ...int) *Writer
- func (w *Writer) SaveCursor() *Writer
- func (w *Writer) TrueColor(fr, fg, fb, br, bg, bb uint8) *Writer
- func (w *Writer) Up(n int) *Writer
- func (w *Writer) WByte(b byte) *Writer
- func (w *Writer) WBytes(data []byte) *Writer
- func (w *Writer) WString(str string) *Writer
- func (w *Writer) Write(bs []byte) (int, error)
- func (w *Writer) WriteESC(esc ESC) *Writer
Constants ¶
View Source
const ResetCode = 0
ResetCode 重置所有状态的 ESC 状态码
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ESC ¶
type ESC string
ESC 表示 ANSI 转码序列
func ED ¶
ED 返回清除屏幕的控制符
- n == 0 时,清除从当前光标到屏幕尾的所有字符;
- n == 1 时,清除从当前光标到屏幕头的所有字符;
- n == 2 时,清除当前屏幕的所有字符;
- 当 n 为其它值时,将触发 panic
func EL ¶
EL 获取清除行的控制符
- n == 0 时,清除从当前光标到行尾的所有字符;
- n == 1 时,清除从当前光标到行头的所有字符;
- n == 2 时,清除当前行的所有字符。
- 当 n 为其它值时,将触发 panic
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer ansi 控制码的 io.Writer 实现
a := NewWriter(os.Stdout) a.Left(5). ClearLine(2). SGR(32, 33). Print("abc") fmt.Fprintf(a, "%v", SGRFBBlue)
func (*Writer) BTrueColor ¶
BTrueColor 输出 24 色彩背景色
func (*Writer) Erase ¶
Erase 清除屏幕
- n==0 时,清除从当前光标到屏幕尾的所有字符;
- n==1 时,清除从当前光标到屏幕头的所有字符;
- n==2 时,清除当前屏幕的所有字符;
- 当 n 为其它值时,将触发 panic
func (*Writer) EraseLine ¶
EraseLine 清除行
- n==0 时,清除从当前光标到行尾的所有字符;
- n==1 时,清除从当前光标到行头的所有字符;
- n==2 时,清除当前行的所有字符;
- 当 n 为其它值时,将触发 panic
func (*Writer) FTrueColor ¶
FTrueColor 输出 24 色彩前景色
func (*Writer) Printf ¶
Printf 相当于 fmt.Printf
func (*Writer) TrueColor ¶
TrueColor 输出 24 位色彩的颜色信息
fr、fb 和 fb 表示前景色的 RGB 颜色值; br、bb 和 bb 表示背景色的 RGB 颜色值;
Click to show internal directories.
Click to hide internal directories.