Skip to content

pzl/tui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc

tui is a low-level terminal interface library. It is mostly just a wrapper around ANSI terminal escape codes, and terminal input handling.

Getting started with fancy screen features is easy:

package main

import (
    "fmt"
    "strings"
    "time"
    "github.com/pzl/tui/ansi"
)

func main() {
    w := ansi.NewWriter(nil)
    w.CursorHide()
    defer w.CursorShow()

    const max = 50
    for i := 0; i <= max; i++ {
        w.Column(0)
        w.ClearLineRight()
        fmt.Printf("%s[%s%s>%s%s]%s % 3.0f%%",
            ansi.Cyan,
            ansi.Green,
            strings.Repeat("=", i),
            strings.Repeat(" ", max-i),
            ansi.Cyan,
            ansi.Reset,
            (float64(i)/max)*100,
        )
        time.Sleep(70 * time.Millisecond)
    }
    fmt.Print("\n")
}

progress-bar

Or you can present full-screen apps with keyboard and mouse control. There are more examples in the _demos folder. You can also check out the docs on godoc.

This library tries to do very little for you. This means more manual work if you use it, but ultimate flexibility. There is no concept of state, or repainting in tui. That is to be implemented in your apps.

the tui top-level package provides keyboard/mouse event handling if your program chooses to take input control. The ansi sub-package is just for outputting things (color, text effects, clearing, cursor movement, etc).

LICENSE

MIT License (c) Dan Panzarella 2019

About

golang terminal interface library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages