Convert Figma logo to code with AI

gizak logotermui

Golang terminal dashboard

13,182
788
13,182
103

Top Related Projects

7,371

A terminal based graphical activity monitor inspired by gtop and vtop

52,000

simple terminal UI for git commands

Terminal based dashboard.

10,905

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

27,461

A powerful little TUI framework 🏗

10,830

Build terminal user interfaces and dashboards using Rust

Quick Overview

termui is a Go library for creating terminal-based user interfaces and dashboards. It provides a set of widgets and tools to build interactive and visually appealing console applications with ease. The library is inspired by blessed-contrib and leverages termbox-go for terminal rendering.

Pros

  • Rich set of pre-built widgets (charts, gauges, lists, etc.)
  • Easy to use API for creating and managing UI components
  • Support for real-time updates and animations
  • Cross-platform compatibility (works on various Unix-like systems and Windows)

Cons

  • Limited customization options for some widgets
  • Documentation could be more comprehensive
  • Potential performance issues with complex layouts or large datasets
  • Learning curve for users new to terminal-based UIs

Code Examples

Creating a basic bar chart:

package main

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

func main() {
    if err := ui.Init(); err != nil {
        panic(err)
    }
    defer ui.Close()

    bc := widgets.NewBarChart()
    bc.Data = []float64{3, 2, 5, 3, 9, 5}
    bc.Labels = []string{"S0", "S1", "S2", "S3", "S4", "S5"}
    bc.Title = "Bar Chart"
    bc.SetRect(5, 5, 100, 25)

    ui.Render(bc)
    <-ui.PollEvents()
}

Creating a paragraph widget with styled text:

p := widgets.NewParagraph()
p.Text = "Hello [World](fg:blue,mod:bold)!"
p.SetRect(0, 0, 25, 5)
ui.Render(p)

Handling user input:

for e := range ui.PollEvents() {
    if e.Type == ui.KeyboardEvent {
        if e.ID == "q" || e.ID == "<C-c>" {
            return
        }
    }
}

Getting Started

  1. Install the library:

    go get github.com/gizak/termui/v3
    
  2. Import the library in your Go code:

    import ui "github.com/gizak/termui/v3"
    
  3. Initialize termui at the start of your main function:

    if err := ui.Init(); err != nil {
        panic(err)
    }
    defer ui.Close()
    
  4. Create and render widgets:

    p := widgets.NewParagraph()
    p.Text = "Hello, termui!"
    p.SetRect(0, 0, 25, 5)
    ui.Render(p)
    
  5. Start the event loop to handle user input:

    for e := range ui.PollEvents() {
        if e.Type == ui.KeyboardEvent && e.ID == "q" {
            return
        }
    }
    

Competitor Comparisons

7,371

A terminal based graphical activity monitor inspired by gtop and vtop

Pros of gotop

  • Ready-to-use system monitoring tool with a polished UI
  • Includes specific features for system monitoring (CPU, memory, network, etc.)
  • Easier to set up and use for end-users who want a quick system monitoring solution

Cons of gotop

  • Less flexible for creating custom terminal UIs
  • More focused on system monitoring, limiting its use for other types of applications
  • Fewer customization options compared to the more general-purpose termui

Code Comparison

termui example:

ui := termui.New()
p := widgets.NewParagraph()
p.Text = "Hello World!"
ui.Render(p)

gotop example:

gotop.New()
gotop.Run()

Summary

termui is a more general-purpose library for creating terminal user interfaces, offering greater flexibility and customization options. It's ideal for developers who want to build custom TUI applications.

gotop, on the other hand, is a specialized tool for system monitoring with a pre-built interface. It's more suitable for users who want a ready-to-use system monitoring solution without needing to code their own UI.

The choice between the two depends on whether you need a flexible UI library or a specific system monitoring tool.

52,000

simple terminal UI for git commands

Pros of lazygit

  • Specifically designed for Git operations, offering a more focused and tailored user experience
  • Provides an interactive interface for Git commands, making complex operations more accessible
  • Regularly updated with new features and improvements

Cons of lazygit

  • Limited to Git functionality, whereas termui is a general-purpose UI library
  • Steeper learning curve for users not familiar with Git concepts
  • Less flexibility for creating custom terminal UIs outside of Git operations

Code Comparison

lazygit (Go):

func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
    message := gui.trimmedContent(v)
    if message == "" {
        return gui.createErrorPanel(gui.Tr.NoCommitMessageErr)
    }
    return gui.handleCommitSubmit(message)
}

termui (Go):

func NewGauge() *Gauge {
    return &Gauge{
        Block:       *NewBlock(),
        PercentColor: ui.ColorBlue,
        BarColor:     ui.ColorGreen,
        Label:        "{{percent}}%",
    }
}

The code snippets demonstrate the different focus areas of the two projects. lazygit deals with Git-specific operations, while termui provides general UI components for terminal applications.

Terminal based dashboard.

Pros of termdash

  • More actively maintained with recent updates
  • Supports a wider range of widgets and customization options
  • Better documentation and examples

Cons of termdash

  • Steeper learning curve due to more complex API
  • Larger codebase and dependencies

Code Comparison

termui:

p := widgets.NewParagraph()
p.Text = "Hello World!"
ui.Render(p)

termdash:

t, err := termbox.New()
c, err := container.New(t)
txt, err := text.New()
c.Update("myText", txt)
txt.Write("Hello World!")

Summary

Both termui and termdash are Go libraries for creating terminal user interfaces. termui offers simplicity and ease of use, while termdash provides more features and customization options. termui might be preferable for quick prototypes or simpler applications, whereas termdash is better suited for more complex, feature-rich terminal UIs. The choice between the two depends on the specific requirements of your project and your familiarity with terminal UI development in Go.

10,905

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

Pros of tview

  • More comprehensive and feature-rich, offering a wider range of UI elements and layouts
  • Better documentation and examples, making it easier for developers to get started
  • Active development and maintenance, with regular updates and bug fixes

Cons of tview

  • Steeper learning curve due to its more complex API and extensive features
  • Potentially higher resource usage for simpler applications

Code Comparison

tview:

app := tview.NewApplication()
box := tview.NewBox().SetBorder(true).SetTitle("Hello, world!")
if err := app.SetRoot(box, true).Run(); err != nil {
    panic(err)
27,461

A powerful little TUI framework 🏗

Pros of Bubbletea

  • More active development and community support
  • Flexible and composable architecture for building complex TUIs
  • Built-in support for keyboard input handling and event-driven programming

Cons of Bubbletea

  • Steeper learning curve due to its unique programming model
  • Less out-of-the-box UI components compared to Termui

Code Comparison

Termui example:

ui.NewPar("Hello World!")

Bubbletea example:

type model struct{}
func (m model) Init() tea.Cmd { return nil }
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil }
func (m model) View() string { return "Hello, World!" }

Summary

Termui offers a simpler approach with ready-to-use UI components, making it easier for quick prototypes. Bubbletea, on the other hand, provides a more flexible and powerful framework for building complex terminal user interfaces, but requires more initial setup and understanding of its programming model.

Both libraries have their strengths, and the choice between them depends on the specific requirements of your project and your familiarity with their respective approaches to terminal UI development.

10,830

Build terminal user interfaces and dashboards using Rust

Pros of tui-rs

  • Written in Rust, offering memory safety and performance benefits
  • More actively maintained with frequent updates and contributions
  • Supports custom widgets and layouts for greater flexibility

Cons of tui-rs

  • Steeper learning curve due to Rust's complexity
  • Smaller community and ecosystem compared to termui

Code Comparison

termui (Go):

ui := termui.New()
p := widgets.NewParagraph()
p.Text = "Hello World!"
ui.Render(p)

tui-rs (Rust):

let mut terminal = Terminal::new(backend)?;
terminal.draw(|f| {
    let chunk = Layout::default()
        .direction(Direction::Vertical)
        .constraints([Constraint::Percentage(100)].as_ref())
        .split(f.size())[0];
    let paragraph = Paragraph::new("Hello World!")
        .block(Block::default().borders(Borders::ALL));
    f.render_widget(paragraph, chunk);
})?;

Both libraries provide similar functionality for creating terminal user interfaces, but tui-rs offers more granular control over layout and rendering at the cost of increased verbosity. termui's API is more concise and easier to get started with, while tui-rs provides greater flexibility and performance for complex applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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.

Note

Please be aware that due to my fluctuating availability, the frequency of updates to this project may not always follow a consistent schedule. I would like to invite potential maintainers to contribute to this project. If you are interested in becoming a maintainer, please do not hesitate to reach out to me.

Versions

termui is currently compatible with Go 1.15 (as in go.mod) and above (tracking the Debian's oldstable). Please use the version-numbered branch as stable release. The new changes will be pushed to master branch first and then merge to version branch.

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