Skip to content

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

License

Notifications You must be signed in to change notification settings

solidiquis/ansigo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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)
		}
	}
}

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages