More Controls — gap analysis and roadmap¶
Survey of the widget set in src/views/ against both the Borland Turbo Vision
reference and the expectations of a modern text UI toolkit. Work top to bottom
within each section.
What already exists¶
Containers: Group, Window, Dialog, Desktop, Frame, Background.
(AnsiBackground moved to tv-extensions' graphics feature in 4.0.0.)
Input: InputLine (with Validator, PictureValidator, LookupValidator),
Button, CheckBox, RadioButton, Cluster, Editor / EditWindow /
FileEditor.
Display: StaticText, Label, ParamText, Memo, TextViewer, ListBox,
SortedListBox, DirListBox, FileList, Outline (tree), Indicator,
Scroller, ScrollBar. (KittyImage, TerminalWidget and LogWindow moved
to tv-extensions' graphics and log features in 4.0.0; see
UPGRADING-TO-4.0.md.)
Chrome and canned dialogs: MenuBar, MenuBox, MenuViewer, StatusLine,
msgbox, FileDialog, ChDirDialog, ColorDialog, ColorSelector,
HistoryWindow, the help_* family.
New controls¶
Ordered by benefit-to-effort. Each one composes existing views wherever it can.
- ProgressBar / gauge — done,
src/views/progress_bar.rs. Determinate and marquee modes;Smooth/Blocks/Asciiglyph styles; centred percentage overlay that can be toggled off or replaced with fixed text; self-animating marquee viaIdleView;CP_PROGRESS_BARpalette reusing the scrollbar gauge colours. Demo inexamples/progress_bar.rs. Still open: a compact status-line variant. - ComboBox / dropdown list — done,
src/views/combo_box.rs. Read-only flavour: a field with a drop arrow, F4 or a click drops the list, arrows cycle without opening. The popup runs modally through the same two-step command the history button uses, since a control cannot reach the terminal fromhandle_event. Still open: the editable flavour, where the field is a realInputLine. - Spinner / numeric up-down — done,
src/views/spinner.rs. Holds one integer inside a range, so typed input is clamped rather than rejected. Arrows step, PgUp and PgDn step ten times as far, Home and End jump to the ends, digits edit the number, and the steppers are clickable. Optional wrap-around and a unit suffix. - TabbedPane / notebook — done,
src/views/tabbed_pane.rs. Each page is aGroup, so it holds ordinary controls and runs its own focus traversal. Drawn as enclosed tab boxes over a framed page, the active tab's floor open. F6 and Shift+F6 switch, as do Ctrl+PgUp/PgDn where the terminal sends them, tilde hotkeys, and clicking a tab. Tab cycles within the active page rather than escaping it. - Table / grid view — done,
src/views/table.rs. Header row, per-column widths and alignment, and a focused cell rather than a focused row: Up and Down move rows, Left and Right move columns, and the grid scrolls in both directions by whole columns. Ragged rows draw blank instead of panicking. - Splitter — done as
SplitPane,src/views/split_pane.rs. A bare divider cannot resize siblings it does not own, so the control owns both halves, each aGroup, the wayTabbedPaneowns its pages. Vertical or horizontal, draggable, with a minimum size per half; F8 moves focus between them. Keyboard divider movement is left to the host throughgrow_firstandshrink_first, rather than stealing a key from the panes. - Tooltip / hint popup — done,
src/views/tooltip.rs. One tooltip serves a whole dialog: register a rect and a line of text per control, and the pointer resting on one raises the hint beside it. Add it last, since it draws over its neighbours. The hover delay runs off the newCM_IDLE_TICKbroadcast. - Slider — done,
src/views/slider.rs. Moved in from turbo-vision-extras; the dragging counterpart ofSpinner. A horizontal track with a thumb over ani64range.
| Key | Action |
|---|---|
| Left, Right | One step down or up |
| Home, End | Minimum or maximum |
Clicking or dragging the track moves the thumb under the pointer; a drag
keeps tracking the pointer even once it leaves the track. set_on_change
broadcasts a command on every user-driven change.
use turbo_vision::views::Slider;
use turbo_vision::core::geometry::Rect;
let mut slider = Slider::new(Rect::new(2, 2, 30, 3), 0, 100);
slider.set_step(5);
slider.set_on_change(1);
assert_eq!(slider.value(), 0);
Completing existing controls¶
-
CheckBoxes/RadioButtonsas true clusters — done,src/views/cluster_group.rs. Each holds its items in one focusable control with a single bitmask value, as Borland does. Arrows move within the cluster, Space toggles or selects, Tab leaves it, and a tilde-marked letter is an item's Alt hotkey; items can be disabled individually. The existing one-labelCheckBoxandRadioButtonare untouched and still supported. - Multi-select in
ListBox— done.set_multi_selectadds marks that are independent of the focus: Space marks the focused item, Shift+click marks a run from the anchor, andmarked_items/marked_textreport them in list order. Marked rows carry a check glyph in a two-cell column, andis_selectedfollows the marks in that mode. Off by default, so existing single-selection lists are untouched. - ScrollBar mouse auto-repeat — done.
Applicationtracks whether a button is held and, only then, broadcastsCM_MOUSE_AUTO_REPEATfrom its idle pass; the scrollbar repeats the press it is holding after a 400 ms delay, every 80 ms, and stops at the end of the range. Nothing is sent while no button is down, so an idle app stays idle. - Frame zoom-icon rendering — done. A resizable window's title bar now
carries
[\u{25B2}]beside the close box, turning into[\u{25BC}]once zoomed. It tracks press and release like the close box, so a press that slides off cancels. Dialogs show none, since Borland pairs wfZoom with wfGrow and a dialog has neither. - Table column separators — done.
Table::set_separators/TableBuilder::separatorsdrawtable::SEPARATOR(│) in the one-cell gap between each pair of visible columns, in each line's own colour. Off by default; columns stay where they are, so a click lands on the same cell either way. - Table frozen panes — done.
Table::set_frozen_cols/TableBuilder::frozen_colskeep the first columns at the left while the rest scroll sideways, marked bytable::FROZEN_SEPARATOR(║) whether separators are on or not;Table::set_frozen_rows/TableBuilder::frozen_rowskeep the first rows under the header while the rest scroll, the last one underlined. Focusing a frozen cell scrolls nothing.examples/table_frozen.rsfreezes a region column and a totals row. - Table cell formats — done.
table::CellFormat(text colour, background colour,Styleflags) given toTable::set_row_format,set_column_formatorset_cell_formatcolours and styles a row, a column or one cell;clear_formatsremoves them all. Formats stack column, row, cell, later ones winning on colours and styles adding up. The selected row keeps the selection colours and takes only the style. A terminal has no fonts, so "font" means bold, italic, underline, reverse, dim and strikethrough.examples/table_format.rsand the gallery's Table demo show it. - Lazy rows and items — done.
table::RowProvider(rows(),cell(row, col)) andlistbox::ListProvider(len(),item(index), a defaultis_empty) let aTableorListBoxread its content only as it draws it, instead of holding every row or item as an owned string. Give one toTable::set_provider/ListBox::set_provider; callrefresh_rows/refresh_itemsafter the source's length changes — drawing and cell access always read the provider's current length, but navigation and therow_count/item_countaccessors use the count from the last refresh. Because content can now come from a provider,Table::selected_cell,ListBox::get_selected_itemandListBox::marked_textreturn ownedStrings instead of borrowing.
Demo¶
examples/new_controls.rs runs all five new controls in one dialog. A tabbed
pane holds two pages: the first wires three combo boxes and a spinner to a
progress bar, the second is a table.
What is left¶
Nothing on this list. Two things worth knowing about what shipped:
CM_IDLE_TICK, added for the tooltip's hover delay, is a general timer any view can use.Application::idlebroadcasts it whenever the event poll times out. Views must not consume it, since a broadcast stops travelling once it is.- The clusters take their colours from
CP_CLUSTER, so they look exactly like the existing one-labelCheckBoxandRadioButton.
Notes¶
New views follow the established shape: a struct holding bounds and a
palette_chain, an impl View, a *Builder with a fluent API and
build() / build_boxed(), unit tests in the same file, and a pub mod entry
plus doc-comment listing in src/views/mod.rs.