Golang terminal dashboard

Related tags

Command-line termui
Overview

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

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.

    enhancement 
    opened by slezica 11
  • 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.

    opened by jonatas 10
  • 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.

    opened by byrnedo 10
  • 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!

    opened by namreg 9
  • 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.

    bug 
    opened by practice 9
  • 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?

    enhancement 
    opened by Matt3o12 8
  • 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)
    
    opened by cospotato 7
  • 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.

    opened by missingdays 7
  • 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?

    opened by divan 7
  • 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

    enhancement 
    opened by ulrichSchreiner 7
  • 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??

    help wanted 
    opened by andyl 7
  • 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.

    opened by andrewarrow 0
  • 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))
    
    opened by gospacedev 0
  • 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.

    opened by cogburnd02 0
  • 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

    opened by xhsky 0
Owner
Zack Guo
May the --force be with you.
Zack Guo
Standalone analytics provider and realtime dashboard designed for self-hosting.

Stats Stats is a high-performance, standalone analytics provider designed for self-hosting, enabling the collection and viewing of event data from web

Udara Jay 120 Mar 23, 2024
Yet another sort crate, porting Golang sort package to Rust.

IndexSort IndexSort Yet another sort crate (in place), porting Golang's standard sort package to Rust. Installation [dependencies] indexsort = "0.1.0"

Al Liu 4 Sep 28, 2022
A terminal ASCII media player. View images, gifs, videos, webcam, YouTube, etc.. directly in the terminal as ASCII art.

Terminal Media Player View images, videos (files or YouTube links), webcam, etc directly in the terminal as ASCII. All images you see below are just m

Max Curzi 36 May 8, 2023
ask.sh: AI terminal assistant that can read and write your terminal directly!

ask.sh: AI terminal assistant that read from & write to your terminal ask.sh is an AI terminal assistant based on OpenAI APIs such as GPT-3.5/4! What'

hmirin 5 Jun 20, 2023
A simple and efficient terminal UI implementation with ratatui.rs for getting quick insights from csv files right on the terminal

CSV-GREP csv-grep is an intuitive TUI application writting with ratatui.rs for reading, viewing and quickly analysing csv files right on the terminal.

Anthony Ezeabasili 16 Mar 10, 2024
:large_orange_diamond: Build beautiful terminal tables with automatic content wrapping

Comfy-table Comfy-table tries to provide utility for building beautiful tables, while being easy to use. Features: Dynamic arrangement of content to a

Arne Beer 525 Jan 8, 2023
🛎 60+ Elegant terminal spinners for Rust

Spinners - ?? 60+ Elegant terminal spinners for Rust ❤️ Shameless plug Charts, simple as a URL. No more server-side rendering pain, 1 url = 1 chart Lo

Francois-Guillaume Ribreau 435 Dec 26, 2022
Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

HashMismatch 47 Nov 25, 2022
Rust library for ANSI terminal colours and styles (bold, underline)

rust-ansi-term This is a library for controlling colours and formatting, such as red bold text or blue underlined text, on ANSI terminals. View the Ru

Benjamin Sago 407 Jan 2, 2023
Cross-platform Rust library for coloring and formatting terminal output

Coloring terminal output Documentation term-painter is a cross-platform (i.e. also non-ANSI terminals) Rust library for coloring and formatting termin

Lukas Kalbertodt 75 Jul 28, 2022
create and test the style and formatting of text in your terminal applications

description: create and test the style and formatting of text in your terminal applications docs: https://docs.rs/termstyle termstyle is a library tha

Rett Berg 18 Jul 3, 2021
A dead simple ANSI terminal color painting library for Rust.

yansi A dead simple ANSI terminal color painting library for Rust. use yansi::Paint; print!("{} light, {} light!", Paint::green("Green"), Paint::red(

Sergio Benitez 169 Dec 25, 2022
(Rust) Coloring terminal so simple you already know how to do it !

Colored Coloring terminal so simple, you already know how to do it! "this is blue".blue(); "this is red".red(); "this is red on blue".red(

Thomas Wickham 1.2k Jan 4, 2023
Cross platform terminal library rust

Cross-platform Terminal Manipulation Library Crossterm is a pure-rust, terminal manipulation library that makes it possible to write cross-platform te

crossterm-rs 2.1k Jan 2, 2023
Build terminal user interfaces and dashboards using Rust

tui-rs tui-rs is a Rust library to build rich terminal user interfaces and dashboards. It is heavily inspired by the Javascript library blessed-contri

Florian Dehau 9.3k Jan 4, 2023
Currency exchange rates in your terminal

Usage example Rates is a scriptable CLI tool that brings currency exchange rates right into your terminal and supports 30+ fiat and 10K+ crypto currencies.

Lunush 89 Nov 9, 2022
My terminal emulator

Miro A GPU-accelerated terminal emulator written in Rust. miro -t pika miro -t kirby miro -t mario miro -t sonic Building from source

Ossama Hjaji 283 Dec 3, 2022
Alacritty - A fast, cross-platform, OpenGL terminal emulator

Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows.

Alacritty 43.8k Dec 31, 2022
Terminal-based typing test.

ttyper Ttyper is a terminal-based typing test built with Rust and tui-rs. installation With Cargo: cargo install ttyper usage For usage instructions,

Max Niederman 527 Dec 17, 2022