Pure Go termbox implementation

Overview

GoDoc

IMPORTANT

This library is somewhat not maintained anymore. But I'm glad that it did what I wanted the most. It moved people away from "ncurses" mindset and these days we see both re-implementations of termbox API in various languages and even possibly better libs with similar API design. If you're looking for a Go lib that provides terminal-based user interface facilities, I've heard that https://github.com/gdamore/tcell is good (never used it myself). Also for more complicated interfaces and/or computer games I recommend you to consider using HTML-based UI. Having said that, termbox still somewhat works. In fact I'm writing this line of text right now in godit (which is a text editor written using termbox-go). So, be aware. Good luck and have a nice day.

Termbox

Termbox is a library that provides a minimalistic API which allows the programmer to write text-based user interfaces. The library is crossplatform and has both terminal-based implementations on *nix operating systems and a winapi console based implementation for windows operating systems. The basic idea is an abstraction of the greatest common subset of features available on all major terminals and other terminal-like APIs in a minimalistic fashion. Small API means it is easy to implement, test, maintain and learn it, that's what makes the termbox a distinct library in its area.

Installation

Install and update this go package with go get -u github.com/nsf/termbox-go

Examples

For examples of what can be done take a look at demos in the _demos directory. You can try them with go run: go run _demos/keyboard.go

There are also some interesting projects using termbox-go:

  • godit is an emacsish lightweight text editor written using termbox.
  • gotetris is an implementation of Tetris.
  • sokoban-go is an implementation of sokoban game.
  • hecate is a hex editor designed by Satan.
  • httopd is top for httpd logs.
  • mop is stock market tracker for hackers.
  • termui is a terminal dashboard.
  • termloop is a terminal game engine.
  • xterm-color-chart is a XTerm 256 color chart.
  • gocui is a minimalist Go library aimed at creating console user interfaces.
  • dry is an interactive cli to manage Docker containers.
  • pxl displays images in the terminal.
  • snake-game is an implementation of the Snake game.
  • gone is a CLI pomodoro® timer.
  • Spoof.go controllable movement spoofing from the cli.
  • rat lets you compose shell commands to build terminal applications.
  • httplab An interactive web server.
  • wot Wait time during command is completed.
  • 2048-go is 2048 in Go.
  • jv helps you view JSON on the command-line.
  • pinger helps you to monitor numerous hosts using ICMP ECHO_REQUEST.
  • vixl44 lets you create pixel art inside your terminal using vim movements.
  • zterm is a typing game inspired by http://zty.pe/.
  • gotypist is a fun touch-typing tutor following Steve Yegge's method.
  • cointop is an interactive terminal based UI application for tracking cryptocurrencies.
  • pexpo is a terminal sending ping tool written in Go.
  • jid is an interactive JSON drill down tool using filtering queries like jq.
  • nonograminGo is a nonogram (aka. picross) in Go.
  • tower-of-go is a tiny maze game that runs on the terminal.

API reference

godoc.org/github.com/nsf/termbox-go

Issues
  • Why output is ahead of my command rather than after?

    Why output is ahead of my command rather than after?

    sample code: https://github.com/yeqown/go-qrcode/blob/main/example/use-tereminal-writer/main.go

    I tried use termbox in my project, but after I run my example, I didn't see any thing after my command but find the output ahead of my command. like this:

    image

    Actually, I start a new session in iterm, ahead of my command should be nothing. So what cause this? help plz

    opened by yeqown 0
  • Panic on FreeBSD host

    Panic on FreeBSD host

    Hello. I get a panic while trying to run demo:

    $ go run _demos/keyboard.go
    panic: runtime error: index out of range [15] with length 14
    	panic: runtime error: index out of range [14] with length 14
    
    goroutine 1 [running]:
    github.com/nsf/termbox-go.Close()
    	/home/oleksandr.anyshchenko/termbox-go/api.go:146 +0x4d2
    panic(0x4fc5c0, 0xc0000de000)
    	/usr/local/go/src/runtime/panic.go:965 +0x1b9
    github.com/nsf/termbox-go.SetInputMode(0x5, 0x0)
    	/home/oleksandr.anyshchenko/termbox-go/api.go:483 +0x1e5
    main.main()
    	/home/oleksandr.anyshchenko/termbox-go/_demos/keyboard.go:702 +0x7d
    exit status 2
    

    FreeBSD 12.2 Go 1.16.3

    opened by aleksuss 5
  • Close without clear screen

    Close without clear screen

    If I am reading the code right:

    https://github.com/nsf/termbox-go/blob/ed494de23a004d7298fbc78a95595388979cd777/api.go#L136-L144

    it seems currently any call to Close clears the screen without option. Is it possible to Close while retaining the current output? I am thinking of something like Less where it has an option for that:

    https://serverfault.com/questions/785949/how-can-i-keep-the-content-i-was-reading-from-man-after-i-quit

    opened by 89z 6
  • Switch screens

    Switch screens

    This is a draft regarding #162 #182 #206 because I'd be interested in such a functionality and the possibilities they imply. Those issues suggest adding functionality to switch between screens. Screens are also referred to as "alternate screen" or "cup mode".

    This draft implements basic functionality to switch between screens, although I did not extensively test anything. I guess these three refer to a functionality similar to this:

    Peek 2020-12-15 12-54 (This is editbox.go with an added call to SelectScreen(false) after the initialization, for convenience I added it as screens.go)

    Notice how I can't override an existing character using a space.

    Also note that it is impossible to read what characters were there before termbox was started.

    If I'm not mistaken, nsf has previously expressed that he is not interested in such a feature, so I'll wait for some feedback on this matter.

    opened by scrouthtv 0
  • Wine panics (

    Wine panics ("Invalid handle")

    I get an Invalid handle panic during Init() when it calls clear() on Wine. There are several issues filed that look similar, but which occur in different places. This may be specific to Wine.

    The closest issue appears to be #125, although the work-around in that ticket uses hiding the cursor, and Init() hides the cursor before calling clear() so it may be unrelated.

    #199 is a panic on Close(); #217 is far past Init(); #174 indicates that termbox-go uses the native Windows API, which might point to the issue when running under Wine.

    opened by xxxserxxx 0
A simple command line -based snake game built with go and termbox

snake-task Snake Game A simple command line -based snake game built with go and termbox library. This is a test task for a Golang positon. It took me

Kingsley Ugwudinso 1 Jan 16, 2022
The pure golang implementation of nanomsg (version 1, frozen)

mangos NOTE: This is the legacy version of mangos (v1). Users are encouraged to use mangos v2 instead if possible. No further development is taking pl

nanomsg 1.5k Jun 22, 2022
Pure Go implementation of D. J. Bernstein's cdb constant database library.

Pure Go implementation of D. J. Bernstein's cdb constant database library.

John Barham 222 Jun 12, 2022
A QUIC implementation in pure go

A QUIC implementation in pure Go quic-go is an implementation of the QUIC protocol in Go. It implements the IETF QUIC draft-29 and draft-32. Version c

Lucas Clemente 7k Aug 1, 2022
Pure Go implementation of the WebRTC API

Pion WebRTC A pure Go implementation of the WebRTC API New Release Pion WebRTC v3.0.0 has been released! See the release notes to learn about new feat

Pion 9.7k Aug 4, 2022
A Windows named pipe implementation written in pure Go.

npipe Package npipe provides a pure Go wrapper around Windows named pipes. Windows named pipe documentation: http://msdn.microsoft.com/en-us/library/w

Nate Finch 249 Jul 27, 2022
mangos is a pure Golang implementation of nanomsg's "Scalablilty Protocols"

mangos Mangos™ is an implementation in pure Go of the SP (“Scalability Protocols”) messaging system. These are colloquially known as a “nanomsg”. ❗ Th

nanomsg 534 Aug 6, 2022
Pure Go implementation of the NaCL set of API's

go-nacl This is a pure Go implementation of the API's available in NaCL: https://nacl.cr.yp.to. Compared with the implementation in golang.org/x/crypt

Kevin Burke 526 Aug 5, 2022
Package git provides an incomplete pure Go implementation of Git core methods.

git Package git provides an incomplete pure Go implementation of Git core methods. Example Code: store := git.TempStore() defer os.RemoveAll(string(st

Daniel Skinner 27 Mar 1, 2022
Pure Go implementation of the WebRTC API

Pure Go implementation of the WebRTC API

Pion 9.7k Aug 8, 2022
Pure Go implementation of the WebRTC API

Pion WebRTC A pure Go implementation of the WebRTC API New Release Pion WebRTC v3.0.0 has been released! See the release notes to learn about new feat

Pion 9.6k Jul 30, 2022
A Blurhash implementation in pure Go (Decode/Encode)

go-blurhash go-blurhash is a pure Go implementation of the BlurHash algorithm, which is used by Mastodon an other Fediverse software to implement a sw

buckket 151 Jul 3, 2022
A highly extensible Git implementation in pure Go.

go-git is a highly extensible git implementation library written in pure Go. It can be used to manipulate git repositories at low level (plumbing) or

go-git 3.7k Aug 9, 2022
Readline is a pure go(golang) implementation for GNU-Readline kind library

A powerful readline library in Linux macOS Windows Solaris Guide Demo Shortcut Repos using readline Feedback If you have any questions, please submit

chzyer 1.8k Aug 1, 2022
NanoVGo NanoVGNanoVGo is pure golang implementation of NanoVG. The same author maintains the NanoGUI.go project mentioned above.

NanoVGo Pure golang implementation of NanoVG. NanoVG is a vector graphics engine inspired by HTML5 Canvas API. DEMO API Reference See GoDoc Porting Me

Yoshiki Shibukawa 139 May 21, 2022
Pure Go implementation of jq

gojq Pure Go implementation of jq This is an implementation of jq command written in Go language. You can also embed gojq as a library to your Go prod

itchyny 1.4k Jul 31, 2022
Pure Go implementation of the NaCL set of API's

go-nacl This is a pure Go implementation of the API's available in NaCL: https://nacl.cr.yp.to. Compared with the implementation in golang.org/x/crypt

Kevin Burke 526 Aug 5, 2022
This an implementation of Jsonnet in pure Go.

This an implementation of Jsonnet in pure Go. It is a feature complete, production-ready implementation. It is compatible with the original Jsonnet C++ implementation. Bindings to C and Python are available (but not battle-tested yet).

Google 1.2k Aug 3, 2022
A Standalone MPQUIC implementation in pure Go

A Standalone MPQUIC implementation in pure Go Inspired and based on: https://multipath-quic.org/2017/12/09/artifacts-available.html mpquic_actor_criti

null 0 Nov 24, 2021
A pure Golang implementation of Rockchip rknand vendor storage interface.

go-rkvendorstorage A pure Golang implementation of Rockchip rknand vendor storage interface. Usage package main import ( "fmt" "github.com/jamesits

James Swineson 3 May 31, 2022
Fluent.go - A pure Go implementation of Project Fluent

fluent.go fluent.go is a pure Go implementation of Project Fluent Important noti

lukas 10 Jun 15, 2022
A pure-Go implementation of the CVE-2021-4034 PwnKit exploit

go-PwnKit A pure-Go implementation of the CVE-2021-4034 PwnKit exploit. Installation git clone [email protected]:OXDBXKXO/go-PwnKit.git cd go-PwnKit make

null 4 Mar 2, 2022
Go language implementation of a blockchain based on the BDLS BFT protocol. The implementation was adapted from Ethereum and Sperax implementation

BDLS protocol based PoS Blockchain Most functionalities of this client is similar to the Ethereum golang implementation. If you do not find your quest

Yongge Wang 0 Jan 1, 2022
Pure Go line editor with history, inspired by linenoise

Liner Liner is a command line editor with history. It was inspired by linenoise; everything Unix-like is a VT100 (or is trying very hard to be). If yo

Peter Harris 910 Jul 28, 2022
LZ4 compression and decompression in pure Go

lz4 : LZ4 compression in pure Go Overview This package provides a streaming interface to LZ4 data streams as well as low level compress and uncompress

Pierre Curto 676 Aug 2, 2022
The minilock file encryption system, ported to pure Golang. Includes CLI utilities.

Go-miniLock A pure-Go reimplementation of the miniLock asymmetric encryption system. by Cathal Garvey, Copyright Oct. 2015, proudly licensed under the

Cathal Garvey 171 May 29, 2022
A simple, fast, embeddable, persistent key/value store written in pure Go. It supports fully serializable transactions and many data structures such as list, set, sorted set.

NutsDB English | 简体中文 NutsDB is a simple, fast, embeddable and persistent key/value store written in pure Go. It supports fully serializable transacti

徐佳军 2.3k Aug 8, 2022
Low-level key/value store in pure Go.

Description Package slowpoke is a simple key/value store written using Go's standard library only. Keys are stored in memory (with persistence), value

Vadim Kulibaba 99 Mar 13, 2022
Pure Go Postgres driver for database/sql

pq - A pure Go postgres driver for Go's database/sql package Install go get github.com/lib/pq Features SSL Handles bad connections for database/sql S

null 7.5k Jul 31, 2022