百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

turbo-vision-4-rust

> 编程语言
开源

Turbo Vision - Rust TUI 图书馆文档网站 &middot; 开始使用 &middot; 用户指南 &middot; 教程 &middot; 与 C++ 的比较 &middot…

99 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

Turbo Vision - Rust TUI 图书馆文档网站 &middot; 开始使用 &middot; 用户指南 &middot; 教程 &middot; 与 C++ 的比较 &middot…

Turbo Vision - Rust TUI Library

Documentation site · Getting started · User guide · Tutorials · vs. C++ · What's new · Upgrading to 3.0

A Rust implementation of the classic Borland Turbo Vision text user interface framework.

Full documentation, user guide, tutorials and a side-by-side comparison with the original C++ application model live at tv.enzolombardi.net.

Version 3.0.0 - PRODUCTION READY ✅

Based on kloczek Borland Turbo Vision C++ port here

Other C++ implementations:

  • Magiblot Turbo Vision for C++
  • Borland Original Turbo Vision 2.0.3 code

This port achieves 100% API parity with kloczek port of Borland Turbo Vision C++. All features from the original framework have been implemented. While the codebase is complete and production-ready, it may contain bugs. Please report any issues you encounter!

Screenshots

Showcase: Multiple Windows

The showcase demo with Calculator, Calendar, ASCII Table, and Puzzle windows demonstrating overlapping window management, z-ordering, and shadows.

Code Editor

A full-featured text editor (pascal_ide) editing its own source code, with menu bar, status line, and scrollable editing area.

Help Window

Context-sensitive help system (F1) with scrollable content, rendered over the editor window.

File System Tree

A tree view widget displaying a hierarchical file system with expandable/collapsible directories, keyboard navigation, and selection highlighting.

File Chooser Dialog

The built-in file dialog with directory navigation, file list, and keyboard/mouse support.

Features

  • Complete UI Component Set: Windows, dialogs, buttons, input fields, menus, status bars, scrollbars
  • Z-Order Management: Click any non-modal window to bring it to the front
  • Modal Dialog Support: Modal dialogs block interaction with background windows
  • Borland-Accurate Styling: Menu borders and shadows match original Borland Turbo Vision
  • Scrollable Views: Built-in scrollbar support with keyboard navigation
  • Text Viewer: Ready-to-use scrollable text viewer with line numbers
  • Event-Driven Architecture:
    • Three-phase event processing (PreProcess → Focused → PostProcess)
    • Event re-queuing for deferred processing
    • Owner-aware broadcast system to prevent echo back to sender
  • Mouse Support: Full mouse support for buttons, menus, status bar, dialog close buttons, scroll wheel, and double-click detection
  • Window Dragging and Resizing: Drag windows by title bar, resize by bottom-right corner
  • Owner-Relative Layout: Children keep coordinates relative to their owner, as in Borland's TView::origin; views draw at (0,0) and the owners translate (see docs/OWNER-COORDINATES.md)
  • Color Support: 16-color palette with Borland-accurate attribute system and context-aware remapping
  • Text Styling: Bold, dim, italic, underline, reverse, and strikethrough attributes — composable via Attr::new(fg, bg).bold().italic(), emitted as real SGR codes on the terminal and in ANSI dumps (see cargo run --example text_styling)
  • Editor Selection: Stream selection (Shift+arrows / drag) plus rectangular block selection with columnar copy/cut and single-step undo, switched with the global block-edit mode (Application::set_block_edit_mode, CM_TOGGLE_BLOCK_MODE) rather than a modifier key; CM_SELECT_ALL command and Ctrl+A select all content of the focused window
  • Cross-Platform: Built on crossterm for wide terminal compatibility
  • SSH Support: Optional SSH backend to serve TUI applications over SSH connections
  • Modal Dialogs: Built-in support for modal dialog execution
  • Focus Management: Tab navigation and keyboard shortcuts
  • Screen Capture: F12 saves an ASCII (ANSI) dump of the whole screen; Ctrl+F12 saves a PNG screenshot. Programmatic dumps of screen/views/regions via dump_screen/dump_region/dump_to_file

Quick Start

…

Tip: Capture the screen at any time —

  • F12 saves an ASCII (ANSI-colored) dump of the whole screen to screen-YYYYMMDD-HHMMSS.ans (view it with cat or less -R).
  • Ctrl+F12 saves a PNG screenshot of the whole screen to screenshot-YYYYMMDD-HHMMSS.png.

For programmatic use, see Terminal::dump_screen(path), Terminal::dump_region(...), and Terminal::save_screenshot_png(path).

Palette System

The color palette system accurately replicates Borland Turbo Vision's behavior:

  • Context-Aware Remapping: Views automatically remap colors based on their container (Dialog, Window, or Desktop)
  • Owner Type Support: Each view tracks its owner type for correct palette inheritance
  • Borland-Accurate Colors: All UI elements (menus, buttons, labels, dialogs) match original Borland colors
  • Runtime Customization: Change the entire application palette at runtime with app.set_palette() for custom themes

The palette system uses a three-level mapping chain:

  1. View palette (e.g., Button, Label) → indices 1-31
  2. Container palette (Dialog/Window) → remaps to indices 32-63
  3. Application palette → final RGB colors

Custom Palettes and Theming

You can customize the entire application palette at runtime to create custom themes:

rust
// Create a custom palette (63 bytes, each encoding foreground  Result> {
    let config = SshServerConfig::default();
    let server = SshServer::new(config)?;

    server.run("0.0.0.0:2222", |backend| {
        // Create Terminal with SSH backend
        let terminal = Terminal::with_backend(backend).unwrap();
        run_your_tui_app(terminal);
    }).await?;

    Ok(())
}

Running the Example

bash
# Start the SSH server
cargo run --example ssh_server --features ssh

# Connect from another terminal
ssh -p 2222 user@localhost
# Password: any (accepts any password in the example)

Architecture

The SSH support uses a Backend trait abstraction:

  • Backend trait: Abstracts terminal I/O operations
  • CrosstermBackend: Default implementation for local terminals
  • SshBackend: Implementation for SSH channel I/O
  • InputParser: Converts raw terminal bytes to turbo-vision events

This allows the same TUI application to run locally or over SSH with no code changes.

Architecture

This implementation closely follows Borland Turbo Vision's architecture, adapted for Rust:

  • Event Loop: Application::run_with takes an AppHandler for the program's own commands (Borland's TApplication::handleEvent and idle overrides); Application::execute_modal is the one modal loop behind Dialog::execute
  • Modal Dialogs: Use Borland's endModal() pattern to exit event loops; CloseOn says which commands close a dialog
  • View Hierarchy: Borland's TView > TGroup > TWindow > TDialog is expressed as layered traits over shared cores: every view owns a ViewCore, GroupLike and WindowLike carry TGroup's and TWindow's behaviour as group_* / window_* default methods, and a window-shaped type gets its View impl from impl_view_for_window! with overrides written inline. Overrides are late-bound: Dialog::get_palette is what window_draw paints with. See docs/MISSING-INHERITANCE.md for the analysis behind it.
  • Drawing: Event-driven redraws with Borland's drawUnderRect pattern for efficient updates
  • Event System:
    • Three-phase processing (PreProcess → Focused → PostProcess) matching Borland's TGroup::handleEvent()
    • Event re-queuing via Terminal::put_event() matching Borland's TProgram::putEvent()
    • Owner-aware broadcasts via Group::broadcast() matching Borland's message(owner, ...) pattern

Class Diagram

A non-exhaustive map of the main types. Traits are marked <>; dashed hollow arrows are trait implementations, filled diamonds are ownership by value. The full page with notes lives in docs/CLASS-DIAGRAM.md.

…

Project Statistics

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Rust                  125        37315        28029         3557         5729
 |- Markdown           102         4695          332         3604          759
 (Total)                          42010        28361         7161         6488
===============================================================================

Generated with tokei - includes inline documentation

226 unit tests - all passing ✅

Star History

License

MIT License - see LICENSE file for details.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言