Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/solidiquis/ansigo

Ansigo offers a convenient way to detect key-presses and control the terminal's font, color, and cursor with ease 🦄
https://github.com/solidiquis/ansigo

ansi go golang terminal vt100

Last synced: 6 days ago
JSON representation

Ansigo offers a convenient way to detect key-presses and control the terminal's font, color, and cursor with ease 🦄

Awesome Lists containing this project

README

        

# ansigo
A library to make the controlling of ANSI terminal emulators' fonts, colors, and cursors, a little less painful — also can be used to detect key presses in the terminal.

Documentation can be found at https://pkg.go.dev/github.com/solidiquis/ansigo

## Installation
```
$ go get github.com/solidiquis/ansigo
```

## Demo
Moving the cursor around the screen Vim-style:
```go
package main

import (
ansi "github.com/solidiquis/ansigo"
)

func main() {
ansi.EraseScreen()
ansi.CursorSetPos(0, 0)

stdin := make(chan string, 1)
go ansi.GetChar(stdin)

for {
switch <-stdin {
case "h":
ansi.CursorBackward(1)
case "j":
ansi.CursorDown(1)
case "k":
ansi.CursorUp(1)
case "l":
ansi.CursorForward(1)
}
}
}
```