# Globals / Procedures / Constants — alphabetical A–dm  (guide pp. 317–330)

Rust module(s): `src/command.rs`, `src/app/`, `src/event/key.rs`, `src/view/view.rs`,
`src/widgets/button.rs`, `src/widgets/cluster.rs`, `src/widgets/history.rs`,
`src/dialog/filedlg.rs`, `src/backend/clipboard.rs`, `src/desktop/desktop.rs`
| magiblot: `views.h`, `app.h/cpp`, `tbutton.cpp`, `tcluster.cpp`, `tdrivers.cpp`, `thstlst.cpp`

> This section covers Chapter 19 reference entries from "Abstract procedure" (p. 317)
> through "dmXXXX constants" (p. 330) — every variable, procedure, function, and
> constant family in alphabetical order up to and including the D entries that fall
> within this range.

| Guide entry | Pg | Bucket | Corr | Rust symbol / mapping | Doc | Notes |
|---|---|---|---|---|---|---|
| `Abstract` procedure | 317 | NOT-PORTED | — | — | — | DOS Pascal runtime hook: calling it terminates with error 211. Rust uses the language itself (`unimplemented!()` / the trait object mechanism) to prevent instantiation of abstract types; no standalone procedure needed. |
| `Application` variable | 318 | EQUIVALENT | OK | `tv::Application` struct (caller-owned, not a global raw pointer) | 3 | Verified in `src/app/application.rs`: `Application` struct doc adds embed-and-delegate explanation, `Application::new` doc adds factory-closure roles, hardware-init handling, and heritage note naming C++ subsystems. `Application::run`/`pump_once` are also documented (score 3). C++: `Application: PApplication = nil`; Rust: caller-owned, no global raw pointer. |
| `AppPalette` variable | 318 | NOT-PORTED | — | — | — | C++: integer selecting one of three color palettes (apColor/apBlackWhite/apMonochrome) set by `TProgram.InitScreen`. Rust derives its single `Theme` from the terminal's actual capabilities at runtime via `crossterm`; no three-way palette selector. The concept of theming is present via `tv::Theme`, but the per-terminal-type switch is not. |
| `apXXXX` constants (`apColor`, `apBlackWhite`, `apMonochrome`) | 318 | NOT-PORTED | — | — | — | Integer constants selecting the color/BW/mono palette family. Absent because `AppPalette` itself is not ported; `tv::Theme` is selected at runtime without a named integer constant. |
| `AssignDevice` procedure | 318–319 | NOT-PORTED | — | — | — | `TextView` unit. Associates a Pascal `Text` file variable with a `TTextDevice`. DOS Pascal I/O plumbing; no analog in Rust (standard I/O is not redirected through TV widgets via file-variable assignment). `TTextDevice` itself is ported as the `TextDevice` trait in `src/widgets/terminal.rs`, but the Pascal-specific `Assign` protocol has no counterpart. |
| `bfXXXX` constants (`bfNormal`, `bfDefault`, `bfLeftJust`, `bfBroadcast`, `bfGrabFocus`) | 319–320 | EQUIVALENT | OK | `tv::widgets::ButtonFlags` struct-of-bools: `default`, `left_just`, `broadcast`, `grab_focus` | 3 | Verified in `src/widgets/button.rs`: `ButtonFlags` struct doc explains all-false default, struct-update syntax example, and `bfNormal` mapping. Field docs name each flag's effect. `ButtonFlags::new()` doc adds "plain non-default centered button" guidance and the struct-update idiom. Score 3. |
| `ButtonCount` variable | 320 | NOT-PORTED | — | — | — | `Drivers` unit. `ButtonCount: Byte` — number of mouse buttons (0 if no mouse). Set by DOS driver init. Rust's crossterm backend detects mouse availability dynamically; no equivalent global Byte counter exposed. Mouse presence is implicit from whether `Event::MouseDown` events arrive. |
| `cdXXXX` constants (`cdNormal`, `cdNoLoadDir`, `cdHelpButton`) | 320 | PORTED | OK | `tv::CD_NORMAL`, `tv::CD_NO_LOAD_DIR`, `tv::CD_HELP_BUTTON` (re-exported via `tv::dialog`) | 3 | Verified in `src/dialog/filedlg.rs`: `CD_NORMAL` doc explains "standard change-directory dialog, same as passing 0"; `CD_NO_LOAD_DIR` doc explains suppress-initial-read use-case and when to pass it; `CD_HELP_BUTTON` doc explains the extra Help button behavior. All three score 3. |
| `cfXXXX` constants (`cfOneBit`, `cfTwoBits`, `cfFourBits`, `cfEightBits`) | 320–321 | EQUIVALENT | OK | `MultiCheckBoxes::new(…, sel_range, flags, states)` — `flags` field encodes the same bit-packing | 3 | Verified in `src/widgets/cluster.rs`: `ClusterKind::MultiCheckBoxes { flags: u16 }` field doc explains the packed encoding ("low byte is the per-item bit mask, high byte is the per-item bit-shift stride"), gives the 2-bit example (`0x0203`), and states the supported item count. The packing formula is documented on the field itself. Score 3. |
| `CheckSnow` variable | 321 | NOT-PORTED | — | — | — | `Drivers` unit. CGA-hardware snow-checking flag. DOS-only; no analog on modern terminals. |
| `ClearHistory` procedure | 321 | PORTED | OK | `tv::clear_history()` in `src/widgets/history.rs` | 3 | C++: `procedure ClearHistory` — removes all strings from all history lists. Rust: `pub fn clear_history()` with identical behavior (clears the thread-local history store). Rustdoc now adds: three when-to-call sites (dialog reset, session/project change, test isolation), the note that there is no per-channel clear, and the heritage note naming `histlist.cpp`. |
| `ClearScreen` procedure | 321 | NOT-PORTED | — | — | — | `Drivers` unit. Calls `InitVideo` first, then clears the screen. Subsumed by `Backend`/`Renderer` setup in Rust; the screen is cleared as part of program startup through `crossterm`. No exported `clear_screen()` function. |
| `Clipboard` variable | 321–322 | EQUIVALENT | OK | `Backend::set_clipboard` / `Backend::get_clipboard` (trait methods on `Backend`; owned by the backend, not a global `PEditor`) | 3 | `ClipboardChain` is `pub(crate)` — internal. The public API is `Backend::set_clipboard` and `Backend::get_clipboard`. Verified in `src/backend/traits.rs`: `set_clipboard` doc explains the fallback chain (native → OSC 52 → internal), the `false` return meaning, and the headless contract; `get_clipboard` doc explains the read priority. Score 3. C++: `Clipboard: PEditor = nil` — a global pointer to a clipboard-holder editor. Rust: text-only, owned by the `Backend` (arboard → OSC52 → internal fallback, landed A6); no `PEditor` global. |
| `cmXXXX` constants — core view commands (cmValid…cmPrev, 0–8) | 322 | PORTED | OK | `tv::Command::{VALID, QUIT, ERROR, MENU, CLOSE, ZOOM, RESIZE, NEXT, PREV}` | 3 | Values 0–8 in C++; Rust uses namespaced `&'static str` identity (deviation D1, documented). Semantics identical. `cmValid=0` → `Command::VALID`; `cmHelp` not in this table (handled separately). Each constant now documents what it does, who emits it, and who handles it. |
| `cmXXXX` constants — dialog commands (cmOK…cmDefault, 10–14) | 323 | PORTED | OK | `tv::Command::{OK, CANCEL, YES, NO, DEFAULT}` | 3 | C++ values 10–14; Rust namespaced strings. Semantics match. Each constant now documents when it is the modal result and how to check for it. |
| `cmXXXX` constants — edit/window menu commands (cmCut…cmCascade, 20–26) | 323 | PORTED | OK | `tv::Command::{CUT, COPY, PASTE, UNDO, CLEAR, TILE, CASCADE}` | 3 | C++ values 20–26; Rust namespaced strings. All present. Each constant now documents handler, key binding, and when to disable via `CommandSet`. |
| `cmXXXX` constants — app file-menu commands (cmNew…cmCloseAll, 30–37) | 323 | PORTED | OK | `tv::Command::{NEW, OPEN, SAVE, SAVE_AS, SAVE_ALL, CH_DIR, DOS_SHELL, CLOSE_ALL}` | 3 | C++ values 30–37; Rust namespaced strings. All present. Each constant now documents who handles it and how to use it in a File menu. |
| `cmXXXX` constants — broadcast/view commands (cmReceivedFocus…cmRecordHistory, 50–60) | 324 | PORTED | OK | `tv::Command::{RECEIVED_FOCUS, RELEASED_FOCUS, COMMAND_SET_CHANGED, SCROLL_BAR_CHANGED, SCROLL_BAR_CLICKED, SELECT_WINDOW_NUM, LIST_ITEM_SELECTED, RECORD_HISTORY}` | 3 | C++ values 50–60 (50,51,52,53,54,55,56,60). Each constant now documents who broadcasts it, what `source` carries, and when to listen. |
| `cmXXXX` constants — editor search commands (cmFind, cmReplace, cmSearchAgain, 82–84) | 325 | PORTED | OK | `tv::Command::{FIND, REPLACE, SEARCH_AGAIN}` | 3 | C++ values 82–84. Each constant now documents the handler (`Editor`) and key binding. |
| `cmXXXX` constants — editor movement/edit commands (500–523) | 325 | PORTED | OK | `tv::Command::{CHAR_LEFT … UPDATE_TITLE}` (full set in `src/command.rs`) | 3 | C++ values 500–523 (cmCharLeft…cmUpdateTitle). All movement/edit commands now document handler (`Editor`/`Memo`) and key binding. |
| `cmXXXX` constants — file dialog commands (cmFileOpen, cmFileReplace, cmFileClear, 800–802) | 325 | PORTED | OK | `tv::Command::{FILE_OPEN, FILE_REPLACE, FILE_CLEAR}` | 3 | C++ values 800–802. Rust namespaced strings; all present in `src/command.rs`. Each one-liner names the file dialog button it represents, sufficient for the narrow internal usage context. |
| `ColorIndexes` variable | 325 | NOT-PORTED | — | — | — | `ColorSel` unit. `ColorIndexes: PColorIndex = nil` — holds state of the color-selection dialog for save/restore. The entire `TColorDialog`/`TColorIndex` save-state protocol is superseded in Rust by `ColorPicker` returning an `Option<Color>` directly; no persistent index state. (See also: `TColorIndex.md`.) |
| `ColorGroup` function | 325–326 | NOT-PORTED | — | — | — | `ColorSel` unit. Pascal helper that allocates a `TColorGroup` record on the heap and chains it into a linked list. Superseded: `tvision-rs` uses `ColorPicker` (a native Rust `Dialog`) without the linked-list color-group builder. (See also: `TColorGroup.md`.) |
| `ColorItem` function | 326 | NOT-PORTED | — | — | — | `ColorSel` unit. Pascal helper that allocates a `TColorItem` record on the heap. Superseded by the same `ColorPicker` replacement. (See also: `TColorItem.md`.) |
| `coXXXX` constants (`coIndexError`, `coOverflow`) | 326 | NOT-PORTED | — | — | — | `Objects` unit. Error codes passed to `TCollection.Error`. Rust's `Vec`-based collections return `Result`/`Option` or panic on out-of-range access — no equivalent named integer error codes; the concept is absent. |
| `CStrLen` function | 326 | EQUIVALENT | OK | Private `cstrlen(s: &str) -> i32` (duplicated in `src/widgets/cluster.rs`, `src/widgets/button.rs`, `src/status/status_line.rs`, `src/menu/menu_bar.rs`) | 0 | C++: `function CStrLen(S: String): Integer` — returns length of a tilde-hotkey string excluding the tilde characters. Rust: a private `fn cstrlen(s: &str) -> i32` is duplicated in four modules rather than exported. Functionally identical. Not public, so doc score 0 (N/A for public scoring, but the duplication is a minor code smell). |
| `CtrlBreakHit` variable | 327 | NOT-PORTED | — | — | — | `Drivers` unit. Boolean flag set by the DOS Ctrl+Break interrupt handler. DOS-only mechanism; Rust/crossterm uses OS signal handling instead. No analog. |
| `CtrlToArrow` function | 327 | PORTED | OK | `tv::event::ctrl_to_arrow` (re-exported via `tv::ctrl_to_arrow`) | 3 | C++: `function CtrlToArrow(KeyCode: Word): Word` — maps WordStar-compatible Ctrl+key codes to `kbXXXX` cursor constants. Rust: `pub fn ctrl_to_arrow(ke: KeyEvent) -> KeyEvent` with the same 12-entry mapping table. Re-exported at crate root. Doc now adds "when to call it" guidance (call before navigation dispatch in `InputLine`/`Editor`; skip for widgets using Ctrl for clipboard). |
| `CursorLines` variable | 327–328 | NOT-PORTED | — | — | — | `Drivers` unit. `CursorLines: Word` — starting and ending scan lines of the hardware text cursor, set by `InitVideo` for BIOS int $10/fn 1. DOS BIOS cursor shape control; no analog on modern virtual terminals where cursor shape is controlled via ANSI escape sequences by the backend. |
| `DefEditorDialog` function | 328 | NOT-PORTED | — | — | — | `Editors` unit. The default value of the `EditorDialog` procedural variable; shows no dialog and returns `cmCancel`. The entire `TEditorDialog` / `EditorDialog` variable mechanism is not ported (Rust editors use a Deferred-channel dialog protocol instead of a global function pointer). |
| `Desktop` variable | 328 | EQUIVALENT | OK | `tv::Desktop` struct; live desktop is a child of `Program.group`, resolved via `Program::desktop() -> Option<ViewId>` | 3 | Verified in `src/app/program.rs`: `Program::desktop()` doc explains "stable for the application lifetime", when to use it (resolve desktop directly, e.g. custom subtype via `as_any_mut`), and recommends `Program::desktop_insert` for the common "open a window" case. Heritage note names `TProgram::deskTop` global static. Score 3. |
| `DesktopColorItems` function | 328 | NOT-PORTED | — | — | — | `ColorSel` unit. Returns a linked list of `TColorItem` records for the desktop. Part of the `TColorDialog` infrastructure that is superseded by `ColorPicker` in Rust. |
| `DialogColorItems` function | 328–329 | NOT-PORTED | — | — | — | `ColorSel` unit. Returns a linked list of `TColorItem` records for dialog boxes. Same supersession reason as `DesktopColorItems`. |
| `DisposeBuffer` procedure | 329 | NOT-PORTED | — | — | — | `Memory` unit. `procedure DisposeBuffer(P: Pointer)` — frees a buffer allocated by `NewBuffer`. DOS heap manager; Rust `Drop` handles deallocation automatically. No analog needed. |
| `DisposeCache` procedure | 329 | NOT-PORTED | — | — | — | `Memory` unit. Frees a cache buffer allocated by `NewCache`. Same reason as `DisposeBuffer`. |
| `DisposeMenu` procedure | 329 | NOT-PORTED | — | — | — | `Menus` unit. `procedure DisposeMenu(Menu: PMenu)` — disposes all elements of a `TMenu` tree. Rust `Drop` for `Menu` / `MenuItem` handles this; no explicit free procedure needed. |
| `DisposeNode` procedure | 329 | NOT-PORTED | — | — | — | `Outline` unit. `procedure DisposeNode(Node: PNode)` — recursively disposes an outline node tree. Rust `Drop` for `Node` handles recursive deallocation. No analog needed. |
| `DisposeStr` procedure | 330 | NOT-PORTED | — | — | — | `Objects` unit. `procedure DisposeStr(P: PString)` — frees a heap-allocated Pascal string created by `NewStr`. Rust `String`/`Box<str>` use RAII; no explicit free procedure needed. |
| `dmXXXX` constants (`dmDragMove`, `dmDragGrow`, `dmLimitLoX`, `dmLimitLoY`, `dmLimitHiX`, `dmLimitHiY`, `dmLimitAll`) | 330 | EQUIVALENT | OK | `tv::view::DragMode` struct-of-bools: `drag_move`, `drag_grow`, `limit_lo_x`, `limit_lo_y`, `limit_hi_x`, `limit_hi_y`; `DragMode::limit_all()` constructor | 3 | C++: bitmapped `Byte` (`$01/$02/$10/$20/$40/$80/$F0`). Rust: `DragMode { drag_move, drag_grow, drag_grow_left, limit_lo_x, limit_lo_y, limit_hi_x, limit_hi_y }` struct-of-bools. Doc now adds how/when to use: set on `ViewState::drag_mode` during construction; `Window` sets move+grow+limit_lo_y; `limit_all()` for the common four-edge clamp. Heritage section updated with `drag_grow_left` extension note. |

## Summary

- PORTED: 11   EQUIVALENT: 7   NOT-PORTED: 21   MISSING: 0   UNSURE: 0
- SUSPECT: 0   |   doc<3 (public): 0   |   → concept: 0
- Pass 1 raised to score 3 (in permitted files `src/command.rs`, `src/event/key.rs`, `src/view/view.rs`): all `cmXXXX` command families, `CtrlToArrow`→`ctrl_to_arrow`, `dmXXXX`→`DragMode`. Reconciliation pass: `Application`, `bfXXXX`/`ButtonFlags`, `cdXXXX`, `cfXXXX`, `Clipboard`, `Desktop` all verified score 3 and re-scored. Final closeout pass: `ClearHistory` → `clear_history()` raised to score 3 (added three when-to-call sites: dialog reset, session/project change, test isolation; no-per-channel-clear note; heritage note naming `histlist.cpp`).
- Notable finding: The `cmXXXX` command family (the single largest entry, spanning pages 322–325 with ~45 individual constants across 6 tables) is fully ported as `Command` newtype associated constants using namespaced `&'static str` identity (deviation D1). Every constant from `cmValid` through `cmFileClear` has a Rust counterpart; the deviation is deliberate and documented. The 18 NOT-PORTED entries are overwhelmingly DOS-era plumbing — none represent gaps in the Rust port's functionality.
