ansigo

package module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2021 License: MIT Imports: 4 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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:

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

Documentation

Index

Constants

View Source
const (
	SCREEN_ESC = "\x1B[%vJ"
	LINE_ESC   = "\x1B[%vK"
)
View Source
const DISPLAY_ATTR = "\x1B[%vm%v\x1B[0m"

Variables

This section is empty.

Functions

func Backspace

func Backspace()

func BgBlack

func BgBlack(txt string) string

func BgBlue

func BgBlue(txt string) string

func BgCyan

func BgCyan(txt string) string

func BgGreen

func BgGreen(txt string) string

func BgMagenta

func BgMagenta(txt string) string

func BgRed

func BgRed(txt string) string

func BgWhite

func BgWhite(txt string) string

func BgYellow

func BgYellow(txt string) string

func Bright

func Bright(txt string) string

func CursorBackward

func CursorBackward(n int)

func CursorDown

func CursorDown(n int)

func CursorDownStartLn added in v0.1.5

func CursorDownStartLn(n int)

func CursorForward

func CursorForward(n int)

func CursorHide

func CursorHide()

func CursorHome

func CursorHome()

func CursorRestorePos

func CursorRestorePos()

func CursorSavePos

func CursorSavePos()

func CursorSetPos

func CursorSetPos(row, col int)

func CursorShow

func CursorShow()

func CursorUp

func CursorUp(n int)

func CursorUpStartLn added in v0.1.5

func CursorUpStartLn(n int)

func Dim added in v0.1.4

func Dim(txt string) string

func EchoStdin

func EchoStdin()

EchoStdin prints user input.

func EraseDown

func EraseDown()

func EraseLine

func EraseLine()

func EraseLineSection added in v0.1.3

func EraseLineSection(row, col1, col2 int)

func EraseScreen

func EraseScreen()

func EraseToEndln

func EraseToEndln()

func EraseToStartln

func EraseToStartln()

func EraseUp

func EraseUp()

func FgBlack

func FgBlack(txt string) string

func FgBlue

func FgBlue(txt string) string

func FgCyan

func FgCyan(txt string) string

func FgGreen

func FgGreen(txt string) string

func FgMagenta

func FgMagenta(txt string) string

func FgRed

func FgRed(txt string) string

func FgWhite

func FgWhite(txt string) string

func FgYellow

func FgYellow(txt string) string

func GetChar

func GetChar(stdin chan string)

GetChar unbuffers stdin and stops the printing of user stdin input.

func Hidden

func Hidden(txt string) string

func Italic added in v0.1.4

func Italic(txt string) string

func RestoreTerminalSettings

func RestoreTerminalSettings()

RestoreTerminalSettings undos the effects of GetChar as well as other window modifications caused by various functions throughout this library such as CursorHide

func StrikeThrough added in v0.1.4

func StrikeThrough(txt string) string

func TerminalDimensions

func TerminalDimensions() (int, int, error)

TerminalDimensions returns the the columns and rows of the current active window.

func UnbufferStdin added in v0.1.3

func UnbufferStdin()

Unbuffers stdin of current terminal and specifies complete input length as 1.

func Underline added in v0.1.4

func Underline(txt string) string

func UnechoStdin added in v0.1.3

func UnechoStdin()

Turns off user input echo.

Types

This section is empty.

Directories

Path Synopsis
example
erase command
keylog command
navigate command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址