Documentation ¶
Overview ¶
输出ansi控制码,不支持windows系统
fmt.Printf("%v这是红色的字", term.FRed) fmt.Printf("%v这是红色字,绿色背景", term.SGR(term.SGRFRed,term.SGRBGreen)) fmt.Printf("%v%v这是红色字,绿色背景", term.FRed,term.BGreen) // 包装一个stderr。 w := term.NewWriter(os.Stderr) w.Left(5) w.SGR(term.SGRFRed) w.Printf("%s", "string") w.Move(1,1)
ansi的相关文档,可参考以下内容:
http://en.wikipedia.org/wiki/ANSI_escape_code http://www.mudpedia.org/mediawiki/index.php/ANSI_colors
Index ¶
- Constants
- func BColor256(color int) string
- func Down(n int) string
- func Erase(n int) string
- func EraseLine(n int) string
- func FColor256(color int) string
- func Left(n int) string
- func Move(x, y int) string
- func Right(n int) string
- func SGR(args ...string) string
- func Up(n int) string
- type AnsiWriter
- func (a *AnsiWriter) BColor256(color int) (int, error)
- func (a *AnsiWriter) Color256(f, b int) (int, error)
- func (a *AnsiWriter) Down(n int) (int, error)
- func (a *AnsiWriter) Erase(n int) (int, error)
- func (a *AnsiWriter) EraseLine(n int) (int, error)
- func (a *AnsiWriter) FColor256(color int) (int, error)
- func (a *AnsiWriter) HideCursor() (int, error)
- func (a *AnsiWriter) Left(n int) (int, error)
- func (a *AnsiWriter) Move(x, y int) (int, error)
- func (a *AnsiWriter) Print(args ...interface{}) (int, error)
- func (a *AnsiWriter) Printf(format string, args ...interface{}) (int, error)
- func (a *AnsiWriter) Println(args ...interface{}) (int, error)
- func (a *AnsiWriter) RestoreCursor() (int, error)
- func (a *AnsiWriter) Right(n int) (int, error)
- func (a *AnsiWriter) SGR(sgr ...string) (int, error)
- func (a *AnsiWriter) SaveCursor() (int, error)
- func (a *AnsiWriter) ShowCursor() (int, error)
- func (a *AnsiWriter) Up(n int) (int, error)
- func (a *AnsiWriter) Write(b []byte) (int, error)
- func (a *AnsiWriter) WriteString(str string) (int, error)
Constants ¶
View Source
const ( Reset = "\033[0m" Bold = "\033[1m" Underline = "\033[4m" Blink = "\033[5m" // 闪烁 ReverseVideo = "\033[7m" // 反显 Conceal = "\033[8m" BoldOff = "\033[22m" UnderlineOff = "\033[24m" BlinkOff = "\033[25m" ReverseVideoOff = "\033[27m" ConcealOff = "\033[28m" FBlack = "\033[30m" FRed = "\033[31m" FGreen = "\033[32m" FYellow = "\033[33m" FBlue = "\033[34m" FMagenta = "\033[35m" FCyan = "\033[36m" FWhite = "\033[37m" FDefault = "\033[39m" // 默认前景色 BBlack = "\033[40m" BRed = "\033[41m" BGreen = "\033[42m" BYellow = "\033[43m" BBlue = "\033[44m" BMagenta = "\033[45m" BCyan = "\033[46m" BWhite = "\033[47m" BDefault = "\033[49m" // 默认背景色 SaveCursor = "\033[s" // 保存光标位置 RestoreCursor = "\033[u" // 恢复光标位置 HideCursor = "\033[?25l" // 隐藏光标 ShowCursor = "\033[?25h" // 显示光标 )
View Source
const ( SGRReset = "0" SGRBold = "1" SGRUnderline = "4" SGRBlink = "5" // 闪烁 SGRReverseVideo = "7" // 反显 SGRConceal = "8" SGRBoldOff = "22" SGRUnderlineOff = "24" SGRBlinkOff = "25" SGRReverseVideoOff = "27" SGRConcealOff = "28" SGRFBlack = "30" SGRFRed = "31" SGRFGreen = "32" SGRFYellow = "33" SGRFBlue = "34" SGRFMagenta = "35" SGRFCyan = "36" SGRFWhite = "37" SGRFDefault = "39" // 默认前景色 SGRBBlack = "40" SGRBRed = "41" SGRBGreen = "42" SGRBYellow = "43" SGRBBlue = "44" SGRBMagenta = "45" SGRBCyan = "46" SGRBWhite = "47" SGRBDefault = "49" // 默认背景色 )
View Source
const Version = "1.1.4.141013"
当前库的版本
Variables ¶
This section is empty.
Functions ¶
func Erase ¶
返回清除屏幕的控制符。 n为0时,清除从当前光标到屏幕尾的所有字符; n为1时,清除从当前光标到屏幕头的所有字符; n为2时,清除当前屏幕的所有字符。 当n为其它值时,将触发panic
func EraseLine ¶
返回清除行的控制符。 n为0时,清除从当前光标到行尾的所有字符; n为1时,清除从当前光标到行头的所有字符; n为2时,清除当前行的所有字符。 当n为其它值时,将触发panic
Types ¶
type AnsiWriter ¶
type AnsiWriter struct {
// contains filtered or unexported fields
}
ansi控制器的io.Writer接口.
a := NewWriter(os.Stdout) a.Left(5) a.ClearLine(2) a.SGR(term.SGRFRed,term.SGRBGreen) a.Print("abc") fmt.Fprintf(a, "%v", term.SGRFBBlue)
func NewWriter ¶
func NewWriter(w io.Writer) *AnsiWriter
func (*AnsiWriter) Erase ¶
func (a *AnsiWriter) Erase(n int) (int, error)
清除屏幕。 n为0时,清除从当前光标到屏幕尾的所有字符; n为1时,清除从当前光标到屏幕头的所有字符; n为2时,清除当前屏幕的所有字符。 当n为其它值时,将触发panic
func (*AnsiWriter) EraseLine ¶
func (a *AnsiWriter) EraseLine(n int) (int, error)
清除行。 n为0时,清除从当前光标到行尾的所有字符; n为1时,清除从当前光标到行头的所有字符; n为2时,清除当前行的所有字符。 当n为其它值时,将触发panic
func (*AnsiWriter) HideCursor ¶
func (a *AnsiWriter) HideCursor() (int, error)
func (*AnsiWriter) Print ¶
func (a *AnsiWriter) Print(args ...interface{}) (int, error)
func (*AnsiWriter) Printf ¶
func (a *AnsiWriter) Printf(format string, args ...interface{}) (int, error)
func (*AnsiWriter) Println ¶
func (a *AnsiWriter) Println(args ...interface{}) (int, error)
func (*AnsiWriter) RestoreCursor ¶
func (a *AnsiWriter) RestoreCursor() (int, error)
func (*AnsiWriter) SaveCursor ¶
func (a *AnsiWriter) SaveCursor() (int, error)
func (*AnsiWriter) ShowCursor ¶
func (a *AnsiWriter) ShowCursor() (int, error)
func (*AnsiWriter) WriteString ¶
func (a *AnsiWriter) WriteString(str string) (int, error)
Click to show internal directories.
Click to hide internal directories.