pub struct CommandSet { /* private fields */ }Expand description
A set of commands the framework enables or disables in bulk.
The command space is open/unbounded (commands are namespaced strings,
not 0..=255), so there is no trackable-range guard and no all()
constructor — “all commands” is not enumerable. The set itself is
polarity-neutral; the framework’s enabled-by-default policy lives in
Program, which keeps its current set as the complement —
a disabled set (a denylist). The enable_cmd/disable_cmd methods mean
insert/remove regardless of which polarity a particular owner stores; the
polarity-neutral insert / remove aliases
are preferred at sites where the set’s meaning is not “enabled commands” (e.g.
the disabled set).
§Turbo Vision heritage
Ports TCommandSet (views.h, tcmdset.cpp); the 256-bit array becomes a
HashSet<Command> (deviation D1).
Implementations§
Source§impl CommandSet
impl CommandSet
Sourcepub fn new() -> Self
pub fn new() -> Self
Build an empty command set.
The returned set contains no commands. Populate it incrementally with
enable_cmd / insert or the +=
operator, or use it as the start of a denylist by calling
disable_cmd / insert for each
command that should be blocked.
Sourcepub fn has(&self, cmd: Command) -> bool
pub fn has(&self, cmd: Command) -> bool
Test whether cmd is a member of this set.
Returns true when the command was previously added and not yet
removed. On a disabled set (denylist) the result means the command
is blocked; on an enabled set it means the command is active — the
interpretation depends on the set’s role, not this method.
Use contains at new call sites as the idiomatic
Rust name; use has when mirroring the C++ TCommandSet::has call.
Sourcepub fn contains(&self, cmd: Command) -> bool
pub fn contains(&self, cmd: Command) -> bool
Idiomatic alias for has — follows Rust collection
convention (HashSet::contains). Prefer this name at new call sites.
Sourcepub fn enable_cmd(&mut self, cmd: Command)
pub fn enable_cmd(&mut self, cmd: Command)
Add cmd to this set (semantic name: enable the command).
When self is an enabled set, this marks the command as enabled
and it will pass the framework’s enabled-command check. When self is
a disabled set (denylist — the pattern Program
uses internally), prefer the polarity-neutral
insert alias to avoid misleading code.
The += operator (AddAssign<Command>) is equivalent.
Sourcepub fn disable_cmd(&mut self, cmd: Command)
pub fn disable_cmd(&mut self, cmd: Command)
Remove cmd from this set (semantic name: disable the command).
When self is an enabled set, this marks the command as disabled
so it will be greyed out in menus and rejected by status-line items.
When self is a disabled set (denylist), prefer the
polarity-neutral remove alias instead.
The -= operator (SubAssign<Command>) is equivalent.
Sourcepub fn insert(&mut self, cmd: Command)
pub fn insert(&mut self, cmd: Command)
Polarity-neutral alias for enable_cmd: add cmd
to the set.
Prefer insert over enable_cmd when the set’s meaning is not “which
commands are currently enabled” — for example, when building a denylist
of blocked commands, disabled.insert(cmd) is clearer than
disabled.enable_cmd(cmd).
Sourcepub fn remove(&mut self, cmd: Command)
pub fn remove(&mut self, cmd: Command)
Polarity-neutral alias for disable_cmd: remove
cmd from the set.
Prefer remove over disable_cmd at denylist sites — see
insert for the naming rationale.
Sourcepub fn enable_set(&mut self, other: &CommandSet)
pub fn enable_set(&mut self, other: &CommandSet)
Add every command in other to this set (set union).
After this call, self contains every command it previously held plus
every command in other. Use to merge two enabled sets, or to
re-enable a batch of commands at a denylist site (remove them from the
blocked list by calling disabled.disable_set(&to_restore)).
The += / |= operators (AddAssign<&CommandSet> /
BitOrAssign<&CommandSet>) are equivalent.
Sourcepub fn disable_set(&mut self, other: &CommandSet)
pub fn disable_set(&mut self, other: &CommandSet)
Remove every command in other from this set (set difference).
After this call, self no longer contains any command that appears in
other. Use to suppress a batch of commands in an enabled set, or to
block a batch of commands by adding them to a denylist.
The -= operator (SubAssign<&CommandSet>) is equivalent.
Trait Implementations§
Source§impl AddAssign<&CommandSet> for CommandSet
set += other — add every command in other (set union, equivalent to
enable_set). Idiomatic C++ Pascal set + operator.
impl AddAssign<&CommandSet> for CommandSet
set += other — add every command in other (set union, equivalent to
enable_set). Idiomatic C++ Pascal set + operator.
Source§fn add_assign(&mut self, other: &CommandSet)
fn add_assign(&mut self, other: &CommandSet)
+= operation. Read moreSource§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 moreSource§impl BitAndAssign<&CommandSet> for CommandSet
set &= other — set intersection: retains only commands present in both
self and other. Equivalent to the Pascal * operator on sets. Use when
you need the overlap of two command sets — for example, to find which commands
are enabled in all active views simultaneously.
impl BitAndAssign<&CommandSet> for CommandSet
set &= other — set intersection: retains only commands present in both
self and other. Equivalent to the Pascal * operator on sets. Use when
you need the overlap of two command sets — for example, to find which commands
are enabled in all active views simultaneously.
Source§fn bitand_assign(&mut self, other: &CommandSet)
fn bitand_assign(&mut self, other: &CommandSet)
&= operation. Read moreSource§impl BitOrAssign<&CommandSet> for CommandSet
set |= other — set union (alias for += other); same as
enable_set. The |= spelling emphasizes
the Boolean-OR semantics over the Pascal-add semantics.
impl BitOrAssign<&CommandSet> for CommandSet
set |= other — set union (alias for += other); same as
enable_set. The |= spelling emphasizes
the Boolean-OR semantics over the Pascal-add semantics.
Source§fn bitor_assign(&mut self, other: &CommandSet)
fn bitor_assign(&mut self, other: &CommandSet)
|= operation. Read moreSource§impl Clone for CommandSet
impl Clone for CommandSet
Source§impl Debug for CommandSet
impl Debug for CommandSet
Source§impl Default for CommandSet
impl Default for CommandSet
impl Eq for CommandSet
Source§impl PartialEq for CommandSet
impl PartialEq for CommandSet
impl StructuralPartialEq for CommandSet
Source§impl SubAssign<&CommandSet> for CommandSet
set -= other — remove every command in other (set difference, equivalent to
disable_set). Idiomatic C++ Pascal set - operator.
impl SubAssign<&CommandSet> for CommandSet
set -= other — remove every command in other (set difference, equivalent to
disable_set). Idiomatic C++ Pascal set - operator.
Source§fn sub_assign(&mut self, other: &CommandSet)
fn sub_assign(&mut self, other: &CommandSet)
-= operation. Read moreSource§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 CommandSet
impl RefUnwindSafe for CommandSet
impl Send for CommandSet
impl Sync for CommandSet
impl Unpin for CommandSet
impl UnsafeUnpin for CommandSet
impl UnwindSafe for CommandSet
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.