Get The Module | Documentation | Contributing | Code of Conduct
Package cursor contains cross-platform methods to move the terminal cursor in different directions. This package can be used to create interactive CLI tools and games, live charts, algorithm visualizations and other updatable output of any kind.
Special thanks to github.com/k0kubun/go-ansi which this project is based on.
# Execute this command inside your project
go get -u github.com/atomicgo/cursor
// Add this to your imports
import "github.com/atomicgo/cursor"
func Bottom()
Bottom moves the cursor to the bottom of the terminal. This is done by calculating how many lines were moved by Up and Down.
func ClearLine()
ClearLine clears the current line and moves the cursor to it's start position.
func Down(n int)
Down moves the cursor n lines down relative to the current position.
func DownAndClear(n int)
DownAndClear moves the cursor down by n lines, then clears the line.
func Hide()
Hide the cursor. Don't forget to show the cursor at least at the end of your application with Show. Otherwise the user might have a terminal with a permanently hidden cursor, until he reopens the terminal.
func HorizontalAbsolute(n int)
HorizontalAbsolute moves the cursor to n horizontally. The position n is absolute to the start of the line.
func Left(n int)
Left moves the cursor n characters to the left relative to the current position.
func Move(x, y int)
Move moves the cursor relative by x and y.
func Right(n int)
Right moves the cursor n characters to the right relative to the current position.
func Show()
Show the cursor if it was hidden previously. Don't forget to show the cursor at least at the end of your application. Otherwise the user might have a terminal with a permanently hidden cursor, until he reopens the terminal.
func StartOfLine()
StartOfLine moves the cursor to the start of the current line.
func StartOfLineDown(n int)
StartOfLineDown moves the cursor down by n lines, then moves to cursor to the start of the line.
func StartOfLineUp(n int)
StartOfLineUp moves the cursor up by n lines, then moves to cursor to the start of the line.
func Up(n int)
Up moves the cursor n lines up relative to the current position.
func UpAndClear(n int)
UpAndClear moves the cursor up by n lines, then clears the line.
AtomicGo.dev · with ❤️ by @MarvinJWendt | MarvinJWendt.com