Skip to content

mizchi/tui-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TUI POC - Terminal UI Proof of Concept

A terminal user interface proof of concept with advanced features including IME support, emoji rendering, Sixel graphics, and a terminal-based web browser.

Overview

This project demonstrates advanced terminal UI capabilities in Rust, including:

  • Japanese IME (Input Method Editor) support
  • Proper emoji and Unicode rendering
  • Sixel protocol for pixel-perfect graphics
  • Terminal-based web browser with Chrome DevTools Protocol support

Project Structure

This is a Cargo workspace containing three crates:

tui - Main TUI Application

The core terminal UI application with:

  • Japanese IME support with proper focus handling
  • Accurate emoji width calculation for monospace fonts
  • Flex layout system using yoga-rs
  • Sixel rendering capabilities
  • vim-like rich display features

tui-renderer - Sixel-based Renderer

A rendering engine for terminal graphics:

  • Pixel-level drawing with Sixel protocol
  • Component-based architecture
  • Layout engine with flexbox support
  • Text rendering with font support
  • Image rendering capabilities

browser - Terminal Web Browser

A lightweight terminal-based web browser featuring:

  • HTML5 parsing with html5ever
  • DOM tree implementation
  • JavaScript engine integration (QuickJS)
  • Layout engine using Taffy (Flexbox/Grid)
  • Chrome DevTools Protocol (CDP) server
  • Puppeteer/Playwright compatibility

Quick Start

# Clone the repository
git clone https://github.com/mizchi/tui-poc.git
cd tui-poc

# Run the main TUI application
cargo run

# Run the terminal browser
cargo run -p browser -- navigate https://example.com

# Start CDP server for browser automation
cargo run -p browser -- serve --port 9222

# Run examples
cargo run --example sixel_demo
cargo run --example flex_image_demo

Browser Usage

Navigate to a URL

cargo run -p browser -- navigate https://example.com
# Or with a local file
cargo run -p browser -- navigate file:///path/to/file.html

Connect with Puppeteer

const browser = await puppeteer.connect({
  browserWSEndpoint: "ws://127.0.0.1:9222"
});

Requirements

  • Rust 1.70+
  • For Sixel features: Sixel-capable terminal (WezTerm, mlterm, foot, xterm with Sixel support)
  • For Japanese input: Japanese IME
  • For browser features: Internet connection for HTTP(S) URLs

Features Demonstrated

IME Integration

  • Proper handling of Japanese IME composition
  • Grapheme-based cursor movement
  • Focus management with screenshot tools

Unicode & Emoji Support

  • Correct width calculation for emoji in monospace fonts
  • Support for emoji variation selectors (VS16)
  • Zero-width joiner (ZWJ) sequence handling

Sixel Graphics

  • Direct pixel manipulation in terminal
  • Image rendering alongside text
  • Component-based rendering system

Web Technologies

  • HTML parsing and DOM manipulation
  • Basic JavaScript execution
  • Terminal-based rendering of web content
  • Chrome DevTools Protocol implementation

Documentation

Detailed documentation is available in the docs/ directory:

Architecture & Design

Research & Analysis

Implementation Guides

Known Issues

  • Emoji width detection may vary by terminal and font
  • Sixel support depends on terminal emulator
  • Browser CSS support is minimal
  • JavaScript DOM APIs are limited

Future Development

  • Complete CSS engine implementation
  • Full JavaScript DOM API support
  • WebSocket support
  • Storage APIs (localStorage, sessionStorage)
  • More CDP protocol coverage
  • Plugin system for extensibility

Contributing

This is a proof of concept project. Feel free to explore and experiment with the code.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages