Skip to main content

Crate tvision_rs

Crate tvision_rs 

Source
Expand description

§tvision-rs — a text-user-interface framework for Rust

tvision-rs is an idiomatic Rust port of magiblot/tvision, a modern revival of Turbo Vision. It gives you the classic Turbo Vision experience — overlapping windows, modal dialogs, menus, a status line, validated input fields, scrollers and list boxes — built on a retained view tree and a single event loop, rendered to the terminal through a pluggable Backend.

§House style: the tv:: namespace

Add the crate to Cargo.toml aliased as tv, and reach everything through the tv:: path — the path is the namespace, so types drop the T prefix the original used in their names:

# Cargo.toml
tv = { package = "tvision-rs", version = "0.1" }
let _r = tv::Rect::new(0, 0, 80, 25);

Public types are therefore re-exported at the crate root below, even though they live in topical modules internally.

§Documentation

  • Guide (narrative, with live terminal screenshots): the developer guide walks through getting started, building apps, the internals, and a widget gallery.
  • Markdown sources & design notes: the docs/ folder in the repository holds the guide’s Markdown sources, the C++→Rust porting reference, and the cross-cutting design notes — raw .md, which is convenient to read directly (and friendlier than rendered HTML for tools and LLMs ingesting the docs).

§Tour of the modules

  • view — the View trait and ViewState that every widget is built on, plus geometry (Point, Rect) and the Group container.
  • app — Program, the application root that owns the event loop, and Application, which adds window tiling/cascading and shell suspend.
  • window, dialog, desktop — top-level frames: resizable windows, modal dialogs, and the backdrop they sit on.
  • widgets — buttons, input lines, check boxes, list boxes, scrollers, editors, the outline viewer, and more.
  • menu, status — the menu bar / pull-down menus and the status line.
  • event, command — the Event enum and key/mouse types, and the command identifiers that drive them.
  • color, theme — colors and styles, and the Theme that maps a widget Role to glyphs and attributes.
  • screen, backend — the cell buffer and diffing renderer, and the Backend trait with its crossterm and headless implementations.
  • validate, text, timer, capture, data, help — input validators, text measurement, the timer queue, the event-capture stack, the typed value protocol, and help contexts.

§Turbo Vision heritage

tvision-rs ports Borland’s Turbo Vision as modernized by magiblot/tvision (a C++ codebase). The pervasive translation choices — inheritance becomes the View trait plus ViewState composition, raw pointers become ViewId handles, flag words become structs of bools, and the palette becomes a Theme keyed by Role — are summarized in the project’s guide.

Re-exports§

pub use app::Application;
pub use app::ModalFrame;
pub use app::Program;
pub use backend::Backend;
pub use backend::CrosstermBackend;
pub use backend::HeadlessBackend;
pub use backend::HeadlessHandle;
pub use backend::Renderer;
pub use capture::CaptureFlow;
pub use capture::CaptureHandler;
pub use capture::CaptureStack;
pub use capture::TrackMask;
pub use color::Color;
pub use color::Modifiers;
pub use color::Style;
pub use command::Command;
pub use command::CommandSet;
pub use data::FieldValue;
pub use desktop::Background;
pub use desktop::Desktop;
pub use dialog::BUTTON_GAP;
pub use dialog::BUTTON_ROW_FROM_BOTTOM;
pub use dialog::ButtonLayout;
pub use dialog::ButtonRowAlign;
pub use dialog::CD_HELP_BUTTON;
pub use dialog::CD_NO_LOAD_DIR;
pub use dialog::CD_NORMAL;
pub use dialog::ChDirDialog;
pub use dialog::ColorPicker;
pub use dialog::Dialog;
pub use dialog::DirCollection;
pub use dialog::DirEntry;
pub use dialog::DirListBox;
pub use dialog::FA_DIREC;
pub use dialog::FD_CLEAR_BUTTON;
pub use dialog::FD_HELP_BUTTON;
pub use dialog::FD_NO_LOAD_DIR;
pub use dialog::FD_OK_BUTTON;
pub use dialog::FD_OPEN_BUTTON;
pub use dialog::FD_REPLACE_BUTTON;
pub use dialog::FileCollection;
pub use dialog::FileDialog;
pub use dialog::FileInfoPane;
pub use dialog::FileInputLine;
pub use dialog::FileList;
pub use dialog::MARGIN_LEFT;
pub use dialog::MARGIN_RIGHT;
pub use dialog::MARGIN_TOP;
pub use dialog::MessageBoxButtons;
pub use dialog::MessageBoxKind;
pub use dialog::STD_BUTTON;
pub use dialog::SearchRec;
pub use dialog::Tab;
pub use dialog::search_rec_compare;
pub use event::Event;
pub use event::EventMask;
pub use event::Key;
pub use event::KeyEvent;
pub use event::KeyModifiers;
pub use event::MouseButtons;
pub use event::MouseEvent;
pub use event::MouseEventFlags;
pub use event::MouseWheel;
pub use event::ctrl_to_arrow;
pub use event::hot_key;
pub use event::is_alt_hotkey;
pub use event::is_plain_hotkey;
pub use frame::Frame;
pub use help::HelpCtx;
pub use junction::Edge;
pub use junction::JunctionMark;
pub use junction::Weight;
pub use keymap::KeyStroke;
pub use keymap::Keymap;
pub use keymap::Resolve;
pub use menu::Menu;
pub use menu::MenuBar;
pub use menu::MenuBox;
pub use menu::MenuBuilder;
pub use menu::MenuItem;
pub use menu::MenuView;
pub use menu::MenuViewState;
pub use menu::alt;
pub use menu::popup_menu;
pub use screen::Buffer;
pub use screen::Cell;
pub use screen::DrawBuffer;
pub use status::HelpCtxRange;
pub use status::StatusColors;
pub use status::StatusDef;
pub use status::StatusItem;
pub use status::StatusLine;
pub use theme::Role;
pub use theme::SurfaceRoles;
pub use theme::Theme;
pub use timer::Clock;
pub use timer::ManualClock;
pub use timer::SystemClock;
pub use timer::TimerId;
pub use timer::TimerQueue;
pub use validate::FilterValidator;
pub use validate::LookupValidator;
pub use validate::PXPictureValidator;
pub use validate::RangeValidator;
pub use validate::RegexError;
pub use validate::RegexValidator;
pub use validate::StringLookupValidator;
pub use validate::Validator;
pub use view::Context;
pub use view::Deferred;
pub use view::DragMode;
pub use view::DrawCtx;
pub use view::Group;
pub use view::GrowMode;
pub use view::Options;
pub use view::Phase;
pub use view::Point;
pub use view::Rect;
pub use view::SelectMode;
pub use view::State;
pub use view::StateFlag;
pub use view::View;
pub use view::ViewId;
pub use view::ViewState;
pub use widgets::Indicator;
pub use widgets::PageStack;
pub use widgets::TabBar;
pub use widgets::Button;
pub use widgets::ButtonFlags;
pub use widgets::CheckBoxes;
pub use widgets::Cluster;
pub use widgets::ClusterKind;
pub use widgets::MultiCheckBoxes;
pub use widgets::RadioButtons;
pub use widgets::ColumnSpec;
pub use widgets::ColumnState;
pub use widgets::RowKey;
pub use widgets::Table;
pub use widgets::TableModel;
pub use widgets::ValidatorFactory;
pub use widgets::VecModel;
pub use widgets::Constraints;
pub use widgets::DividerStyle;
pub use widgets::Orientation;
pub use widgets::Splitter;
pub use widgets::EditWindow;
pub use widgets::Editor;
pub use widgets::FindMode;
pub use widgets::InputLine;
pub use widgets::LimitMode;
pub use widgets::ListBox;
pub use widgets::ListRoles;
pub use widgets::ListViewer;
pub use widgets::ListViewerState;
pub use widgets::MaskedInput;
pub use widgets::RevealEye;
pub use widgets::RevealEyeConfig;
pub use widgets::SM_DOUBLE;
pub use widgets::SM_EXTEND;
pub use widgets::SM_TRIPLE;
pub use widgets::ScrollBar;
pub use widgets::Scroller;
pub use widgets::SortedListBox;
pub use widgets::ValuePosition;
pub use widgets::Encoding;
pub use widgets::FileEditor;
pub use widgets::LineEnding;
pub use widgets::Memo;
pub use widgets::HistoryViewer;
pub use widgets::HistoryWindow;
pub use widgets::THistory;
pub use widgets::clear_history;
pub use widgets::history_add;
pub use widgets::history_count;
pub use widgets::history_str;
pub use widgets::Label;
pub use widgets::ParamText;
pub use widgets::StaticText;
pub use widgets::Node;
pub use widgets::Outline;
pub use widgets::OutlineViewer;
pub use widgets::OutlineViewerState;
pub use widgets::ov_update;
pub use widgets::Terminal;
pub use widgets::TextDevice;
pub use window::Fullscreen;
pub use window::ScrollBarOptions;
pub use window::Window;
pub use window::WindowFlags;
pub use window::WindowPalette;

Modules§

app
The application layer: Program, the application root that owns the single event loop, the timer queue, and the capture stack that powers modal dialogs; and Application, a thin wrapper over it that adds window tiling/cascading and shell suspend.
backend
The platform seam: everything that touches the terminal lives behind a single trait, so the rest of the framework stays terminal-agnostic.
capture
The capture stack — the single mechanism behind modality, mouse tracking, window drag/resize, and press-and-hold.
color
Typed colour and style.
command
Commands and command sets.
data
Typed dialog-data transfer — the value currency moved between controls and the dialog that owns them, and the open seam for third-party components.
desktop
Desktop-layer views — the desktop surface and its backdrop.
dialog
The modal dialog window.
event
Events — the Event enum and the key/mouse records that fill it.
frame
The decorative border Frame a Window places around its interior: the box, the centered title, the optional window number, and the close / zoom / resize icons. It is a passive view — it never takes focus.
help
Help contexts.
junction
View-independent vocabulary for joining box-drawing linework: which frame edge a divider abuts, the weight (single/double) of each line, and the pure glyph-selector functions that map an (edge, bar-weight, stem-weight) tuple to the matching box character in Glyphs.
keymap
Data-driven, process-global keymap shared by the editor and input line.
menu
Menus: the data tree and the views that present it.
screen
Screen-cell storage, the render back-buffer, and the cell diff.
status
The status-line data types — StatusItem, StatusDef — plus a fluent builder. The StatusLine view (drawing, mouse dispatch, hotkey accelerators, command graying) lives in status_line.
text
Width-aware Unicode text: measuring, scrolling, and drawing strings by display column rather than byte or codepoint.
theme
Theming: a Role → Style map plus a Glyphs holder.
timer
Injected clock and timer queue.
validate
Input validators that gate what an InputLine accepts.
view
Views, geometry, and the downward-context substrate.
widgets
Widget implementations — the leaf views (buttons, input lines, lists, editors, scrollbars, and more).
window
The framed, selectable, movable Window.

Attribute Macros§

delegate
Embed-and-delegate: forward the un-written View methods to an inner view.