Golang terminal dashboard

termui

demo cast under osx 10.10; Terminal.app; Menlo Regular 12pt.)

termui is a cross-platform and fully-customizable terminal dashboard and widget library built on top of termbox-go. It is inspired by blessed-contrib and tui-rs and written purely in Go.

Features

  • Several premade widgets for common use cases
  • Easily create custom widgets
  • Position widgets either in a relative grid or with absolute coordinates
  • Keyboard, mouse, and terminal resizing events
  • Colors and styling

Installation

Go modules

It is not necessary to go get termui, since Go will automatically manage any imported dependencies for you. Do note that you have to include /v3 in the import statements as shown in the 'Hello World' example below.

Dep

Add with dep ensure -add github.com/gizak/termui. With Dep, /v3 should not be included in the import statements.

Hello World

package main

import (
	"log"

	ui "github.com/gizak/termui/v3"
	"github.com/gizak/termui/v3/widgets"
)

func main() {
	if err := ui.Init(); err != nil {
		log.Fatalf("failed to initialize termui: %v", err)
	}
	defer ui.Close()

	p := widgets.NewParagraph()
	p.Text = "Hello World!"
	p.SetRect(0, 0, 25, 5)

	ui.Render(p)

	for e := range ui.PollEvents() {
		if e.Type == ui.KeyboardEvent {
			break
		}
	}
}

Widgets

Run an example with go run _examples/{example}.go or run each example consecutively with make run-examples.

Documentation

Uses

Related Works

License

MIT

Owner
Zack Guo
May the --force be with you.
Zack Guo
Comments
  • Suggestion: plain-text configuration

    Suggestion: plain-text configuration

    This is a surprising and awesome tool, but you need to write Go to use it.

    Reading widgets from a configuration file, in any popular format, would make the tool easier to configure and available to a much larger range of developers.

  • screen / byobu encoding

    screen / byobu encoding

    termui works perfectly via ssh and on my desktop terminal. But when I try to use via screen or byobu it breaks the window borders.

    How can I fix the strange characters?

    captura de tela 2016-02-08 as 22 53 25

    Is there any way to keep it compatible with screen or byobu screen?

    These screenshot was on screen. Using byobu is even worst because it breaks the window size.

  • Flickering render

    Flickering render

    I just upgraded my project (https://github.com/byrnedo/dockdash/tree/feature/new_termui) to the latest termui. Maybe not according to best practices but just to make an easy first port I've done the following:

    I have one main select loop where I hold state ( up/down position, displayable data... ) All my key handlers are signalling to a channel which is read by this select. Any data updates are also sent to a channel which is read by the select as well. Any of these events will trigger a render. I also have a timer (1s) running which signals another channel also read by this select which renders.

    The basic rendering flow I have is the same as before I upgraded ( ie all rendering is done in the same select ).

    I'm experiencing flickering now though with every render.

    Is there a likely cause of this? I see that the rendering in termui is now done in a routine ( perhaps it was before too?)

    EDIT:

    I notice it gets worse the larger the size of the terminal window.

  • Tree widget

    Tree widget

    Hello, there. I've created a tree widget for my project. I believe this can be useful for anyone else :) Let me know, please, what you think about that.

    Thanks for the termui project!

  • go get error

    go get error

    $ go get -u github.com/gizak/termui
    # github.com/gizak/termui
    ../../../github.com/gizak/termui/render.go:107:30: not enough arguments in call to stack.ParseDump
            have (*bytes.Reader, *os.File)
            want (io.Reader, io.Writer, bool)
    ../../../github.com/gizak/termui/render.go:112:10: undefined: stack.Palette
    ../../../github.com/gizak/termui/render.go:113:15: undefined: stack.SortBuckets
    ../../../github.com/gizak/termui/render.go:113:33: undefined: stack.Bucketize
    ../../../github.com/gizak/termui/render.go:114:22: undefined: stack.CalcLengths
    

    maruel/panicparse API has changed 3 days ago.

  • Colored list #4

    Colored list #4

    Colored lists #4

    Don't merge, yet! The development has not quite finished, yet. This is just a preview.

    screen shot 2015-04-06 at 12 15 21 am

    So, that's what I've done so far:

    • I added the Markdown-flavored renderer (MarkdownTextRenderer) and the Noop renderer (NoopRenderer) as well as abstract interfaces and factories for these two.
    • I implemented these into the list.
    • I wrote a lot of unit tests so nothing will (hopefully) break.

    What needs to be done:

    • Fixing the regex (I don't know how to do that correctly. I'd appreciate someone's help.)
    • ~~Adding a ASCII escape code renderer.~~ (Done in a3f1384).
    • Tests under real work scenarios.
    • ~~Writing docs on how to implement it~~ (See: https://github.com/Matt3o12/termui/wiki/Color-Renderers)
    • ~~Refactoring the code (I need some advice from a native speaker here)[2] :)~~ (if you have any feedback, please give it now. Nothing is in the master branch, yet).
    • ~~Adding the renderers to other Bufferer-components?~~ Added in e9e3e40 (Par only).

    How do I use/test the new text renderer? Just do: myList.RendererFactory = termui.MarkdownTextRendererFactory{} :)

    Are these changes backwards compatible? Short: yes, at least when you used NewList() instead of List{} as you're supposed to.

    These changes add a new field to the List: RendererFactory, which generates the TextRenderers. List uses this field for generating the appropriate (colorful) output. If you didn't use the list constructor (NewList()), the compiler will yield an error because of a missing field.
    If you use the constructor, the constructor will set the field to NoopRendererFactory which will not generate any formatted output (as the name states: No Operation).

    If you have any question or feedback, just leave comment.


    [1]: The current regex implementation for finding text sequences that need formatting, doesn't work properly. It will not format: [[ERROR]](red,bold) foo correctly, which should normalize to: [ERROR] foo. Here is the current regex in action with example it should find (https://regex101.com/r/fC0gD1/1). Currently only one expression fails. If you know a regex that will work, please let me know!

    [2]: Everything that formats a text is called TextRenderer. In my dictionary I couldn't find Renderer and I wonder if that is a word, which makes sense. If you find that this word fits properly, let me know. If it doesn't, could you suggest a better one?

  • Install failed on Go 1.11 with `go mod` turned on

    Install failed on Go 1.11 with `go mod` turned on

    go version

    go version go1.11 darwin/amd64
    

    go env

    GOARCH="amd64"
    GOBIN="/Users/CosPotato/go/bin"
    GOCACHE="/Users/CosPotato/Library/Caches/go-build"
    GOEXE=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
    GOPATH="/Users/CosPotato/go"
    GOPROXY=""
    GORACE=""
    GOROOT="/usr/local/go"
    GOTMPDIR=""
    GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
    GCCGO="gccgo"
    CC="gcc"
    CXX="g++"
    CGO_ENABLED="1"
    GOMOD=""
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    

    What have I done

    go get -u github.com/gizak/termui
    

    What I Got

    # github.com/gizak/termui
    ../../../go/pkg/mod/github.com/gizak/[email protected]+incompatible/render.go:107:30: too many arguments in call to stack.ParseDump
            have (*bytes.Reader, *os.File, bool)
            want (io.Reader, io.Writer)
    ../../../go/pkg/mod/github.com/gizak/[email protected]+incompatible/render.go:112:15: undefined: stack.Aggregate
    ../../../go/pkg/mod/github.com/gizak/[email protected]+incompatible/render.go:112:33: gs.Goroutines undefined (type []stack.Goroutine has no field or method Goroutines)
    
  • Allow to plot datapoints with both coordinates defined. Closes #68

    Allow to plot datapoints with both coordinates defined. Closes #68

    Allows users to define both x and y coordinates for linechart. E.g. this will plot line with three "main" points at (4, 1), (6,4) and (10,2) with linear interpolation in between.

    lc.Data = [1, 4, 2]
    lc.IsXS = true
    lc.XS = [4, 6, 10]
    

    This closes #68.

  • Handle timers

    Handle timers

    Hi,

    how is handling timers supposed to work with new API?

    Initially I thought, Handle("/timer/Ns") or Handle("/timer/200ms") should work, but it works only with 1s timer and it seems to be hardcoded or am I missing something?

  • Max value in sparkline/multivalue chart

    Max value in sparkline/multivalue chart

    hi,

    i'm using your library for https://github.com/ulrichSchreiner/dockmon. it would be great to have

    • a max value for sparklines. i render the CPU value with sparklines. it would be great to set the maxvalue for sparklines to a specific value because i know the maximal value and so the sparklines would be comparable.
    • another great option would be a chart widget with multiple lines in differen colors. so i could render all cpu-values in one diagram. or should i use a canvas for this?

    thx, your library is great

  • Run under Tmux ??

    Run under Tmux ??

    On Ubuntu 14.04 - everything looks great in Terminator (xterm).

    But - from Tmux 1.9a the screen looks bad. Anyone have any luck running termui under Tmux??

  • termbox-go v1.1.1 incompatibility issues and wide character related issues

    termbox-go v1.1.1 incompatibility issues and wide character related issues

    I've run the examples with utf8(Chinese) characters , but can't see right result in vscode

    My vscode uses the system cmd, which is in UTF-8 format like the system cmd configuration. But when running the sample file, there are two results. There is an extra space in Chinese in vscode, and it occupies the position of other characters. I don’t know if there is a solution or it’s just a problem with my vocode configuration, thanks image

  • Fix style parser to handle [ or ] in text without style

    Fix style parser to handle [ or ] in text without style

    There is a problem with using [ or ] in text. Style Parser thinks you are going to supply a (style) block after and eats some of the chars:

    https://github.com/gizak/termui/issues/311

    This PR re-writes the logic to look for pairs or "](" and only processes style when needed and leaves normal [ or ] in text alone.

  • Feature Request: add containers for widgets

    Feature Request: add containers for widgets

    The way to set the positions of widgets is through the x1 y1 coordinates in func (*Block) SetRect:

    p := widgets.NewParagraph()
    	p.Title = "Lunar"
    	p.Text = selectedAudio
    	p.SetRect(0, 0, 40, 3)
    	p.TitleStyle.Fg = ui.ColorYellow
    	p.BorderStyle.Fg = ui.ColorCyan
    
    	c := widgets.NewParagraph()
    	c.Title = "Audio Controls"
    	c.Text = `Pause and play music: [ENTER]
    Volume: [↓ ↑]
    Speed:  [← →]
    Normal Speed: [Ctrl + N]
    Back to menu: [BACKSPACE]
    Quit Lunar: [ESC]
    	`
    	c.SetRect(0, 4, 40, 12)
    	c.TitleStyle.Fg = ui.ColorYellow
    	c.BorderStyle.Fg = ui.ColorCyan
    
    	ui.Render(p, c)
    
    

    But this can create overlap over widgets:

    +-Lunar--------------------------------+
    |Playing Charlie Puth                  |
    +--------------------------------------+
    |Normal Speed: [Ctrl + N]              |
    |Back to menu: [BACKSPACE]             |
    |Quit Lunar: [ESC]                     |
    +--------------------------------------+
    

    Preferred output:

    +-Lunar--------------------------------+
    |Playing Charlie Puth                  |
    +--------------------------------------+
    
    +-Audio Controls-----------------------+
    |Pause and play music: [ENTER]         |
    |Volume: [↓ ↑]                         |
    |Speed:  [← →]                         |
    |Normal Speed: [Ctrl + N]              |
    |Back to menu: [BACKSPACE]             |
    |Quit Lunar: [ESC]                     |
    +--------------------------------------+
    

    My idea is to create a container for the widgets like in the Fyne GUI to position the widgets and avoid widget overlap:

    SetContent(NewVericalBox(c, p))
    
  • wishlist: support 'Symbols for Legacy Computing' 'Smooth mosaic terminal graphic characters' for graphs

    wishlist: support 'Symbols for Legacy Computing' 'Smooth mosaic terminal graphic characters' for graphs

    The 'Symbols for Legacy Computing' block in Unicode has many symbols in its 'Smooth mosaic terminal graphic characters' section to represent shapes of graphs as text characters. https://www.unicode.org/charts/PDF/U1FB00.pdf

    Termui could use these and have much smoother looking graphs.

  • Grid cannot be aligned

    Grid cannot be aligned

    I changed it slightly using the sample file grid.go , the boxes in the grid are not aligned at 1/2 column

    	grid.Set(
    		ui.NewRow(1.0/2,
    			ui.NewCol(1.0/2, slg),
    			ui.NewCol(1.0/2, lc),
    		),
    		ui.NewRow(1.0/2,
    			ui.NewCol(1.0/4, ls),
    			ui.NewCol(1.0/4, ls),
    			//ui.NewRow(.9/3, gs[0]),
    			//ui.NewRow(.9/3, gs[1]),
    			//ui.NewRow(1.2/3, gs[2]),
    			ui.NewCol(1.0/2, p),
    		),
    	)
    
    	ui.Render(grid)
    

    image

Intuitive package for prettifying terminal/console output. http://godoc.org/github.com/ttacon/chalk
Intuitive package for prettifying terminal/console output. http://godoc.org/github.com/ttacon/chalk

chalk Chalk is a go package for styling console/terminal output. Check out godoc for some example usage: http://godoc.org/github.com/ttacon/chalk The

Dec 23, 2022
An ANSI colour terminal package for Go

colourize An ANSI colour terminal package for Go. Supports all ANSI colours and emphasis. Not compatible with Windows systems. Installation go get gi

Sep 26, 2022
Console Text Colors - The non-invasive cross-platform terminal color library does not need to modify the Print method

ctc - Console Text Colors The non-invasive cross-platform terminal color library does not need to modify the Print method Virtual unix-like environmen

Nov 9, 2022
Simple tables in terminal with Go

Simple tables in terminal with Go This package allows to generate and display ascii tables in the terminal, f.e.: +----+------------------+-----------

Dec 29, 2022
uilive is a go library for updating terminal output in realtime
uilive is a go library for updating terminal output in realtime

uilive uilive is a go library for updating terminal output in realtime. It provides a buffered io.Writer that is flushed at a timed interval. uilive p

Dec 28, 2022
A go library to render progress bars in terminal applications
A go library to render progress bars in terminal applications

uiprogress A Go library to render progress bars in terminal applications. It provides a set of flexible features with a customizable API. Progress bar

Dec 29, 2022
A go library to improve readability in terminal apps using tabular data

uitable uitable is a go library for representing data as tables for terminal applications. It provides primitives for sizing and wrapping columns to i

Dec 30, 2022
Yet Another CLi Spinner; providing over 70 easy to use and customizable terminal spinners for multiple OSes
Yet Another CLi Spinner; providing over 70 easy to use and customizable terminal spinners for multiple OSes

Yet Another CLi Spinner (for Go) Package yacspin provides yet another CLi spinner for Go, taking inspiration (and some utility code) from the https://

Dec 25, 2022
Terminal string styling for go done right, with full and painless Windows 10 support.
Terminal string styling for go done right, with full and painless Windows 10 support.

GChalk GChalk is a library heavily inspired by chalk, the popular Node.js terminal color library, and using go ports of supports-color and ansi-styles

Dec 28, 2022
Golang ultimate ANSI-colors that supports Printf/Sprintf methods
Golang ultimate ANSI-colors that supports Printf/Sprintf methods

Aurora Ultimate ANSI colors for Golang. The package supports Printf/Sprintf etc. TOC Installation Usage Simple Printf aurora.Sprintf Enable/Disable co

Dec 29, 2022
go-isatty - isatty for golang.

go-isatty isatty for golang Usage package main import ( "fmt" "github.com/mattn/go-isatty" "os" ) func main() { if isatty.IsTerminal(os.Stdout.F

Jan 7, 2023
A really basic thread-safe progress bar for Golang applications
A really basic thread-safe progress bar for Golang applications

progressbar A very simple thread-safe progress bar which should work on every OS without problems. I needed a progressbar for croc and everything I tr

Jan 2, 2023
A tiny library for super simple Golang tables

Tabby A tiny library for super simple Golang tables Get Tabby go get github.com/cheynewallace/tabby Import Tabby import "github.com/cheynewallace/tabb

Nov 23, 2022
Github-workflow-dashboard - WEB and CLI dashboard for github action workflows
Github-workflow-dashboard - WEB and CLI dashboard for github action workflows

CLI capable of retrieving github action workflows stats Example usage Dashboard

Aug 30, 2022
Golang terminal dashboard
Golang terminal dashboard

termui termui is a cross-platform and fully-customizable terminal dashboard and widget library built on top of termbox-go. It is inspired by blessed-c

Dec 27, 2022
Golang terminal dashboard
Golang terminal dashboard

termui termui is a cross-platform and fully-customizable terminal dashboard and widget library built on top of termbox-go. It is inspired by blessed-c

Dec 29, 2022
Terminal based dashboard.
Terminal based dashboard.

Termdash is a cross-platform customizable terminal based dashboard. The feature set is inspired by the gizak/termui project, which in turn was inspire

Dec 28, 2022
:bento: Highly Configurable Terminal Dashboard for Developers and Creators
:bento: Highly Configurable Terminal Dashboard for Developers and Creators

DevDash is a highly configurable terminal dashboard for developers and creators who want to choose and display the most up-to-date metrics they need,

Jan 3, 2023
The personal information dashboard for your terminal
The personal information dashboard for your terminal

WTF (aka 'wtfutil') is the personal information dashboard for your terminal, providing at-a-glance access to your very important but infrequently-need

Dec 31, 2022