Categorygithub.com/nsf/termbox-go
modulepackage
1.1.1
Repository: https://github.com/nsf/termbox-go.git
Documentation: pkg.go.dev

# README

Go Reference Build

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 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 various examples 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.

# Functions

AttributeToRGB converts an Attribute to the underlying rgb triplet.
Returns a slice into the termbox's back buffer.
Clears the internal back buffer.
Finalizes termbox library, should be called after successful initialization when termbox's functionality isn't required anymore.
Synchronizes the internal back buffer with the terminal.
Returns the specified cell from the internal back buffer.
The shortcut for SetCursor(-1, -1).
Initializes termbox library.
Interrupt an in-progress call to PollEvent by causing it to return EventInterrupt.
After getting a raw event from PollRawEvent function call, you can parse it again into an ordinary one using termbox logic.
Wait for an event and return it.
Wait for an event and return it.
RGBToAttribute is used to convert an rgb triplet into a termbox attribute.
Changes cell's background attributes in the internal back buffer at the specified position.
Changes cell's parameters in the internal back buffer at the specified position.
Changes cell's character (rune) in the internal back buffer at the specified position.
Sets the position of the cursor.
Changes cell's foreground attributes in the internal back buffer at the specified position.
Sets termbox input mode.
Sets the termbox output mode.
Returns the size of the internal back buffer (which is mostly the same as terminal's window size in characters).
Sync comes handy when something causes desync between termbox's understanding of a terminal buffer and the reality.

# Constants

Cell attributes, it is possible to use multiple attributes by combining them using bitwise OR ('|').
Cell attributes, it is possible to use multiple attributes by combining them using bitwise OR ('|').
Cell attributes, it is possible to use multiple attributes by combining them using bitwise OR ('|').
Cell attributes, it is possible to use multiple attributes by combining them using bitwise OR ('|').
Cell attributes, it is possible to use multiple attributes by combining them using bitwise OR ('|').
Cell attributes, it is possible to use multiple attributes by combining them using bitwise OR ('|').
Cell attributes, it is possible to use multiple attributes by combining them using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Cell colors, you can combine a color with multiple attributes using bitwise OR ('|').
Event type.
Event type.
Event type.
Event type.
Event type.
Event type.
Event type.
Input mode.
Input mode.
Input mode.
Input mode.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Alt modifier constant, see Event.Mod field and SetInputMode function.
Alt modifier constant, see Event.Mod field and SetInputMode function.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Key constants, see Event.Key field.
Output mode.
Output mode.
Output mode.
Output mode.
Output mode.
Output mode.

# Variables

To know if termbox has been initialized or not.

# Structs

A cell, single conceptual entity on the screen.
This type represents a termbox event.

# Type aliases