Advanced terminal output in Go
Switch branches/tags
Nothing to show
Latest commit bc6c333 Mar 17, 2017 @buger committed on GitHub Merge pull request #12 from dimapaloskin/cursor-movements
Add "relative" cursor movement functions


This library provides basic building blocks for building advanced console UIs.

Initially created for Gor.

Full API documentation:

Basic usage

Full screen console app, printing current time:

import (
    tm ""

func main() {
    tm.Clear() // Clear current screen

    for {
        // By moving cursor to top-left position we ensure that console output
        // will be overwritten each time, instead of adding new.

        tm.Println("Current Time:", time.Now().Format(time.RFC1123))

        tm.Flush() // Call it every time at the end of rendering


This can be seen in examples/time_example.go. To run it yourself, go into your $GOPATH/src/ directory and run go run ./examples/time_example.go

Print red bold message on white background:

tm.Println(tm.Background(tm.Color(tm.Bold("Important header"), tm.RED), tm.WHITE))

Create box and move it to center of the screen:


// Create Box with 30% width of current screen, and height of 20 lines
box := tm.NewBox(30|tm.PCT, 20, 0)

// Add some content to the box
// Note that you can add ANY content, even tables
fmt.Fprint(box, "Some box content")

// Move Box to approx center of the screen
tm.Print(tm.MoveTo(box.String(), 40|tm.PCT, 40|tm.PCT))


This can be found in examples/box_example.go.

Draw table:

// Based on
totals := tm.NewTable(0, 10, 5, ' ', 0)
fmt.Fprintf(totals, "Time\tStarted\tActive\tFinished\n")
fmt.Fprintf(totals, "%s\t%d\t%d\t%d\n", "All", started, started-finished, finished)

This can be found in examples/table_example.go.

Line charts

Chart example:

screen shot 2013-07-09 at 5 05 37 pm

    import (
        tm ""

    chart := tm.NewLineChart(100, 20)
    data := new(tm.DataTable)

    for i := 0.1; i < 10; i += 0.1 {
		data.addRow(i, math.Sin(i), math.Cos(i+1))

This can be found in examples/chart_example.go.

Drawing 2 separate graphs in different scales. Each graph have its own Y axe.

chart.Flags = tm.DRAW_INDEPENDENT

Drawing graph with relative scale (Grapwh draw starting from min value instead of zero)

chart.Flags = tm.DRAW_RELATIVE