Pure Go termbox implementation

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

Comments
  • KeyEnter and KeyCtrlM map to the same Hex value

    KeyEnter and KeyCtrlM map to the same Hex value

    See code here... https://github.com/nsf/termbox-go/blob/e788edde8c11a0755b83a1fba8e7e578cfe484ef/api_common.go#L96

    	KeyEnter          Key = 0x0D
    	KeyCtrlM          Key = 0x0D
    

    I found this out the hard way while I attempted to bind KeyCtrlM for something and found out by accident that when I hit the Enter key I got the same behavior.... a feature; not a bug perhaps?

  • Chinese characters support issue

    Chinese characters support issue

    My terminal application using github.com/jroimartin/gocui which based on termbox-go, but I found some display issues.

    termbox.SetCell(x, y int, ch rune, fg, bg Attribute)
    

    The following issues are caused by setCell with Chinese character.

    • It works well when I tried to input Chinese characters one by one ,but characters overlapped likes this

    my input is [中文].

    image
    • Some characters disappear when I tried to input more than one Chinese characters , like this

    my input is [中文中文].

    image
  • 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

  • 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

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

A simple command line -based snake game built with go and termbox
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

Jan 16, 2022
The pure golang implementation of nanomsg (version 1, frozen)
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

Dec 7, 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.

Oct 19, 2022
A QUIC implementation in pure go
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

Jan 9, 2023
Pure Go implementation of the WebRTC API
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

Jan 1, 2023
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

Jan 1, 2023
mangos is a pure Golang implementation of nanomsg's "Scalablilty Protocols"
mangos is a pure Golang implementation of nanomsg's

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

Jan 1, 2023
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

Dec 16, 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

Oct 6, 2022
Pure Go implementation of the WebRTC API
Pure Go implementation of the WebRTC API

Pure Go implementation of the WebRTC API

Jan 8, 2023
Pure Go implementation of the WebRTC API
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

Jan 9, 2023
A Blurhash implementation in pure Go (Decode/Encode)
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

Dec 27, 2022
A highly extensible Git implementation in pure Go.
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

Jan 8, 2023
Readline is a pure go(golang) implementation for GNU-Readline kind library
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

Jan 8, 2023
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

Dec 6, 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

Jan 9, 2023
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

Dec 16, 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).

Dec 29, 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

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

Nov 8, 2022