pub trait Operator: Send + Sync {
// Required methods
fn id(&self) -> &'static str;
fn execute(
&self,
ctx: &mut OperatorContext<'_>,
range: Range,
) -> Result<(), OperatorError>;
// Provided methods
fn is_linewise(&self) -> bool { ... }
fn is_text_modifying(&self) -> bool { ... }
}Expand description
Operators execute actions on text ranges.
- Mechanism (Kernel): Range calculation, text manipulation APIs
- Policy (Module): What each operator does with the range
§Examples
delete- Remove text in range, save to registeryank- Copy text in range to registerchange- Delete text and enter insert modeindent- Increase indentation of lines in range
Required Methods§
Sourcefn execute(
&self,
ctx: &mut OperatorContext<'_>,
range: Range,
) -> Result<(), OperatorError>
fn execute( &self, ctx: &mut OperatorContext<'_>, range: Range, ) -> Result<(), OperatorError>
Provided Methods§
Sourcefn is_linewise(&self) -> bool
fn is_linewise(&self) -> bool
Whether this operator works on whole lines (dd, yy).
Linewise operators extend the range to include full lines.
Sourcefn is_text_modifying(&self) -> bool
fn is_text_modifying(&self) -> bool
Whether this operator modifies text.
Used for undo grouping - modifying operators create checkpoints.