Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpillora/ansi
Easy to use ANSI control codes
https://github.com/jpillora/ansi
Last synced: 2 months ago
JSON representation
Easy to use ANSI control codes
- Host: GitHub
- URL: https://github.com/jpillora/ansi
- Owner: jpillora
- License: mit
- Created: 2014-10-27T00:56:46.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-09-26T15:06:35.000Z (over 1 year ago)
- Last Synced: 2024-10-14T11:41:24.960Z (3 months ago)
- Language: Go
- Homepage: https://pkg.go.dev/github.com/jpillora/ansi?tab=doc
- Size: 8.79 KB
- Stars: 13
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## ansi
---
:warning: Not maintained. Please use https://github.com/muesli/ansi or the excellent https://github.com/muesli/termenv
---
Implements the ANSI VT100 control set.
Please refer to http://www.termsys.demon.co.uk/vtansi.htm[![GoDoc](https://godoc.org/github.com/jpillora/ansi?status.svg)](https://pkg.go.dev/github.com/jpillora/ansi?tab=doc)
### Install
```
go get github.com/jpillora/ansi
```### Usage
Get ANSI control code bytes:
``` go
ansi.Goto(2,4)
ansi.Set(ansi.Green, ansi.BlueBG)
```Wrap an `io.ReadWriteCloser`:
``` go
a := ansi.Wrap(tcpConn)
//Read, Write, Close as normal
a.Read()
a.Write()
a.Close()//Shorthand for a.Write(ansi.Set(..))
a.Set(ansi.Green, ansi.BlueBG)//Send query
a.QueryCursorPosition()
//Await report
report := <- a.Reports
report.Type//=> ansi.Position
report.Pos.Row
report.Pos.Col
```*Wrapped connections will intercept and remove ANSI report codes from `a.Read()`*
### API
https://pkg.go.dev/github.com/jpillora/ansi?tab=doc