What "faithful" means
Almost everything a C++ Turbo Vision programmer knows still holds in tvision-rs. This part of the guide is written for that reader. It explains the ideas behind the few places where the Rust looks different from the C++, so that each familiar construct can be traced to what it became.
Faithful by default
tvision-rs is a faithful port of
magiblot/tvision. Class structure, method
names, control flow, algorithms, and observable behaviour are reproduced as-is.
The event loop dispatches the same way, modal dialogs nest the same way, the
draw model paints the same way, and the widgets behave as Turbo Vision
widgets do. handleEvent became handle_event on the
View trait, but it is called at the same
moments, receives the same events, and is expected to consume them the same way.
The rule the port follows: if a behaviour isn't called out as a deliberate departure, it was translated straight from the C++. The answer to "does it still work like Turbo Vision here?" is yes unless a chapter in this part says otherwise.
Why port faithfully
Turbo Vision's command bus, its modal execView, its desktop/window/dialog
layering, and its view-owns-its-children tree were refined over decades and fit
together. Re-deriving that design from scratch would gain nothing. Faithfulness
also means existing Turbo Vision knowledge, and the
magiblot documentation, transfers
directly, and the port's behaviour can be checked against the C++ source
instead of guessed at.
Where it departs, and why
The places where tvision-rs looks different from the C++ are a small,
deliberate set with one root cause. Turbo Vision's T prefixes, bit-packed flag
words, raw pointers, and hand-rolled machinery were workarounds for features the
language of 1991 lacked and Rust has built in. The approach is the same every
time:
Recognize each 1991 workaround, replace it with the language feature, and keep everything around it faithful.
TView becomes the View trait (a
namespace C++ approximated with a T prefix). state & sfFocused becomes a boolean
field. The TEvent.what union becomes an enum. A raw TView* becomes a
ViewId handle. Each time, the
Rust construct carries the meaning the workaround approximated, so the
surrounding code stays a direct translation.
The chapters that follow
Each of the next chapters covers one of these departures: what the C++ does, what tvision-rs does instead, and how the rest of the faithful port connects to it:
- Inheritance → trait + composition: the
TViewhierarchy becomes theViewtrait plusViewStatecomposition. - Pointers & infoPtr → handles:
TView*becomes aViewIdresolved through a downward-borrowedContext. - Events → enum + match: the
TEventunion becomes a sum type. - Flag words → struct-of-bools:
ofXxx/sfXxxbitmasks become named boolean fields. - Constant families → open newtypes:
cmXxx/hcXxxbecome namespaced consts likeCommand::OK. - Palettes & glyphs → Theme/Role: the palette chain becomes a
Themekeyed by semantic roles. - The draw model:
drawView/drawSubViewsbecomes whole-tree redraw plus a cell-buffer diff. - Modal execView → one loop + capture: nested modal loops collapse into a single event loop driven by a capture stack.
- The Deferred channel: effects a downward-borrowed view can't perform inline are routed back to the loop owner.
- Dropped & changed: the few pieces that were removed or replaced outright, and what stands in for them.
For the mapping in one table see Differences from C++ Turbo Vision. For the one-to-one name lookup, see the symbol map.