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

Related tags
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

Jan 1, 2023
Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.
Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.

Stonks is a terminal based stock visualizer and tracker. Installation Requirements: golang >= 1.13 Manual Clone the repo Run make && make install Pack

Dec 16, 2022
💻 PTerm | Pretty Terminal Printer A golang module to print pretty text
💻 PTerm | Pretty Terminal Printer A golang module to print pretty text

✨ PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more ?? It's completely configurable and 100% cross-platform compatible.

Jan 1, 2023
A collection of terminal-based widgets for richer Golang CLI apps.
A collection of terminal-based widgets for richer Golang CLI apps.

Flinch A collection of terminal-based widgets for richer Golang CLI apps. Ships with a library to build your own widgets/TUIs too. Warning: This modul

Jan 7, 2023
Go (golang) package with 70+ configurable terminal spinner/progress indicators.
Go (golang) package with 70+ configurable terminal spinner/progress indicators.

Spinner spinner is a simple package to add a spinner / progress indicator to any terminal application. Examples can be found below as well as full exa

Dec 26, 2022
Terminal UI library with rich, interactive widgets — written in Golang
Terminal UI library with rich, interactive widgets — written in Golang

Rich Interactive Widgets for Terminal UIs This Go package provides commonly needed components for terminal based user interfaces. Among these componen

Jan 7, 2023
🔹 Golang module to move the terminal cursor in any direction on every operating system.
🔹 Golang module to move the terminal cursor in any direction on every operating system.

AtomicGo | cursor Get The Module | Documentation | Contributing | Code of Conduct Description Package cursor contains cross-platform methods to move t

Dec 22, 2022
Source code of a YouTube tutorial about writing terminal applications with Golang

Bubble Tea Demo 00 Source code of a YouTube tutorial about writing terminal applications with Golang by using Bubble Tea. Contains a simple counter ap

Nov 10, 2022
Golang package with functionality to add colors to your logs to the terminal.
Golang package with functionality to add colors to your logs to the terminal.

colrz It's a set of funcs and constants to provide basic colors to your terminal app. How to use Get it go get github.com/unnamedxaer/colrz Use it pac

Sep 15, 2022
Gocheat - Golang terminal client for cht.sh that uses charm.sh's bubbletea project

Go Cheat.sh install gotext go get -u golang.org/x/text/cmd/gotext go generate

Jun 3, 2022
Terminal client for SimpleNote

GoNote - Terminal client for SimpleNote GoNote is a simple utility for managing notes in your SimpleNote account. It allows basic operations like crea

Nov 22, 2022
gomerge is a tool to quickly bulk merge several pull requests from your terminal.
gomerge is a tool to quickly bulk merge several pull requests from your terminal.

Gomerge is a tool to quickly enable you to bulk merge Github pull requests from your terminal. The intention of this tool is to simplfy, and eventually automate the merging of github pull requests. This tool should be able to run on most systems.

Dec 28, 2022
`tmax` is a powerful tool to help you get terminal cmd directly.
`tmax`  is a powerful tool to help you get terminal cmd directly.

The positioning of tmax is a command line tool with a little artificial intelligence. If you frequently deal with the terminal daily, tmax will greatly improve your work efficiency.

Oct 15, 2022
YouTube client on your terminal

MeowTube YouTube client on your terminal Table of Contents About Getting Started Usage Contributing About MeowTube is a CLI (Command Line Interface) t

Jul 29, 2022
🎄 A Christmas tree right from your terminal!
🎄 A Christmas tree right from your terminal!

ctree ?? A Christmas tree right from your terminal! ?? Demo ⌛ No Refresh Don't want the tree to refresh every 2 seconds? Easy! Just add the --no-refre

Dec 20, 2022
progress_bar creates a single customizable progress bar for Linux terminal.
progress_bar creates a single customizable progress bar for Linux terminal.

progress_bar Go Progress Bar Features progress_bar creates a single customizable progress bar for Linux terminal. Installation go get -u github.com/er

Aug 12, 2022
A terminal based typing test.
A terminal based typing test.

What A terminal based typing test. Installation Linux sudo curl -L https://github.com/lemnos/tt/releases/download/v0.4.0/tt-linux -o /usr/local/bin/tt

Dec 28, 2022
Raspberry Pi terminal based activity monitor
Raspberry Pi terminal based activity monitor

pitop Raspberry Pi terminal based activity monitor Yes I know there are plenty of solutions already available, but I wanted to build my own terminal b

Dec 11, 2022
❓🖼 Find the anime scene by image using your terminal
❓🖼 Find the anime scene by image using your terminal

What Anime CLI ❓ ?? > This application is basically a ?? wrapper around trace.moe PREVIEW Usage ?? Get Anime By Image File ?? what-anime file anime.jp

Jan 2, 2023