pub struct Command(/* private fields */);Expand description
The identity of an action — what a menu item, button, or key binding emits and a view interprets. A command’s identity is a namespaced static string rather than a number, so downstream code can mint application-specific commands collision-safely.
The field is private: a Command is an opaque token. The associated
constants below are the framework’s standard vocabulary, and external
apps/views use Command::custom to define their own, namespacing under their
own dotted prefix:
const REFRESH: tvision_rs::Command = tvision_rs::Command::custom("myapp.refresh");Equality and hashing compare the string contents, so two Commands with
equal-content names are equal regardless of where the literals live.
Default is Command::VALID (the zero command).
§Turbo Vision heritage
Ports the cm* command family (views.h), which were plain ints; here a
command’s identity is a namespaced &'static str (deviation D1).
Implementations§
Source§impl Command
impl Command
Sourcepub const VALID: Command
pub const VALID: Command
The no-op / always-valid command; also the zero/default command.
Used as the response to View::valid meaning
“this view is always willing to proceed”. Also the Default value for
Command.
Sourcepub const QUIT: Command
pub const QUIT: Command
Quit the application — emit from a menu item or key binding (e.g. Alt-X).
Handled by Program, which closes all windows and exits
the event loop. Place in your status-line or File menu to give users a
standard exit path.
Sourcepub const ERROR: Command
pub const ERROR: Command
Report a runtime error — a beep / no-op fallback for unhandled commands.
Program sends this to the focused view when a command cannot be routed;
the default handler produces an audible bell. Views should not normally
emit this directly.
Sourcepub const MENU: Command
pub const MENU: Command
Open the menu bar — emit from a key binding (conventionally F10).
Handled by the MenuBar; the status-line default key set binds F10 to this
command so users can enter the menu with the keyboard.
Sourcepub const CLOSE: Command
pub const CLOSE: Command
Close the active window — handled by the active Window.
Emitted by the window’s close button (frame close icon) or from a menu item
(e.g. Alt-F3 in the default window menu). The window calls
View::valid before closing.
Sourcepub const ZOOM: Command
pub const ZOOM: Command
Maximize / restore the active window — handled by the active Window.
Emitted by the window’s zoom button (frame zoom icon) or a key binding. Toggles between the zoomed (full-desktop) rect and the saved un-zoom rect.
Sourcepub const FULLSCREEN: Command
pub const FULLSCREEN: Command
Cycle the active window through frameless-fullscreen modes
(Off → Desktop → Screen → Off). Handled by the Window; no default key
binding (apps bind their own). See Window::set_fullscreen.
Sourcepub const RESIZE: Command
pub const RESIZE: Command
Enter window resize/move mode — handled by the active Window.
Emitted by the frame drag handle or a key binding. Starts the interactive drag loop where arrow keys reposition or resize the window.
Sourcepub const NEXT: Command
pub const NEXT: Command
Focus the next window on the desktop — handled by Program.
Cycles the desktop’s current window forward. Bind to a key (e.g. F6) in the window menu to give keyboard access to window cycling.
Sourcepub const PREV: Command
pub const PREV: Command
Send the active window to the back (focus the previous one).
Handled by Program; cycles the desktop’s current window
backward. Bind to Shift-F6 or the window menu as a companion to NEXT.
Sourcepub const HELP: Command
pub const HELP: Command
Open context help — handled by Program.
Dispatched when the user presses F1 or the frame help icon. Program
routes it to the registered help viewer if any.
Sourcepub const OK: Command
pub const OK: Command
Confirm / accept a dialog — the modal result returned when the user presses the OK / default button or Enter.
Program::exec_view returns this command when a dialog’s modal loop ends on
confirmation. Check the return value to distinguish OK from CANCEL after a
Dialog::run / MessageBox call.
Sourcepub const CANCEL: Command
pub const CANCEL: Command
Cancel / dismiss a dialog without accepting — always enabled (cannot be
disabled via CommandSet).
The Escape key generates this in a dialog. The framework guarantees
CANCEL is always in the enabled command set so users can always dismiss.
Sourcepub const YES: Command
pub const YES: Command
Answer “yes” in a yes/no confirmation dialog.
Emitted by the Yes button in a MessageBox::confirm style dialog; check the
modal result against this to detect a “yes” answer.
Sourcepub const NO: Command
pub const NO: Command
Answer “no” in a yes/no confirmation dialog.
Emitted by the No button in a MessageBox::confirm style dialog. The dialog
loop ends and this is the return value when the user picks No.
Sourcepub const DEFAULT: Command
pub const DEFAULT: Command
Activate the dialog’s default button — broadcast on Enter inside a dialog
to the default button (the one whose ButtonFlags.default is true).
Sourcepub const CUT: Command
pub const CUT: Command
Cut the selection to the clipboard (Shift-Del / Ctrl-X).
Handled by Editor / Memo; disable via CommandSet when nothing is
selected. Place in a standard Edit menu.
Sourcepub const COPY: Command
pub const COPY: Command
Copy the selection to the clipboard (Ctrl-Ins / Ctrl-C).
Handled by Editor / Memo; disable via CommandSet when nothing is
selected. Place in a standard Edit menu.
Sourcepub const PASTE: Command
pub const PASTE: Command
Paste from the clipboard (Shift-Ins / Ctrl-V).
Handled by Editor / Memo. Place in a standard Edit menu.
Sourcepub const UNDO: Command
pub const UNDO: Command
Undo the last edit (Alt-Backspace / Ctrl-Z).
Handled by Editor / Memo; disable via CommandSet when the undo
buffer is empty. Place in a standard Edit menu.
Sourcepub const CLEAR: Command
pub const CLEAR: Command
Clear (delete) the selection without copying to the clipboard (Ctrl-Del).
Handled by Editor / Memo; disable via CommandSet when nothing is
selected.
Sourcepub const TILE: Command
pub const TILE: Command
Tile the open windows into a grid — handled by Desktop.
Bind to a Window menu item (e.g. “Tile”); the desktop repositions and
resizes all tileable windows (Options::tileable = true) to fill the
desktop area without overlap.
Sourcepub const CASCADE: Command
pub const CASCADE: Command
Cascade the open windows in an offset stack — handled by Desktop.
Bind to a Window menu item (e.g. “Cascade”); each tileable window is placed at a staggered offset so title bars are visible.
Sourcepub const NEW: Command
pub const NEW: Command
Create a new document — emit from a File menu “New” item.
The framework does not handle this; your application handles it by opening a new editor window.
Sourcepub const OPEN: Command
pub const OPEN: Command
Open a document — emit from a File menu “Open” item.
The framework does not handle this automatically; your application handles it by running a file-open dialog and opening the chosen file.
Sourcepub const SAVE: Command
pub const SAVE: Command
Save the current document — emit from a File menu “Save” item.
Your application handles this; disable via CommandSet when no document
is open or the editor is unmodified.
Sourcepub const SAVE_AS: Command
pub const SAVE_AS: Command
Save the current document under a new name — emit from “Save As”.
Your application handles this by running a file-save dialog.
Sourcepub const SAVE_ALL: Command
pub const SAVE_ALL: Command
Save all open documents — emit from “Save All”.
Your application handles this; disable when no modified documents are open.
Sourcepub const CH_DIR: Command
pub const CH_DIR: Command
Change the working directory — opens the change-directory dialog.
Handled by the standard ChDirDialog when your application routes it.
Sourcepub const DOS_SHELL: Command
pub const DOS_SHELL: Command
Drop to a shell prompt (inherited from the DOS era; keep for compatibility).
In the original Turbo Vision this suspended the application to a DOS shell; in a modern port you may repurpose it or leave it disabled.
Sourcepub const CLOSE_ALL: Command
pub const CLOSE_ALL: Command
Close all open windows — emit from a Window menu “Close All” item.
Desktop / Program close every window whose
valid(CLOSE) returns true.
Sourcepub const RECEIVED_FOCUS: Command
pub const RECEIVED_FOCUS: Command
A view received focus — broadcast by Group whenever it calls
set_current; carries the newly-focused view’s ViewId as source.
Listen for this in a parent or sibling to react to focus changes (e.g. to update a status bar or enable/disable commands).
Sourcepub const RELEASED_FOCUS: Command
pub const RELEASED_FOCUS: Command
A view is about to release focus — broadcast before set_current removes
focus; carries the old view’s ViewId as source.
Can be vetoed via View::valid: if the focused
view’s valid(RELEASED_FOCUS) returns false, the focus change is blocked.
Sourcepub const COMMAND_SET_CHANGED: Command
pub const COMMAND_SET_CHANGED: Command
The set of enabled commands changed — broadcast by Program after any
CommandSet update.
Menu bars, status lines, and buttons listen for this to re-query which commands are enabled and redraw accordingly.
Sourcepub const SCROLL_BAR_CHANGED: Command
pub const SCROLL_BAR_CHANGED: Command
A scroll bar’s value changed — broadcast by ScrollBar
whenever the thumb moves; source is the scroll bar’s ViewId.
A scroller or list viewer receives this broadcast and scrolls its content
to match. The cross-view broker in the pump resolves source to the
scroll bar and reads its value.
Sourcepub const SCROLL_BAR_CLICKED: Command
pub const SCROLL_BAR_CLICKED: Command
A scroll bar arrow or page region was clicked — broadcast by
ScrollBar to trigger a single scroll step.
Sourcepub const TAB_BAR_CHANGED: Command
pub const TAB_BAR_CHANGED: Command
Sourcepub const SELECT_WINDOW_NUM: Command
pub const SELECT_WINDOW_NUM: Command
Select the desktop window whose number matches the Alt-N keypress.
Emitted by Program when the user presses Alt-1 through Alt-9; the
desktop walks its children and focuses the window whose
View::number matches.
Sourcepub const LIST_ITEM_SELECTED: Command
pub const LIST_ITEM_SELECTED: Command
A list item was activated (broadcast) — emitted by ListViewer on
Enter or double-click; source is the list viewer’s ViewId.
Listen for this broadcast in a parent view to react to item selection (e.g. open a document, populate a detail pane).
Sourcepub const LIST_FIND_CHANGED: Command
pub const LIST_FIND_CHANGED: Command
The find query changed (incremental find-and-highlight); source is the
list viewer’s ViewId. Mirrors SCROLL_BAR_CHANGED’s notify-by-
broadcast — a parent filters on source to drive an external search
(e.g. submit an async query and re-feed results).
Sourcepub const TABLE_SORT_CHANGED: Command
pub const TABLE_SORT_CHANGED: Command
A Table’s sort order changed through the user
(a header click or TABLE_SORT_NEXT /
TABLE_SORT_FLIP); source is the table’s
ViewId. Read the new order with Table::sort_spec.
Sourcepub const TABLE_SELECTION_CHANGED: Command
pub const TABLE_SELECTION_CHANGED: Command
A multi-select Table’s set of marked rows
changed through the user (Space or a double-click toggled a row);
source is the table’s ViewId. Read the set with
Table::selected_keys.
Sourcepub const TABLE_SORT_NEXT: Command
pub const TABLE_SORT_NEXT: Command
Sort a focused Table by the next visible
column, ascending (wrapping; with no sort yet, the first visible
column). The table binds no key to it: an app maps a key to this
command (status line or keymap) if it wants keyboard sorting.
Sourcepub const TABLE_SORT_FLIP: Command
pub const TABLE_SORT_FLIP: Command
Flip the sort direction of a focused Table
on its current sort column (with no sort yet: sort the first visible
column ascending). Unbound by default, like
TABLE_SORT_NEXT.
Sourcepub const TABLE_CELL_EDITED: Command
pub const TABLE_CELL_EDITED: Command
A Table cell editor committed a new text
that the model accepted; source is the table’s ViewId. Read the
value from Table::model (or the app’s own copy of the data). An
edit committed by the command that closes a modal dialog arrives
after the dialog is gone (see Table::valid).
Sourcepub const TABLE_COLUMNS: Command
pub const TABLE_COLUMNS: Command
Open a focused Table’s column popup at its
header: every column with a check mark, choosing one shows or hides it
(the same popup a right-click on the header opens). Unbound by
default, like TABLE_SORT_NEXT.
Sourcepub const TABLE_COLUMNS_CHANGED: Command
pub const TABLE_COLUMNS_CHANGED: Command
A Table’s column layout changed through the
user (a column resized, moved, shown or hidden); source is the
table’s ViewId. Read the layout with Table::column_layout to
persist it.
Sourcepub const RECORD_HISTORY: Command
pub const RECORD_HISTORY: Command
Record the current input-line value into its history list — handled by
InputLine when it loses focus.
Program broadcasts this before routing focus away from an input line so
the line’s history list is updated even if the user did not press Enter.
Sourcepub const REVEAL_CHANGED: Command
pub const REVEAL_CHANGED: Command
Broadcast by a RevealEye when its reveal intent changes, so the owning
MaskedInput re-syncs its field’s reveal state (source = the eye’s id).
Sourcepub const REPLACE: Command
pub const REPLACE: Command
Open the find-and-replace dialog — handled by Editor; bind to Ctrl-Q/A
or Ctrl-H.
Sourcepub const SEARCH_AGAIN: Command
pub const SEARCH_AGAIN: Command
Repeat the last search from the current cursor position — handled by
Editor; bind to Ctrl-L.
Sourcepub const CHAR_LEFT: Command
pub const CHAR_LEFT: Command
Move the cursor one character left (Left arrow / Ctrl-S in WordStar mode).
Sourcepub const CHAR_RIGHT: Command
pub const CHAR_RIGHT: Command
Move the cursor one character right (Right arrow / Ctrl-D in WordStar mode).
Sourcepub const WORD_LEFT: Command
pub const WORD_LEFT: Command
Move the cursor one word left (Ctrl-Left / Ctrl-A in WordStar mode).
Sourcepub const WORD_RIGHT: Command
pub const WORD_RIGHT: Command
Move the cursor one word right (Ctrl-Right / Ctrl-F in WordStar mode).
Sourcepub const LINE_START: Command
pub const LINE_START: Command
Move the cursor to the start of the line (Home / Ctrl-Q-S).
Sourcepub const LINE_DOWN: Command
pub const LINE_DOWN: Command
Move the cursor down one line (Down arrow / Ctrl-X in WordStar mode).
Sourcepub const TEXT_START: Command
pub const TEXT_START: Command
Move the cursor to the start of the document (Ctrl-Home / Ctrl-Q-R).
Sourcepub const BACK_SPACE: Command
pub const BACK_SPACE: Command
Delete the character before the cursor (Backspace / Ctrl-H).
Sourcepub const DEL_WORD: Command
pub const DEL_WORD: Command
Delete the word at (to the right of) the cursor (Ctrl-T in WordStar mode).
Sourcepub const DEL_START: Command
pub const DEL_START: Command
Delete from the cursor to the start of the line (Ctrl-Q-Backspace).
Sourcepub const START_SELECT: Command
pub const START_SELECT: Command
Begin a keyboard selection (Ctrl-K-B).
Sourcepub const HIDE_SELECT: Command
pub const HIDE_SELECT: Command
Collapse / hide the current selection without deleting it (Ctrl-K-H).
Sourcepub const INDENT_MODE: Command
pub const INDENT_MODE: Command
Toggle auto-indent mode (Ctrl-O-I).
Sourcepub const UPDATE_TITLE: Command
pub const UPDATE_TITLE: Command
Update the editor window’s title bar — emitted by Editor after a save
or filename change so the frame rerenders the new title.
Sourcepub const SELECT_ALL: Command
pub const SELECT_ALL: Command
Select the entire document contents (Ctrl-A / Ctrl-K-K after Ctrl-K-B).
Sourcepub const DEL_WORD_LEFT: Command
pub const DEL_WORD_LEFT: Command
Delete the word to the left of the cursor (Ctrl-Backspace).
Sourcepub const FILE_REPLACE: Command
pub const FILE_REPLACE: Command
The file dialog’s Replace button.
Sourcepub const FILE_CLEAR: Command
pub const FILE_CLEAR: Command
The file dialog’s Clear button.
Sourcepub const CHANGE_DIR: Command
pub const CHANGE_DIR: Command
Confirm a directory change in the change-directory dialog.
Sourcepub const FILE_FOCUSED: Command
pub const FILE_FOCUSED: Command
A file in the file list gained focus (broadcast on every focus change; the
focused file record is carried via the broadcast’s resolvable source).
Sourcepub const FILE_DOUBLE_CLICKED: Command
pub const FILE_DOUBLE_CLICKED: Command
A file in the file list was double-clicked (broadcast). Payload-less in
tvision-rs: the file dialog just turns it into OK.
Sourcepub const OUTLINE_ITEM_SELECTED: Command
pub const OUTLINE_ITEM_SELECTED: Command
An outline-viewer item was selected — broadcast by
Outline when the user presses Enter or
double-clicks a node.
source is the Outline’s ViewId. Listen for this broadcast in a parent
or sibling to react to node activation (e.g. open the selected item). The
selected node is the one at OutlineViewerState::foc; resolve the outline’s
ViewId to read it.
§Turbo Vision heritage
Ports cmOutlineItemSelected (outline.h).
Sourcepub const THEME_EDIT_FG: Command
pub const THEME_EDIT_FG: Command
Open the foreground color picker for the selected theme role (tvision-rs-native).
Sourcepub const THEME_EDIT_BG: Command
pub const THEME_EDIT_BG: Command
Open the background color picker for the selected theme role (tvision-rs-native).
Sourcepub const fn custom(name: &'static str) -> Command
pub const fn custom(name: &'static str) -> Command
Mint an application- or view-specific command from a namespaced name.
The escape hatch external code uses to define its own commands; pick a
dotted prefix unique to your app/view ("myapp.refresh") so it cannot
collide with the framework’s tv.* vocabulary or another extension’s.
Trait Implementations§
Source§impl AddAssign<Command> for CommandSet
set += cmd — add a single command (equivalent to enable_cmd /
insert). Use this operator when building a set incrementally:
let mut s = CommandSet::new(); s += Command::CUT; s += Command::COPY;
impl AddAssign<Command> for CommandSet
set += cmd — add a single command (equivalent to enable_cmd /
insert). Use this operator when building a set incrementally:
let mut s = CommandSet::new(); s += Command::CUT; s += Command::COPY;
Source§fn add_assign(&mut self, cmd: Command)
fn add_assign(&mut self, cmd: Command)
+= operation. Read moreimpl Copy for Command
impl Eq for Command
impl StructuralPartialEq for Command
Source§impl SubAssign<Command> for CommandSet
set -= cmd — remove a single command (equivalent to disable_cmd /
remove). Use to revoke a single command from an enabled set or to
unblock a single command from a denylist.
impl SubAssign<Command> for CommandSet
set -= cmd — remove a single command (equivalent to disable_cmd /
remove). Use to revoke a single command from an enabled set or to
unblock a single command from a denylist.
Source§fn sub_assign(&mut self, cmd: Command)
fn sub_assign(&mut self, cmd: Command)
-= operation. Read moreAuto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnsafeUnpin for Command
impl UnwindSafe for Command
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.