Skip to content

ofabricio/imtui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imtui

Simple Immediate Mode Terminal UI

Example

package main

import "github.com/ofabricio/imtui"

func main() {

    tui := imtui.New()

    var clicks int
    for range tui.Loop() {

        if tui.Button(" Click! ") {
            clicks++
        }

        tui.Text(fmt.Sprintf(" Button clicked %d times ", clicks))
    }
}

Demo

This demo is from the example in example/demo.go.

Documentation

Text

for range tui.Loop() {

    tui.Text("Hello, World!")
}

Button

var clicks int
for range tui.Loop() {

    if tui.Button(" Click! ") {
        clicks++
    }

    tui.Text(fmt.Sprintf(" Button clicked %d times ", clicks))
}

Toggle Button

var toggle bool
for range tui.Loop() {

    if tui.Toggle(" Expand ", &toggle); toggle {
        tui.Text(" Hello! ")
    }
}

Checkbox

var one, two bool
for range tui.Loop() {

    tui.Check("One ", &one)
    tui.Check("Two ", &two)

    tui.Text(fmt.Sprintf(" One is %t; Two is %t ", one, two))
}

Radio button

var opt int = -1
for range tui.Loop() {

    tui.Radio("One ", 0, &opt)
    tui.Radio("Two ", 1, &opt)

    tui.Text(fmt.Sprintf(" Item selected: %v ", opt))
}

About

Simple Immediate Mode Terminal UI

Topics

Resources

Stars

Watchers

Forks

Releases

Contributors

Languages