Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GoogleCloudPlatform/terminus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Terminus

A Go framework for building terminal-style user interfaces that run in web browsers. Terminus brings the simplicity and power of terminal UIs to the web, using a Model-View-Update (MVU) architecture similar to Elm.

NOTE This project is a demonstration of vibe coding intended to provide a trustworthy and verifiable example that developers and researchers can use. It is not intended for use in a production environment.

This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.

โœจ Features

  • ๐Ÿ–ฅ๏ธ Terminal-Style UI in the Browser: Build text-based interfaces that run in any modern web browser
  • ๐ŸŽฏ MVU Architecture: Simple, predictable state management with Model-View-Update pattern
  • ๐Ÿ“ฆ Rich Widget Library: Pre-built components for common UI needs
  • ๐Ÿš€ Server-Side Rendering: Keep your application logic in Go, minimize client-side JavaScript
  • โšก Real-Time Updates: WebSocket-based communication for instant UI updates
  • ๐ŸŽจ Full Styling Support: Colors, bold, italic, underline, and more using ANSI-style formatting
  • ๐Ÿ“ฑ Responsive Design: Works on desktop and mobile browsers
  • ๐Ÿ”ง Easy to Extend: Simple component interface for building custom widgets

Widget Library

TextInput

Full-featured text input with:

  • Cursor movement and text editing
  • Validation support
  • Placeholder text
  • Max length constraints
  • Custom styling for all states

List

Scrollable lists with:

  • Keyboard navigation
  • Real-time filtering
  • Custom item rendering
  • Selection callbacks
  • Wrap-around navigation

Table

Data tables with:

  • Sortable columns
  • Cell/row selection
  • Custom alignment
  • Row numbers
  • Header customization

Spinner

Loading indicators with:

  • Multiple animation styles
  • Custom characters
  • Configurable speed
  • Text positioning

๐Ÿš€ Quick Start

Installation

go get github.com/GoogleCloudPlatform/terminus

Hello World Example

package main

import (
    "fmt"
    "log"

    "github.com/GoogleCloudPlatform/terminus/pkg/terminus"
    "github.com/GoogleCloudPlatform/terminus/terminus/style"
)

type HelloWorld struct {
    count int
}

func (h *HelloWorld) Init() terminus.Cmd {
    return nil
}

func (h *HelloWorld) Update(msg terminus.Msg) (terminus.Component, terminus.Cmd) {
    switch msg := msg.(type) {
    case terminus.KeyMsg:
        switch msg.Type {
        case terminus.KeyUp:
            h.count++
        case terminus.KeyDown:
            h.count--
        case terminus.KeyEscape:
            return h, terminus.Quit
        }
    }
    return h, nil
}

func (h *HelloWorld) View() string {
    title := style.New().Bold(true).Foreground(style.Cyan).Render("Terminus Counter")
    counter := style.New().Bold(true).Render(fmt.Sprintf("Count: %d", h.count))
    help := style.New().Faint(true).Render("โ†‘/โ†“ to change โ€ข ESC to quit")

    return fmt.Sprintf("%s\n\n%s\n\n%s", title, counter, help)
}

func main() {
    program := terminus.NewProgram(
        func() terminus.Component { return &HelloWorld{} },
        terminus.WithAddress(":8080"),
    )

    fmt.Println("Starting on http://localhost:8080")
    if err := program.Start(); err != nil {
        log.Fatal(err)
    }
    program.Wait()
}

๐Ÿ“š Documentation

๐ŸŽฎ Examples

Explore our example applications:

Example Description Run Command
Hello World Simple starter app go run ./examples/hello/
Todo List Task management with persistence go run ./examples/todo/
Chat Real-time messaging go run ./examples/chat/
Dashboard Complex layouts go run ./examples/dashboard/
Widgets All widgets showcase go run ./examples/widgets/
Text Input Forms with validation go run ./examples/textinput/
Commands Advanced command usage go run ./examples/commands/
Layout Layout system demo go run ./examples/layout/
Gemini Chat AI chat with Google Gemini go run ./examples/gemini_chat/

All examples run on http://localhost:8890 by default.

๐Ÿ—๏ธ Architecture

Terminus uses a unique server-side architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         WebSocket        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Browser   โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚  Go Server  โ”‚
โ”‚             โ”‚       JSON Messages      โ”‚             โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚                          โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚  Thin   โ”‚ โ”‚                          โ”‚ โ”‚   MVU   โ”‚ โ”‚
โ”‚ โ”‚ Client  โ”‚ โ”‚                          โ”‚ โ”‚ Engine  โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚                          โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key benefits:

  • Zero client-side state - All logic stays in Go
  • Automatic UI updates - Just update your model
  • Secure by default - No client-side code execution
  • Easy testing - Pure functions throughout

๐Ÿ› ๏ธ Development Status

โœ… Completed

  • Core MVU engine with component system
  • WebSocket communication layer
  • Session management
  • Full ANSI styling system (16, 256, and RGB colors)
  • Efficient line-based diff algorithm
  • Complete widget library (TextInput, List, Table, Spinner)
  • Layout system with box drawing
  • HTTP command helpers
  • Comprehensive documentation
  • Enhanced JavaScript client with full color support

๐Ÿšง In Progress

  • Performance optimizations
  • Mouse support
  • Browser compatibility testing
  • Security hardening

๐Ÿ“‹ Planned

  • Additional widgets (Progress, Select, Tree)
  • Hot reload for development
  • DevTools browser extension
  • Plugin system

๐Ÿค Contributing

We welcome contributions! Areas where you can help:

  • ๐Ÿ“ Documentation improvements
  • ๐Ÿ› Bug reports and fixes
  • โœจ New widget implementations
  • ๐ŸŽจ Example applications
  • ๐ŸŒ Internationalization
  • โšก Performance optimizations

Please see our Contributing Guide (coming soon).

๐Ÿ“„ License

This project is licensed under the Apache 2.0 License.

๐Ÿ™ Acknowledgments

Terminus is inspired by:

  • Bubble Tea - Terminal UI framework for Go
  • Elm - The MVU architecture
  • Terminal emulators and their rich history

Happy coding! ๐Ÿš€

About

terminus is a Go framework for building terminal-style user interfaces that run in web browsers.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •