simpleansi

package module
v0.0.0-...-8cd0472 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: MIT Imports: 1 Imported by: 42

README

simpleansi

Simple ANSI is a package that contains simple ANSI operations using escape sequences. It was developed to be used in the Pac Go project, but feel free to use it anywhere you would like :)

Introduction

This package contain helper functions for some common terminal operations. One important difference in regards to the ANSI standard is that we consider the top left corner to be zero-based (0,0) instead of 1-based (1,1). The only reason for that is that it simplifies the code for drawing when you are iterating over an array of slices, as it is used in Pac Go.

Contributing

This project is open source under the MIT license, which means you are basically free to do whatever you want with it, just give me the proper credits. :)

If you want to contribute just raise an issue and/or submit a pull request.

If you are looking for inspiration you may browse the open issues or have a look at the TODO list.

Everything on the TODO list should be planned as a new step on the tutorial unless otherwise noted.

License

See LICENSE.

Contacting the Author

If you have any questions, please reach out to me at daniela.petruzalek@gmail.com. I'm also on Twitter as @danicat83.

Finally, you can support me on Ko-Fi if you like my work and want me to continue doing crazy stuff like this project:

ko-fi

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearScreen

func ClearScreen()

ClearScreen cleans the terminal and set cursor position to the top left corner.

func MoveCursor

func MoveCursor(row, col int)

MoveCursor sets the cursor position to given row and col.

Please note that ANSI is 1-based and the top left corner is (1,1), but here we are assuming the user is using a zero based coordinate system where the top left corner is (0, 0)

func WithBackground

func WithBackground(text string, colour Colour) string

WithBackground wraps the given 'text' with 'colour' background and reset escape sequences.

func WithBlueBackground

func WithBlueBackground(text string) string

WithBlueBackground wraps the given text with blue background and reset escape sequences.

Types

type Colour

type Colour int
const (
	BLACK Colour = iota
	RED
	GREEN
	BROWN
	BLUE
	MAGENTA
	CYAN
	GREY
)

Jump to

Keyboard shortcuts

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