Skip to main content

Command

Struct Command 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub const PASTE: Command

Paste from the clipboard (Shift-Ins / Ctrl-V).

Handled by Editor / Memo. Place in a standard Edit menu.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const SAVE_ALL: Command

Save all open documents — emit from “Save All”.

Your application handles this; disable when no modified documents are open.

Source

pub const CH_DIR: Command

Change the working directory — opens the change-directory dialog.

Handled by the standard ChDirDialog when your application routes it.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub const SCROLL_BAR_CLICKED: Command

A scroll bar arrow or page region was clicked — broadcast by ScrollBar to trigger a single scroll step.

Source

pub const TAB_BAR_CHANGED: Command

Broadcast by a TabBar when its selected tab changes; carries the bar’s own ViewId as the broadcast source so a sibling PageStack can tell which bar fired (the D3/D4 pattern, mirroring SCROLL_BAR_CHANGED).

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub const FIND: Command

Open the find dialog — handled by Editor; bind to Ctrl-Q/F or Ctrl-F.

Source

pub const REPLACE: Command

Open the find-and-replace dialog — handled by Editor; bind to Ctrl-Q/A or Ctrl-H.

Source

pub const SEARCH_AGAIN: Command

Repeat the last search from the current cursor position — handled by Editor; bind to Ctrl-L.

Source

pub const CHAR_LEFT: Command

Move the cursor one character left (Left arrow / Ctrl-S in WordStar mode).

Source

pub const CHAR_RIGHT: Command

Move the cursor one character right (Right arrow / Ctrl-D in WordStar mode).

Source

pub const WORD_LEFT: Command

Move the cursor one word left (Ctrl-Left / Ctrl-A in WordStar mode).

Source

pub const WORD_RIGHT: Command

Move the cursor one word right (Ctrl-Right / Ctrl-F in WordStar mode).

Source

pub const LINE_START: Command

Move the cursor to the start of the line (Home / Ctrl-Q-S).

Source

pub const LINE_END: Command

Move the cursor to the end of the line (End / Ctrl-Q-D).

Source

pub const LINE_UP: Command

Move the cursor up one line (Up arrow / Ctrl-E in WordStar mode).

Source

pub const LINE_DOWN: Command

Move the cursor down one line (Down arrow / Ctrl-X in WordStar mode).

Source

pub const PAGE_UP: Command

Scroll up one page (PgUp / Ctrl-R in WordStar mode).

Source

pub const PAGE_DOWN: Command

Scroll down one page (PgDn / Ctrl-C in WordStar mode).

Source

pub const TEXT_START: Command

Move the cursor to the start of the document (Ctrl-Home / Ctrl-Q-R).

Source

pub const TEXT_END: Command

Move the cursor to the end of the document (Ctrl-End / Ctrl-Q-C).

Source

pub const NEW_LINE: Command

Insert a line break at the cursor position (Enter).

Source

pub const BACK_SPACE: Command

Delete the character before the cursor (Backspace / Ctrl-H).

Source

pub const DEL_CHAR: Command

Delete the character at the cursor position (Delete / Ctrl-G).

Source

pub const DEL_WORD: Command

Delete the word at (to the right of) the cursor (Ctrl-T in WordStar mode).

Source

pub const DEL_START: Command

Delete from the cursor to the start of the line (Ctrl-Q-Backspace).

Source

pub const DEL_END: Command

Delete from the cursor to the end of the line (Ctrl-Q-Y).

Source

pub const DEL_LINE: Command

Delete the current line (Ctrl-Y).

Source

pub const INS_MODE: Command

Toggle insert / overwrite mode (Ins key).

Source

pub const START_SELECT: Command

Begin a keyboard selection (Ctrl-K-B).

Source

pub const HIDE_SELECT: Command

Collapse / hide the current selection without deleting it (Ctrl-K-H).

Source

pub const INDENT_MODE: Command

Toggle auto-indent mode (Ctrl-O-I).

Source

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.

Source

pub const SELECT_ALL: Command

Select the entire document contents (Ctrl-A / Ctrl-K-K after Ctrl-K-B).

Source

pub const DEL_WORD_LEFT: Command

Delete the word to the left of the cursor (Ctrl-Backspace).

Source

pub const ENCODING: Command

Change the text encoding of the current editor document.

Source

pub const FILE_OPEN: Command

The file dialog’s Open button.

Source

pub const FILE_REPLACE: Command

The file dialog’s Replace button.

Source

pub const FILE_CLEAR: Command

The file dialog’s Clear button.

Source

pub const FILE_INIT: Command

Re-read the file dialog’s directory listing.

Source

pub const CHANGE_DIR: Command

Confirm a directory change in the change-directory dialog.

Source

pub const REVERT: Command

Revert the change-directory dialog to the current directory.

Source

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).

Source

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.

Source

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).

Source

pub const THEME_EDIT_FG: Command

Open the foreground color picker for the selected theme role (tvision-rs-native).

Source

pub const THEME_EDIT_BG: Command

Open the background color picker for the selected theme role (tvision-rs-native).

Source

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.

Source

pub const fn name(self) -> &'static str

The command’s namespaced name (e.g. "tv.ok").

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;

Source§

fn add_assign(&mut self, cmd: Command)

Performs the += operation. Read more
Source§

impl Clone for Command

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Command

Source§

impl Debug for Command

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Command

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Command

Source§

impl Hash for Command

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Command

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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.

Source§

fn sub_assign(&mut self, cmd: Command)

Performs the -= operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomValue for T
where T: Any + Debug,

Source§

fn as_any_rc(self: Rc<T>) -> Rc<dyn Any>

Upcast Rc<Self> to Rc<dyn Any> so FieldValue::as_custom / FieldValue::value_as can downcast.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.