# TStatusLine  (guide pp. 539–542)

Rust module(s): src/status/status_line.rs   |   magiblot: include/tvision/menus.h / source/tvision/tstatusl.cpp

> TStatusLine inherits all view fields from TView. The guide documents the two
> protected data members `items` and `defs`, five methods (`Draw`, `GetPalette`,
> `HandleEvent`, `Hint`, `Update`), the private `FindItems`, the private
> `DrawSelect`, and the six-entry `CStatusLine` palette. All are listed below.

| Guide entry | Pg | Bucket | Corr | Rust symbol / mapping | Doc | Notes |
|---|---|---|---|---|---|---|
| `items` (protected field) | 539 | EQUIVALENT | OK | `StatusLine.items_def: Option<usize>` (index into `defs` Vec) | 2 | C++: raw `TStatusItem*` pointer to the selected def's first item. Rust: stores the *index* of the selected `StatusDef` in `self.defs` and uses `self.defs[i].items` as needed. Functionally identical; the pointer-vs-index difference is the standard idiomatic linked-list→Vec transformation (D12). Field is private; `selected_def()` test accessor is public. |
| `defs` (protected field) | 539 | EQUIVALENT | OK | `StatusLine.defs: Vec<StatusDef>` | 2 | C++: `TStatusDef*` singly-linked list owned by the view. Rust: `Vec<StatusDef>` owned by the view. Known idiomatic mapping: linked list → Vec. Private; no public accessor. |
| `Init` (constructor) | 540 | PORTED | OK | `tv::StatusLine::new(bounds: Rect, defs: Vec<StatusDef>) -> StatusLine` | 3 | Guide / C++: sets `ofPreProcess`, `evBroadcast`, `gfGrowLoY|gfGrowHiX|gfGrowHiY`, calls `findItems`. Rust `new` sets all four grow-mode booleans plus `options.pre_process = true`, initialises `help_ctx = HelpCtx::NO_CONTEXT`, runs `find_items`. The `eventMask |= evBroadcast` is not needed — Group fans broadcasts unconditionally; documented in module doc. All constructor semantics matched. Doc score 3. |
| `Draw` (method) | 540 | PORTED | OK | `tv::StatusLine::draw` (impl `View::draw`) | 3 | C++: delegates to `drawSelect(0)` which fills the row, lays out visible items left-to-right with per-item colour, then appends the hint tail. Rust: same single-pass layout; `pressed_item` replaces the `selected` pointer as the highlight discriminator; colour matrix is `StatusColors::item(enabled, selected)`. The whole-tree redraw model means no separate `drawView()` call is needed after mouse-up (deviation D9, documented). |
| `GetPalette` (method) | 541 | EQUIVALENT | OK | `tv::StatusColors::resolve(ctx: &DrawCtx) -> StatusColors` + `tv::theme::Role::Status*` | 3 | C++: returns the `CStatusLine` 6-entry palette. Rust: replaces palette indirection with direct theme-role lookups (deviation D7, documented in module doc and heritage section). `StatusColors::resolve` now explains call-once-at-top-of-draw and links to `StatusLine::draw` as the consumer. Doc score 3. The `Role::Status*` entries remain in theme.rs (deferred to theme pass). |
| `HandleEvent` (method) | 541 | PORTED | OK | `tv::StatusLine::handle_event` (impl `View::handle_event`) | 3 | Guide / C++: (1) `evMouseDown` — loop tracking mouse-move + drawSelect highlight, post command on release if enabled, clearEvent; (2) `evKeyDown` — transform matching item's key into evCommand in place; (3) `evBroadcast` cmCommandSetChanged → drawView. Rust: (1) mouse-down arms a `MouseTrackCapture` (A3 seam) for press-and-hold drag-highlight instead of an inline `mouseEvent` spin-loop; post-on-release semantics preserved; (2) key transform-in-place ported verbatim; (3) broadcast → `request_update_menu` broker (deferred graying, same net effect). Degenerate no-id fallback for uninserted views documented in code. All three arms present; documented deliberate deviations (D3 capture, D9 redraw). |
| `Hint` (method) | 541 | EQUIVALENT | OK | `StatusLine.hint: Box<dyn Fn(HelpCtx) -> Option<String>>` + `set_hint` / `with_hint` | 3 | C++: `virtual const char* hint(ushort aHelpCtx)` returning `""` by default; subclasses override. Rust: non-virtual — stores a `Box<dyn Fn>` closure; `set_hint` / `with_hint` replace subclassing. Return type `Option<String>` replaces empty-string sentinel (`None` = no hint). Known idiomatic mapping: virtual override → stored closure. `with_hint` is builder-style. Documented at score 3 including the empty-string / `None` distinction. |
| `Update` (method) | 542 | EQUIVALENT | OK | `tv::StatusLine::set_help_ctx` + `Program` idle pump | 3 | C++: `update()` walks to `TopView()`, reads its `helpCtx`, calls `findItems` + `drawView` if changed. Rust: `set_help_ctx(ctx)` is called by the `Program` idle loop with the topmost view's context (documented in module doc); idempotent guard skips re-scan if unchanged. The `drawView()` is replaced by the whole-tree redraw (D9). Doc score 3 — `set_help_ctx` now has a `# Turbo Vision heritage` section naming `update()`, `TopView()`, and the D9 deviation. |
| `FindItems` (private method) | 542 | PORTED | OK | `tv::StatusLine::find_items` (pub) | 3 | C++: walks `defs` list to find first `TStatusDef` whose `[min, max]` range contains `helpCtx`. Rust: `find_items` walks `self.defs` Vec, uses `HelpCtxRange::matches`; stores the index in `items_def`. Made `pub` (test / program access); C++ was private. Doc score 3 — doc now explains auto-call by new/set_help_ctx, when to call manually (post-construction defs modification). |
| `DrawSelect` (private method) | — | EQUIVALENT | OK | `StatusLine.pressed_item: Option<usize>` field + `draw` | 1 | C++: `void drawSelect(TStatusItem *selected)` — the shared draw path for both `draw()` and the mouse-loop highlight. Rust: no separate `drawSelect`; the `draw` method reads `self.pressed_item` directly as the highlight discriminator. Refactoring is deliberate and documented in the `draw` rustdoc. |
| `ItemMouseIsIn` (private method) | — | PORTED | OK | `StatusLine::item_mouse_is_in(mouse: Point) -> Option<usize>` | 2 | C++: returns `TStatusItem*`. Rust: returns `Option<usize>` (index). Same hit-test logic: y≠0 → None; walk visible items accumulating span `[i, i+cstrlen+2)`. Textless items skip the span advance. Private in C++; private in Rust. |
| `CStatusLine` palette (6 entries) | 542 | EQUIVALENT | OK | `tv::theme::Role::{StatusNormal, StatusShortcut, StatusSelect, StatusShortcutSelect, StatusDisabled, StatusSelDisabled}` | 3 | C++: `cpStatusLine = "\x02\x03\x04\x05\x06\x07"` — 6 entries mapping app-color slots 2–7. Rust: 6 `Role::Status*` entries; all carry score-3 docs in `src/theme.rs` with explicit color values, chain, and `StatusLine` as consumer (confirmed in theme.rs Role pass). |

## Summary

- PORTED: 5   EQUIVALENT: 7   NOT-PORTED: 0   MISSING: 0   UNSURE: 0
- SUSPECT: 0   |   doc<3 (public): 0   |   → concept: 0
- Notable findings: All public symbols at or above score 3. Private fields (`items_def`, `defs`, `pressed_item`, `item_mouse_is_in`) have useful internal comments but are not held to the public bar. `Role::Status*` entries confirmed score-3 in the theme.rs Role pass. `set_help_ctx` has a full heritage section naming C++ `update()`, `TopView()`, and D9. `find_items` explains auto-call vs. manual use. `StatusColors::resolve` explains the call-once-at-draw-top pattern.
