# Globals/procedures/constants  (guide pp. 331–346)

Rust module(s): `src/app/program.rs`, `src/app/application.rs`, `src/event/mod.rs`, `src/event/key.rs`, `src/dialog/filedlg.rs`, `src/dialog/msgbox.rs`, `src/widgets/editor.rs`, `src/widgets/history.rs`, `src/help.rs`, `src/view/view.rs`, `src/window/window.rs`   |   magiblot: `source/tvision/`, `include/tvision/`

> This section covers the globals, procedures, and constants of the Turbo Vision 2.0
> reference from `DoneDosMem` through `kbXXXX` (keyboard constants that begin on p.347).
> Entries are in guide order.

| Guide entry | Pg | Bucket | Corr | Rust symbol / mapping | Doc | Notes |
|---|---|---|---|---|---|---|
| `DoneDosMem` (procedure) | 331 | NOT-PORTED | — | — | — | DOS heap management for shell-out. Rust owns memory via allocator; `Application` comment notes no explicit setup/teardown needed (`application.rs` module doc). |
| `DoneEvents` (procedure) | 331 | EQUIVALENT | OK | `CrosstermBackend::drop` (`src/backend/crossterm_backend.rs:272`) | N/A | C++ disables mouse interrupt handler + hides mouse. Rust backend `Drop` calls `restore_terminal()` which teardowns crossterm raw mode and mouse. Idiomatic RAII. `CrosstermBackend::drop` is not a public API symbol. |
| `DoneHistory` (procedure) | 331 | EQUIVALENT | OK | `thread_local! HISTORY` auto-drops (`src/widgets/history.rs:68`) | N/A | C++ frees the history block. Rust uses a `thread_local! RefCell<Vec<HistRec>>` that drops automatically; no explicit free needed. `HISTORY` is module-private. |
| `DoneMemory` (procedure) | 331 | NOT-PORTED | — | — | — | C++ frees all cache buffers allocated via `GetBufMem`. No DOS heap/cache-buffer system in Rust port. |
| `DoneSysError` (procedure) | 332 | NOT-PORTED | — | — | — | C++ restores DOS interrupt vectors 09H, 1BH, 21H, 23H, 24H. DOS-era; no analog in crossterm/Rust. |
| `DoneVideo` (procedure) | 332 | EQUIVALENT | OK | `CrosstermBackend::drop` → `restore_terminal()` (`src/backend/crossterm_backend.rs:272`) | N/A | C++ restores initial screen mode, clears screen, restores cursor. Rust `CrosstermBackend::drop` calls `restore_terminal()`. Same RAII pattern as `DoneEvents`. Not a public API symbol. |
| `DoubleDelay` (variable) | 332 | EQUIVALENT | OK | `MouseEventFlags::double_click: bool` on `MouseEvent` (`src/event/mod.rs`) | 3 | C++ global `Word = 8` (units: 1/18.2 s). Heritage note in `MouseEventFlags` now states: no timing tunable; interval is OS-controlled via crossterm. `double_click` field docs explain when to check it. |
| `dpXXXX` constants (`dpBlueDialog=1`, `dpCyanDialog=2`, `dpGrayDialog=3`) | 332 | EQUIVALENT | OK | `tv::WindowPalette::{Blue, Cyan, Gray}` (`src/window/window.rs:56`) | 3 | Heritage note now cites `dpBlueDialog`/`dpCyanDialog`/`dpGrayDialog` and `wpBlueWindow`/`wpCyanWindow`/`wpGrayWindow`. Each variant doc explains when to use it (plain window / help viewer / dialog). |
| `EditorDialog` (variable) | 333 | NOT-PORTED | — | — | — | C++ was a global procedural variable (`TEditorDialog = DefEditorDialog`) allowing app-wide override of editor dialog dispatch. Rust port handles editor dialogs directly via `Deferred::OpenMessageBox` and per-editor closure chains in `Program`; there is no single global function pointer. |
| `EditorFlags` (variable) | 333 | EQUIVALENT | OK | `Editor::editor_flags: u16` (private field; `src/widgets/editor.rs:421`) | N/A | C++ was a global `Word = efBackupFiles + efPromptOnReplace`. Rust makes it a private per-instance field on `Editor`; set/get via `pub(crate)` accessors. Not public API. |
| `edXXXX` constants | 333–334 | NOT-PORTED | — | — | — | C++ constants (`edOutOfMemory=0` .. `edReplacePrompt=10`) passed to the `EditorDialog` function to identify which dialog to show. No `EditorDialog` function-pointer mechanism was ported; editor dialogs are dispatched via `Deferred::OpenMessageBox` and `request_message_box`. |
| `efXXXX` constants | 334 | EQUIVALENT | OK | `EF_CASE_SENSITIVE`, `EF_WHOLE_WORDS_ONLY`, `EF_PROMPT_ON_REPLACE`, `EF_REPLACE_ALL`, `EF_DO_REPLACE`, `EF_BACKUP_FILES` (`src/widgets/editor.rs:87–98`, `pub(crate)`) | N/A | Six constants with matching values ($0001–$0100). `pub(crate)` visibility — not public API. Each has an internal `///` doc comment explaining its meaning. |
| `EmsCurHandle` (variable) | 335 | NOT-PORTED | — | — | — | EMS (Expanded Memory Spec) state cache for `TEmsStream`. DOS EMS memory; no analog. |
| `EmsCurPage` (variable) | 335 | NOT-PORTED | — | — | — | EMS page state cache for `TEmsStream`. DOS EMS memory; no analog. |
| `ErrorAttr` (constant) | 335 | NOT-PORTED | — | — | — | C++ `const Byte = $CF`: error video attribute returned by `TView.GetColor` on palette mapping failure. Rust uses `Theme`/`Role` lookups; there is no raw video attribute fallback constant. Palette errors surface differently (no fallback color sentinel). |
| `evXXXX` constants — individual event types | 336 | EQUIVALENT | OK | `Event` enum variants: `Event::MouseDown`, `Event::MouseUp`, `Event::MouseMove`, `Event::MouseAuto`, `Event::KeyDown`, `Event::Command`, `Event::Broadcast`, `Event::Nothing` (`src/event/mod.rs:55–93`) | 3 | C++ `evMouseDown=$0001`, `evMouseUp=$0002`, `evMouseMove=$0004`, `evMouseAuto=$0008`, `evKeyDown=$0010`, `evCommand=$0100`, `evBroadcast=$0200`, `evNothing=$0000`. Rust: closed `Event` enum — no bitmask needed, each variant is structural. Known idiomatic mapping (D4). Module doc explains the heritage, each variant is documented. `evMouseWheel` is a Rust addition (`Event::MouseWheel`). |
| `evXXXX` mask constants — `evNothing`, `evMouse`, `evKeyboard`, `evMessage` | 336 | EQUIVALENT | OK | `EventMask::{mouse_move, mouse_auto}` + routing logic in `Group::handle_event` (`src/event/mod.rs:190`, `src/view/group.rs`) | 3 | Rust `EventMask` keeps only the two opt-in bits (`mouse_move`, `mouse_auto`); routing is structural (enum-match), not bitmask. `EventMask` rustdoc explains the opt-in design and when to set each flag. |
| `fdXXXX` constants | 337 | PORTED | OK | `FD_OK_BUTTON`, `FD_OPEN_BUTTON`, `FD_REPLACE_BUTTON`, `FD_CLEAR_BUTTON`, `FD_HELP_BUTTON`, `FD_NO_LOAD_DIR` (`src/dialog/filedlg.rs`) | 3 | All six public `pub const` with individual rustdoc (what each button does, its `Command`, when to choose it). A leading block comment documents typical combination patterns (open dialog, save-as, with-clear, with-help). Each constant now has a heritage note. |
| `FindStr` (variable) | 337 | EQUIVALENT | OK | `Editor::find_str: String` (private field; `src/widgets/editor.rs:417`) | N/A | C++ was a global `string[80]`. Rust private per-instance field with a `///` comment noting the per-instance vs. global design. Not public API. |
| `FNameStr` (type) | 337 | NOT-PORTED | — | — | — | C++ `FNameStr = string[79]`: a Pascal fixed-length string typedef for DOS file names. Rust uses `String`/`&str` throughout; no fixed-length file-name type. |
| `FocusedEvents` (variable) | 337–338 | EQUIVALENT | OK | Structural enum routing in `Group::handle_event` (`src/view/group.rs:1187–1202`) | N/A | C++ `Word = evKeyboard + evCommand`: global constant used by `TGroup.HandleEvent`. Rust: enum-arm match in `Group::handle_event`; no public constant or knob. The routing logic is internal. |
| `FormatStr` (procedure) | 338–339 | NOT-PORTED | — | — | — | C++ `vsprintf`-style string formatter taking `Format: String; var Params`. Rust uses `format!` macro and standard `Display`/`write!` throughout; no `FormatStr` analog exists or is needed. |
| `FreeBufMem` (procedure) | 340 | NOT-PORTED | — | — | — | C++ frees a cache buffer via `DisposeCache`. DOS cache-buffer management; no analog in Rust port. |
| `GetAltChar` (function) | 340 | NOT-PORTED | — | — | — | C++ `function GetAltChar(KeyCode: Word): Char` — reverse-maps a 2-byte alt scan code to the character. Rust encodes Alt keys as `Key::Char(ch)` + `KeyModifiers::alt`; no scan-code reverse-lookup function needed. |
| `GetAltCode` (function) | 340 | NOT-PORTED | — | — | — | C++ `function GetAltCode(Ch: Char): Word` — maps a char to its alt 2-byte scan code. Same reason as `GetAltChar`; scan codes are not exposed in the Rust key model. |
| `GetBufMem` (procedure) | 340–341 | NOT-PORTED | — | — | — | C++ allocates a cache buffer. DOS cache-buffer management; no analog. |
| `GetBufferSize` (function) | 340 | NOT-PORTED | — | — | — | C++ returns size in bytes of a buffer allocated by `NewBuffer`. DOS memory management; no analog. |
| `GetKeyEvent` (procedure) | 341 | EQUIVALENT | OK | crossterm keyboard polling in `CrosstermBackend` / `Program::pump_once` (`src/app/program.rs:1641`) | N/A | C++ polls BIOS INT 16H. Rust polls via crossterm in the event loop; result surfaces as `Event::KeyDown`. The backend polling is internal (not a public symbol). |
| `GetMouseEvent` (procedure) | 341 | EQUIVALENT | OK | crossterm mouse polling in `CrosstermBackend` / `Program::pump_once` | N/A | C++ polls Turbo Vision's mouse queue. Rust polls via crossterm; results surface as `Event::MouseDown` etc. Internal, not public. |
| `gfXXXX` constants | 341–342 | EQUIVALENT | OK | `tv::GrowMode` struct-of-bools: `lo_x`, `lo_y`, `hi_x`, `hi_y`, `rel`, `fixed` (`src/view/view.rs:183–196`) | 3 | Each field has expanded docs explaining when to set it and typical use-cases. Struct-level doc now lists common flag combinations (fill owner, anchor-to-right, fixed-size-anchor, proportional desktop window). `grow_all()` doc says when to use it. |
| `hcXXXX` constants — `hcNoContext=0`, `hcDragging=1` (Views) | 343 | EQUIVALENT | OK | `HelpCtx::NO_CONTEXT`, `HelpCtx::DRAGGING` (`src/help.rs:54, 57`) | 3 | Direct counterparts; identity changed from `int` to `&'static str` (D1). Both are documented with purpose and when to use. Score 3. |
| `hcXXXX` constants — standard File menu help contexts (`hcNew`=`$FF01` .. `hcExit`=`$FF08`) | 342–343 | NOT-PORTED | — | — | — | C++ defined standard help context constants for `StdFileMenuItems`, `StdEditMenuItems`, `StdWindowMenuItems`. Rust has no `StdXxxMenuItems` helpers and no corresponding `hcXXXX` constants defined. App code uses `HelpCtx::custom("...")` to define its own. |
| `hcXXXX` constants — standard Edit menu help contexts (`hcUndo`=`$FF10` .. `hcClear`=`$FF14`) | 343 | NOT-PORTED | — | — | — | Same reason as File menu hcXXXX: no `StdEditMenuItems` function and no predefined edit-menu help context constants. |
| `hcXXXX` constants — standard Window menu help contexts (`hcTile`=`$FF20` .. `hcClose`=`$FF27`) | 343 | NOT-PORTED | — | — | — | Same reason: no `StdWindowMenuItems` and no predefined window-menu help context constants. |
| `HideMouse` (procedure) | 344 | EQUIVALENT | OK | crossterm mouse cursor hide in `CrosstermBackend` (internal) | N/A | C++ increments "hide counter" in mouse driver. Rust hides/shows mouse cursor via crossterm on terminal setup/teardown. No public `hide_mouse` API — internal to the backend. |
| `HiResScreen` (variable) | 344 | NOT-PORTED | — | — | — | C++ Boolean set by `InitVideo` if EGA/VGA 43/50-line mode available. No DOS video modes; Rust uses crossterm's terminal size query. Not ported. |
| `HistoryAdd` (procedure) | 344 | PORTED | OK | `tv::history_add(id: u8, str: &str)` (`src/widgets/history.rs:94`) | 3 | Rustdoc now says: call after the user confirms an input line; each input line uses a unique stable `id`; explains dedup + eviction order. Heritage note added. |
| `HistoryBlock` (variable) | 344 | EQUIVALENT | OK | `HISTORY: thread_local! RefCell<Vec<HistRec>>` (`src/widgets/history.rs:68`) | N/A | C++ `Pointer = nil`. Rust: module-private `thread_local!`. Not a public symbol. Module doc explains the design. |
| `HistoryCount` (function) | 344–345 | PORTED | OK | `tv::history_count(id: u8) -> usize` (`src/widgets/history.rs:128`) | 3 | Rustdoc explains oldest/newest ordering and typical use (range-check or drive a list viewer). Heritage note added. |
| `HistorySize` (variable) | 345 | EQUIVALENT | OK | `HISTORY_SIZE: usize = 1024` (`src/widgets/history.rs:72`, module-private `const`) | N/A | C++ `Word = 1024`. Rust: module-private `const HISTORY_SIZE`. Not `pub` or `pub(crate)`. Has inline doc comment. |
| `HistoryStr` (function) | 345 | PORTED | OK | `tv::history_str(id: u8, index: usize) -> Option<String>` (`src/widgets/history.rs:135`) | 3 | Rustdoc explains oldest-first indexing, `None` for out-of-range, and that `HistoryViewer` uses this to populate its list. Heritage note added. |
| `HistoryUsed` (variable) | 345 | NOT-PORTED | — | — | — | C++ `Word = 0`: internal offset pointer within the raw history block. Rust uses a `Vec`; there is no raw-offset variable. Implementation detail dropped cleanly. |
| `InitDosMem` (procedure) | 345 | NOT-PORTED | — | — | — | C++ reclaims heap space after DOS shell by calling `SetMemTop`. No DOS heap; no analog. |
| `InitEvents` (procedure) | 346 | EQUIVALENT | OK | `CrosstermBackend::new` / terminal raw-mode setup (`src/backend/crossterm_backend.rs`) | N/A | C++ enables mouse interrupt handler and shows mouse. Rust `CrosstermBackend::new` sets up crossterm raw mode and mouse capture. Not a public API surface. |
| `InitHistory` (procedure) | 346 | EQUIVALENT | OK | `thread_local! HISTORY` auto-initializes (`src/widgets/history.rs:68`) | N/A | C++ allocates the history block. Rust: `thread_local!` auto-initializes on first access. Module-private; no public init call needed. |
| `InitMemory` (procedure) | 346 | NOT-PORTED | — | — | — | C++ installs a heap notification function in `HeapError`. DOS heap management; no analog. |
| `InitSysError` (procedure) | 346 | NOT-PORTED | — | — | — | C++ captures DOS interrupt vectors. DOS-era; no analog. |
| `InitVideo` (procedure) | 347 | EQUIVALENT | OK | `CrosstermBackend::new` (terminal initialization path) | N/A | C++ saves `StartupMode`, switches screen mode, sets `ScreenWidth`/`ScreenHeight`/`HiResScreen`/etc. Rust queries terminal size via crossterm. Internal to the backend; not a public symbol. |
| `InputBox` (function) | 347 | PORTED | OK | `Program::input_box(&mut self, title, label, initial, limit) -> (Command, String)` (`src/app/program.rs`) | 3 | Rustdoc now: "convenience wrapper around `input_box_rect`"; explains `title`/`label`/`initial`/`limit`; documents the `(cmd, text)` return including cancel behavior; notes the centering coordinate caveat. |
| `InputBoxRect` (function) | 347 | PORTED | OK | `Program::input_box_rect(&mut self, bounds, title, label, initial, limit) -> (Command, String)` (`src/app/program.rs`) | 3 | Rustdoc explains scatter/gather, the "single-field shortcut" design, and the `(cmd, text)` return. Heritage note present. |
| `kbXXXX` constants — keyboard state/shift masks (`kbRightShift`, `kbLeftShift`, `kbCtrlShift`, `kbAltShift`, `kbScrollState`, `kbNumState`, `kbCapsState`, `kbInsState`) | 347–348 | EQUIVALENT | OK | `KeyModifiers::{shift, ctrl, alt}` (`src/event/key.rs:76`); Insert/Caps/Scroll/Num Lock states not modeled | 3 | `KeyModifiers` rustdoc has a code example (Ctrl+C pattern) and notes "the platform left/right-Ctrl, left/right-Alt and left/right-Shift distinctions collapse into a single flag each." Heritage note explains the C++ packed word. Lock states omission is OS-determined. |
| `kbXXXX` constants — alt-letter scan codes (`kbAltA` .. `kbAltZ`) | 348 | EQUIVALENT | OK | `Key::Char(ch)` + `KeyModifiers { alt: true }` (`src/event/key.rs`) | 3 | `Key` module doc and type-level docs explain the `Key::Char + modifier` decomposition; heritage section covers the `kb*` family. |
| `kbXXXX` constants — special keys (`kbEqual`, `kbAltMinus`, etc.) | 348–349 | EQUIVALENT | OK | `Key` enum variants + `KeyModifiers` flags (`src/event/key.rs:28–64`) | 3 | Each `Key` variant is individually documented in the enum. `Key` type-level doc explains "no modifier-combined variants" and the decomposition model. `kbNoKey` → absence of `Event::KeyDown`. |
| `kbXXXX` constants — alt-number scan codes (`kbAlt1`..`kbAlt0`) | 349 | EQUIVALENT | OK | `Key::Char('1'..'0')` + `KeyModifiers { alt: true }` | 3 | Same decomposed model as alt-letters; documented in `Key` module/type docs. |
| `kbXXXX` constants — function keys (`kbF1`..`kbF10`) | 349 | EQUIVALENT | OK | `Key::F(1)` .. `Key::F(10)` | 3 | `Key::F(n)` variant documented in the enum. |
| `kbXXXX` constants — shift-function keys (`kbShiftF1`..`kbShiftF10`) | 349 | EQUIVALENT | OK | `Key::F(n)` + `KeyModifiers { shift: true }` | 3 | Decomposed model; `Key::F` + `shift` modifier. |
| `kbXXXX` constants — ctrl-function keys (`kbCtrlF1`..`kbCtrlF10`) | 349 | EQUIVALENT | OK | `Key::F(n)` + `KeyModifiers { ctrl: true }` | 3 | Decomposed model. |
| `kbXXXX` constants — alt-function keys (`kbAltF1`..`kbAltF10`) | 350 | EQUIVALENT | OK | `Key::F(n)` + `KeyModifiers { alt: true }` | 3 | Decomposed model; module doc example shows Alt+F3. |

## Summary

- PORTED: 6   EQUIVALENT: 29   NOT-PORTED: 23   MISSING: 0   UNSURE: 0
- SUSPECT: 0   |   doc<3 (public): 0   |   → concept: 0
- All public symbols are at score 3. Private/internal symbols (EF_* pub(crate), HISTORY thread_local, editor private fields, CrosstermBackend internals, HISTORY_SIZE module-private const) are marked N/A — they carry `///` internal doc comments only.
- Notable finding: The Init*/Done* DOS subsystem lifecycle procedures (InitDosMem, InitSysError, InitEvents, InitMemory, InitVideo, DoneDosMem, DoneSysError, DoneMemory) collapse cleanly into the `CrosstermBackend` RAII `Drop` and auto-initializing `thread_local!` store — a deliberate, architecture-level deviation documented in `application.rs`'s module doc. All 23 NOT-PORTED entries are DOS/EMS memory management, DOS interrupt vectors, or scan-code utilities with no crossterm/Rust equivalent.
