Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snugfox/ansi-escapes
Collection of ANSI escapes for Go
https://github.com/snugfox/ansi-escapes
ansi-escape-sequences apple-terminal go golang vt100 windows-10
Last synced: about 1 month ago
JSON representation
Collection of ANSI escapes for Go
- Host: GitHub
- URL: https://github.com/snugfox/ansi-escapes
- Owner: snugfox
- License: mit
- Created: 2018-07-29T19:34:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-14T14:02:53.000Z (over 3 years ago)
- Last Synced: 2024-10-02T04:41:09.154Z (about 2 months ago)
- Topics: ansi-escape-sequences, apple-terminal, go, golang, vt100, windows-10
- Language: Go
- Size: 12.7 KB
- Stars: 12
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ansi-scapes [![GoDoc](https://godoc.org/github.com/snugfox/ansi-escapes?status.svg)](https://godoc.org/github.com/snugfox/ansi-escapes)
ansi-scapes is a minimal Go library for ANSI escape sequences. It handles the
small differences in the Apple's Terminal app, as well as enable and disable
escape sequences on Windows 10 v1511 and later.🚧 ansi-escapes is still under development, and is subject to change 🚧
## Features
- Constants for simple escape sequences
- Functions for sequences with parameters
- Correct functionality across terminal emulators
- Ability to enable/disable escape sequence processing on Windows v1511 and
later## Installation
With the [Go Programming Language](https://golang.org/),
```console
$ go get -u github.com/snugfox/ansi-escapes
```## Usage
Go's import mechanism does not allow package names to contain hyphens, so import
the package as `escapes`.
```go
import escapes "github.com/snugfox/ansi-escapes"
```## Example
```go
package mainimport (
"bytes"
"fmt"
"os"escapes "github.com/snugfox/ansi-escapes"
)func main() {
// Enable support on Windows for this application. It is safe to include on
// OSes other than Windows, as the functions will only return nil; thus
// compiled out.
escapes.EnableVirtualTerminal(escapes.Stdout)
defer escapes.DisableVirtualTerminal(escapes.Stdout)// Erase the screen. Remember that fmt.Println would print the newline *after*
// the escape sequence.
fmt.Print(escapes.EraseScreen)// Move the cursor one column to the right
fmt.Print(escapes.CursorForward)// Move the cursor to (1, 1)
fmt.Print(escapes.CursorPos(1, 1))// Display a super secret image
var buf bytes.Buffer
file, _ := os.Open("meow.jpg")
buf.ReadFrom(file)
fmt.Print(escapes.Image(buf.Bytes()))
}
```## License
MIT (c) Snug_Fox