๐Ÿ”น Golang module to move the terminal cursor in any direction on every operating system.

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

Owner
AtomicGo
โœจ Small Golang libraries to make developers life easier!
AtomicGo
Similar Resources

Command-line tools for the FFS module.

Command-line tools for FFS The blobd tool defines a JSON-RPC service that implements the FFS blob store interface over various underlying key-value st

Dec 14, 2022

go-editor is the clean go module that refractors from Kubernetes to help you edit resources in a command-line way.

go-editor The source code of go-editor comes from Kubernetes and refractor as the clean Go module. You can embed go-editor in your command-line tool l

Dec 5, 2021

Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies.

Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies.

Sensible and fast command-line flag parsing with excellent support for subcommands and positional values. Flags can be at any position. Flaggy has no

Jan 1, 2023

Make any Go function into a API (FaaS)

faas Make any (Go) function into an API with one HTTP request. This is a FaaS: functions as a service. But, in actuality, its more of a FaaSSS: functi

Dec 30, 2022

a work time management CLI tool for any platform

a work time management CLI tool for any platform

english |ๆ—ฅๆœฌ่ชž jobgosh | job management tool made with golang for shell a multi-platform work time management CLI tool to track and improve your day to

May 16, 2022

Aces is a command line utility that lets you encode any file to a character set of your choice.

Aces Any Character Encoding Set Aces is a command line utility that lets you encode any file to a character set of your choice. For example, you could

Nov 28, 2022

๐Ÿš€ Get Youtube Live stream chat feed without any authentication!

youtube-live-chat-downloader Fetches Youtube live chat messages with no authentication required. How does it work? The request for fetching live chat

Oct 17, 2022

Cli tool to translate text from any language into german

GERMAN A cli tool for converting text into German. Build Locally $ go build $ go install Dependencies To execute successfully, a free tier DEEPL API

Jan 24, 2022

๐Ÿ—๏ธ Fetch a specific commit without any history (shallow depth w/o cloning)

shallow-fetch-sha ๐Ÿ—๏ธ For a given git repository and commit, fetch and checkout just that commit without any history. This can be extremely useful in

Nov 27, 2021
Comments
  • Add ability to set custom io.writter for the Area

    Add ability to set custom io.writter for the Area

    Acording to this: https://github.com/pterm/pterm/issues/261#issuecomment-1069475206 Can I have option for setting custom io.writter for the Area. If it is needed, can I create a PR for this?

  • Can't install this library using

    Can't install this library using "go get" command (error: module declares its path as: atomicgo.dev/cursor but was required as: github.com/atomicgo/cursor )

    I found this library useful for my current project but I am getting error while installing this lib using "go get" command and I also changed the module name of the library and tried installing but the error doesn't go away So now I am looking for a possible solution.

    (error: module declares its path as: atomicgo.dev/cursor but was required as: github.com/atomicgo/cursor )

    GoLang version : 1.19 OS: Windows 10

    Thank you ๐Ÿ˜Š.

  • Add ability to set custom io.writer

    Add ability to set custom io.writer

    Add ability to set custom io.writter for cursor. And maybe add the hacktoberfest label. :)

    to be able to finish https://github.com/pterm/pterm/issues/261

A simple tool which you can use to move through your directories from the command line

Fe What is Fe ? Fe is a simple tool which you can use to move through your direc

Jan 1, 2022
Fetches the output for an AWS SSM command for every target

AWSCommander Fetches the output for an AWS SSM command for every target. Optionally outputs as HTML. Examples Get command from Tokio Japan as text AWS

Nov 24, 2021
Splasher is a tool to change desktop wallpaper random every 2 minutes from unsplash.

Splasher Splasher is a tool to change desktop wallpaper random every 2 minutes from unsplash. Download Latest Release: GitHub Release Installation & S

Jan 7, 2022
๐Ÿ’ป PTerm | Pretty Terminal Printer A golang module to print pretty text
๐Ÿ’ป PTerm | Pretty Terminal Printer A golang module to print pretty text

โœจ PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more ?? It's completely configurable and 100% cross-platform compatible.

Jan 1, 2023
A terminal designed for anyone to use and designed for any platform

A terminal designed for anyone to use and designed for any platform. Which includes the basic features of any terminal and includes friendly commands to perform tools such as ping, traceroute, generate key pairs, encrypt/decrypt, router security actions, etc. All of the source code is done in Go.

Jan 25, 2022
A client for managing authzed or any API-compatible system from your command line.

zed A client for managing authzed or any API-compatible system from your command line. Installation zed is currently packaged by as a head-only Homebr

Dec 31, 2022
A CLI tool to find the absolute path of any folder in your local file system.

Table of Contents What is this? How to use this Examples of usage How to compile it What am I looking at It's a CLI tool that I made for finding the a

Jan 15, 2022
Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.
Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.

Stonks is a terminal based stock visualizer and tracker. Installation Requirements: golang >= 1.13 Manual Clone the repo Run make && make install Pack

Dec 16, 2022
remindme is a simple application to set reminders from the CLI that integrates with your system's notification system.
remindme is a simple application to set reminders from the CLI that integrates with your system's notification system.

remindme remindme is a simple application to set reminders from the CLI that integrates with your system's notification system. Examples Once the serv

Nov 24, 2022
Sense your go module as iTerm2 tab colours
Sense your go module as iTerm2 tab colours

Synesthesia updates your iTerm2 tab colours depending on the go module name in your directory ancestry.

Aug 10, 2022