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

Overview

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

You might also like...
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

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

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

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

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

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

๐Ÿš€ 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

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

๐Ÿ—๏ธ 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

Comments
Releases(v0.1.1)
  • v0.1.1(Jun 5, 2022)

    What's Changed

    • proposal to add windows support to the custom target functionality by @Brookke in https://github.com/atomicgo/cursor/pull/8
    • Fixed Bug when terminal has no space down and a new area is created by @MarvinJWendt in https://github.com/atomicgo/cursor/pull/10

    New Contributors

    • @Brookke made their first contribution in https://github.com/atomicgo/cursor/pull/8

    Full Changelog: https://github.com/atomicgo/cursor/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Jun 3, 2022)

    What's Changed

    • Use they in comment by @ruudk in https://github.com/atomicgo/cursor/pull/4
    • adds the ability to set a custom writer (#5) by @willmadison in https://github.com/atomicgo/cursor/pull/6

    New Contributors

    • @ruudk made their first contribution in https://github.com/atomicgo/cursor/pull/4
    • @willmadison made their first contribution in https://github.com/atomicgo/cursor/pull/6

    Full Changelog: https://github.com/atomicgo/cursor/compare/v0.0.1...v0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
AtomicGo
โœจ Small Golang libraries to make developers life easier!
AtomicGo
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

Pranav Baburaj 8 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

Michael Bradley 0 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

XXIV 0 Jan 7, 2022
๐Ÿ’ป 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.

null 3.1k Nov 29, 2022
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.

Karun Kanda 1 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

authzed 51 Nov 18, 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

Benyakir Horowitz 0 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. Installation Requirements: golang >= 1.13 Manual Clone the repo Run make && make install Pack

Eric Moynihan 516 Nov 16, 2022
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

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

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

Rory Quinn 8 Aug 10, 2022