Giter Club home page Giter Club logo

vt100's Introduction

VT100

Build Status GoDoc License Go Report Card

  • Supports colors and attributes.
  • Supports platforms with VT100 support and a /dev/tty device.
  • Can detect the terminal size.
  • Can get key-presses, including arrow keys (252, 253, 254, 255).
  • Has a Canvas struct, for drawing only the updated lines to the terminal.
  • Uses the a reference document directly, but memoizes the commands sent to the terminal, for performance.
  • Could be used for making an alternative to the dialog or whiptail utilities.

Editor

For an editor that uses this module, take a look at orbiton.

Images

shooter example

Screen recording of the shooter example, where you can control a small character with the arrow keys and shoot with space.


menu example

Screen recording of the menu example, which uses VT100 terminal codes and demonstrates a working menu.


VT100 terminal

A physical VT100 terminal. Photo by Jason Scott, CC BY 2.0

Requirements

  • Go 1.17 or later.

Features and limitations

  • Can detect letters, arrow keys and space. F12 and similar keys are not supported (they are supported by VT220 but not VT100).
  • Resizing the terminal when using the Canvas struct may cause artifacts, for a brief moment.
  • Holding down a key may trigger key repetition which may speed up the main loop.

Simple use

Output "hi" in blue:

vt100.Blue.Output("hi")

Erase the current line:

vt100.Do("Erase Line")

Move the cursor 3 steps up (it's a bit verbose, but it is memoized for better performance):

vt100.Set("Cursor Up", map[string]string{"{COUNT}": "3"})

The full overview of possible commands are at the top of vt100.go.

Another example

See cmd/move for a more advanced example, where a character can be moved around with the arrow keys.

A small editor using vt100

The Orbiton editor that uses vt100 can be used for editing Go, Bash or for example C++ code.

Quick installation:

go install github.com/xyproto/o/v2@latest

General info

vt100's People

Contributors

xyproto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.