GithubHelp home page GithubHelp logo

brookke / cursor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atomicgo/cursor

1.0 0.0 0.0 59 KB

🔹 Golang module to move the terminal cursor in any direction on every operating system.

Home Page: https://atomicgo.dev

License: MIT License

Go 100.00%

cursor's Introduction

AtomicGo | cursor

Latest Release Tests Coverage Unit test count Issues License: MIT


Get The Module | Documentation | Contributing | Code of Conduct


AtomicGo

Description

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.

Install

# Execute this command inside your project
go get -u github.com/atomicgo/cursor
// Add this to your imports
import "github.com/atomicgo/cursor"

Usage

func Bottom

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

func ClearLine()

ClearLine clears the current line and moves the cursor to it's start position.

func ClearLinesDown

func ClearLinesDown(n int)

ClearLinesDown clears n lines downwards from the current position and moves the cursor.

func ClearLinesUp

func ClearLinesUp(n int)

ClearLinesUp clears n lines upwards from the current position and moves the cursor.

func Down

func Down(n int)

Down moves the cursor n lines down relative to the current position.

func DownAndClear

func DownAndClear(n int)

DownAndClear moves the cursor down by n lines, then clears the line.

func Hide

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

func HorizontalAbsolute(n int)

HorizontalAbsolute moves the cursor to n horizontally. The position n is absolute to the start of the line.

func Left

func Left(n int)

Left moves the cursor n characters to the left relative to the current position.

func Move

func Move(x, y int)

Move moves the cursor relative by x and y.

func Right

func Right(n int)

Right moves the cursor n characters to the right relative to the current position.

func Show

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

func StartOfLine()

StartOfLine moves the cursor to the start of the current line.

func StartOfLineDown

func StartOfLineDown(n int)

StartOfLineDown moves the cursor down by n lines, then moves to cursor to the start of the line.

func StartOfLineUp

func StartOfLineUp(n int)

StartOfLineUp moves the cursor up by n lines, then moves to cursor to the start of the line.

func Up

func Up(n int)

Up moves the cursor n lines up relative to the current position.

func UpAndClear

func UpAndClear(n int)

UpAndClear moves the cursor up by n lines, then clears the line.

type Area

type Area struct {
}

Area displays content which can be updated on the fly. You can use this to create live output, charts, dropdowns, etc.

func NewArea

func NewArea() Area

NewArea returns a new Area.

func (*Area) Clear

func (area *Area) Clear()

Clear clears the content of the Area.

func (*Area) Update

func (area *Area) Update(content string)

Update overwrites the content of the Area.


AtomicGo.dev  ·  with ❤️ by @MarvinJWendt | MarvinJWendt.com

cursor's People

Contributors

marvinjwendt avatar ruudk avatar willmadison avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.