Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Differences from C++ Turbo Vision

tvision-rs is a faithful port of magiblot's C++ Turbo Vision: class structure, method names, control flow, and behaviour are reproduced as-is, except in the places where a line-by-line port is impossible or unwise in Rust. Each such place is a numbered difference. If a behaviour is not on this list, it was ported straight from the C++.

Each difference carries a tag: most are forced (Rust won't compile the direct port) or chosen (the direct port compiles, but a modern construct fits better); a few are tagged by scope (minor / moderate) where the change is small and self-contained.

This page is the at-a-glance list. Every entry links to the Part II chapter that covers it and, where one type carries the difference, to that type's API reference. Other pages cite an entry by its stable anchor (for example difference D2).

Porting contributors: see the project repository.

D1 · Names & namespacing

chosen. The T prefix is dropped and every type lives under the tv:: namespace (TButton → tv::Button); methods become snake_case. The cm*/hc* constant families become type-scoped associated constants on open newtypes (Command, HelpCtx) so apps can mint their own values. → Constant families

D2 · Inheritance → trait + composition

forced. The class tree becomes a View trait with default methods plus a ViewState struct held by composition; "subclass TWindow" becomes embed-and-delegate: hold a Window, forward the methods you don't change. → Inheritance

D3 · Pointers → handles + downward context

forced. Raw TView* pointers become process-global ViewId handles plus a downward-passed Context; up/sideways links resolve by tree-walk, never by reference. → Pointers & infoPtr → handles

D4 · Events → enum + match

chosen. TEvent's tagged union and bitmasks become an Event enum that is matched, not masked; message() splits into a targeted query and an Event::Broadcast. TKey/kb* become a closed Key enum plus KeyModifiers. → Events

D5 · Flag words → struct-of-bools

chosen. The ushort flag words (state, options, growMode, dragMode) become #[derive(Default)] structs of bools, with a verb-enum set_state over them (StateFlag, Options). → Flag words

D6 · Attribute bytes → typed Color/Style

chosen. Packed TColorAttr/TColorDesired bytes become a typed four-variant Color enum plus Style; the per-cell retain-0 overloads are dropped. → The draw model

D7 · Palettes & glyphs → Theme

chosen. Palette chains and scattered glyph literals become a Theme owning a state→Role style map and a Glyphs set; getColor/getPalette become ctx.theme.style(Role::…). → Palettes & glyphs → Theme

D8 · Whole-tree redraw + diff

chosen. Per-write occlusion and damage tracking become a whole-tree redraw into a back buffer plus a diff-bounded terminal flush; occlusion becomes the painter's algorithm, and shadows are cast during the draw. → The draw model

D9 · Modal loops → one loop + capture stack

forced. Nested blocking modal loops (execView, dragView) become one non-recursive event loop plus a LIFO capture stack; modality, drag, and press-tracking are handlers, not loops. execView from a Program method becomes Program::exec_view_with (result by value); execView from within a view becomes Context::request_exec_view (queues Deferred::OpenModal; reuses the existing pending_modal + RouteModalAnswer machinery; the modal's record is routed back via set_modal_data unless the close command is Command::CANCEL, then the close command via set_modal_answer). As in C++, keys, commands, pastes and the mouse wheel go to the modal view alone while it runs, and a command it leaves unhandled is dropped; status-line keys still pre-route. Remaining difference: broadcasts queued under a modal reach the whole tree, not only the modal view. → Modal execView

D10 · Data transfer → typed value protocol

forced. Flat-record memcpy data transfer (getData/setData/dataSize) becomes a typed value()/set_value() protocol over a FieldValue. → Dialogs & data

See The data-movement model for the whole-design overview.

D11 · Platform layer → Backend trait

chosen. The platform layer (THardwareInfo, ncurses/win32 strategies) becomes a small object-safe Backend trait, with a production CrosstermBackend and a test HeadlessBackend that unlocks snapshot testing. → Drawing & backends

D12 · Persistence → dropped

chosen. TStreamable persistence and resource files are dropped; reach for serde if persistence is ever wanted. → Dropped & changed

D13 · Text → Unicode grapheme model

minor. Per-char, CP437 text becomes a Unicode grapheme model (unicode-width + unicode-segmentation) that clusters combining marks into one cell; unprintables render as �. → Dropped & changed

D14 · DOS drives & paths → native Linux filesystem

moderate. The file dialog's DOS drives and \ paths become a native Linux / filesystem: no drive letters, the root is /, and subdirectories are listed via std::fs::read_dir. → Dropped & changed

D15 · DOS timestamps → std::fs mtime, UTC

minor. DOS findfirst local-time stamps become std::fs mtime computed in UTC, packed into the same DOS ftime word so the file-info-pane unpack ports verbatim. → Dropped & changed

D16 · Virtual sizeLimits floor → settable min_size

minor. A C++ window subclass raises its minimum size by overriding the virtual sizeLimits, which the drag, keyboard-resize and zoom paths call. With embed-and-delegate (D2) the inner window cannot see a wrapper's override, so the floor is a field on the window instead: Window::set_min_size (also on Dialog) raises it from the 16×6 default, and every clamp path reads it. The wrapper sets it once at construction, as FileDialog (49×19), ChDirDialog (48×18) and EditWindow (24×6) do. → Inheritance

Underlying mechanisms

The Deferred channel and the cross-view sibling broker are not numbered differences but the substrate that several of these (notably D3 and D9) rely on; see Part IV.