#[non_exhaustive]pub enum Message {
Show 92 variants
CharacterInput(char),
VimKey(char),
ToggleVimMode,
WriteRequested,
Backspace,
Delete,
Enter,
Tab,
Backtab,
ArrowKey(ArrowDirection, bool),
MouseClick(Point),
MouseDrag(Point),
MouseHover(Point),
MouseRelease,
SelectionAutoScroll(f32),
DoubleClick(Point),
TripleClick(Point),
ContextMenuRequested(Point),
CustomContextMenuAction(String),
RevealInFileManager,
Cut,
Copy,
Paste(String),
DeleteSelection,
SelectAll,
Tick,
PageUp(bool),
PageDown(bool),
Home(bool),
End(bool),
CtrlHome,
CtrlEnd,
WordLeft(bool),
WordRight(bool),
DeleteWordBack,
DeleteWordForward,
GotoPosition(usize, usize),
OpenGotoLine,
CloseGotoLine,
GotoLineChanged(String),
SubmitGotoLine,
OpenCommandPalette,
CloseCommandPalette,
CommandPaletteChanged(String),
CommandPaletteNavigate(bool),
CommandPaletteSelected(usize),
SubmitCommandPalette,
CommandPaletteAction(String),
Scrolled(Viewport),
HorizontalScrolled(Viewport),
Undo,
Redo,
OpenSearch,
OpenSearchReplace,
CloseSearch,
SearchQueryChanged(String),
ReplaceQueryChanged(String),
ToggleCaseSensitive,
ToggleWholeWord,
ToggleSearchRegex,
ToggleSearchMultiline,
ToggleSearchReplace,
SearchInputAction(Action),
ReplaceInputAction(Action),
SelectAllSearchMatches,
FindNext,
FindPrevious,
ReplaceNext,
ReplaceAll,
SearchDialogTab,
SearchDialogShiftTab,
CanvasFocusGained,
CanvasFocusLost,
JumpClick(Point),
ImeOpened,
ImePreedit(String, Option<Range<usize>>),
ImeCommit(String),
ImeClosed,
AltClick(Point),
AddCursorAbove,
AddCursorBelow,
SelectNextOccurrence,
ToggleFold(usize),
ToggleFoldAtCursor,
FoldAll,
UnfoldAll,
MoveLineUp,
MoveLineDown,
DuplicateLineUp,
DuplicateLineDown,
ToggleComment,
StickyScrollJump(usize),
}Expand description
Messages emitted by the code editor
A host application forwards these to CodeEditor::update. They are also
the programmatic control surface: sending a variant directly performs the
same action as the user gesture that would normally produce it, which is
how a host wires its own menu items and toolbar buttons to editor commands.
§Examples
use iced_code_editor::{CodeEditor, Message};
let mut editor = CodeEditor::new("hello", "rs");
// Drive an edit as if the user had pasted.
let _ = editor.update(&Message::Paste(" world".to_string()));
assert_eq!(editor.content(), " worldhello");
// And undo it the same way a menu item would.
let _ = editor.update(&Message::Undo);
assert_eq!(editor.content(), "hello");The enum is #[non_exhaustive]: new editor features add variants, so a
host match on it must keep a wildcard arm, typically forwarding the
message back to CodeEditor::update.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
CharacterInput(char)
Character typed
VimKey(char)
A printable key interpreted by the Vim state machine.
ToggleVimMode
Toggle Vim behavior for this editor instance.
WriteRequested
Requests that the host save this editor’s current document.
Backspace
Backspace pressed
Delete
Delete pressed
Enter
Enter pressed
Tab
Tab pressed (inserts 4 spaces)
Backtab
Shift + Tab pressed (removes 4 spaces)
ArrowKey(ArrowDirection, bool)
Arrow key pressed (direction, shift_pressed)
MouseClick(Point)
Mouse clicked at position
MouseDrag(Point)
Mouse drag for selection
MouseHover(Point)
Mouse moved within the editor without dragging
MouseRelease
Mouse released
SelectionAutoScroll(f32)
Advances edge scrolling during an active selection drag.
DoubleClick(Point)
Double-click: select the word under the cursor
TripleClick(Point)
Triple-click: select the whole line under the cursor
ContextMenuRequested(Point)
Right-clicked in the editor to position and open the context menu
CustomContextMenuAction(String)
A configured context-menu action was selected.
RevealInFileManager
Requests that the host reveal the editor’s file in the system file manager.
Cut
Cut selected text
Copy
Copy selected text (Ctrl+C)
Paste(String)
Paste text from clipboard (Ctrl+V)
DeleteSelection
Delete selected text (Shift+Delete)
SelectAll
Select the complete document
Tick
Request redraw for cursor blink
PageUp(bool)
Page Up pressed (move up one page, shift_pressed)
PageDown(bool)
Page Down pressed (move down one page, shift_pressed)
Home(bool)
Home key pressed (shift_pressed): move to the first non-blank character of the line, or to column 0 when already there
End(bool)
End key pressed (move to end of line, shift_pressed)
CtrlHome
Ctrl+Home pressed (move to start of document)
CtrlEnd
Ctrl+End pressed (move to end of document)
WordLeft(bool)
Ctrl+Left (Alt+Left on macOS): move one word left (shift_pressed)
WordRight(bool)
Ctrl+Right (Alt+Right on macOS): move one word right (shift_pressed)
DeleteWordBack
Ctrl+Backspace (Alt+Backspace on macOS): delete the word before the cursor (or the selection, if there is one)
DeleteWordForward
Ctrl+Delete (Alt+Delete on macOS): delete the word after the cursor (or the selection, if there is one)
GotoPosition(usize, usize)
Go to an explicit logical position (line, column), both 0-based.
OpenGotoLine
Open the go-to-line dialog (Cmd/Ctrl+G).
CloseGotoLine
Close the go-to-line dialog.
GotoLineChanged(String)
Change the one-based line number shown in the go-to-line input.
SubmitGotoLine
Submit the current go-to-line input.
OpenCommandPalette
Open the command palette (Cmd/Ctrl+Shift+P).
CloseCommandPalette
Close the command palette without running anything.
CommandPaletteChanged(String)
Change the filter text typed in the command palette.
Move the command palette highlight one row down (true) or up.
CommandPaletteSelected(usize)
Highlight the command palette row at this index and run it.
SubmitCommandPalette
Run the currently highlighted command palette row.
CommandPaletteAction(String)
A host-registered command palette entry was run, identified by the
id it was registered with. The editor never acts on this itself:
handle it in the host application.
Scrolled(Viewport)
Viewport scrolled - track scroll position
HorizontalScrolled(Viewport)
Horizontal scrollbar scrolled (only when wrap is disabled)
Undo
Undo last operation (Ctrl+Z)
Redo
Redo last undone operation (Ctrl+Y)
OpenSearch
Open search dialog (Ctrl+F)
OpenSearchReplace
Open search and replace dialog (Ctrl+H)
CloseSearch
Close search dialog (Escape)
SearchQueryChanged(String)
Search query text changed
ReplaceQueryChanged(String)
Replace text changed
ToggleCaseSensitive
Toggle case sensitivity
ToggleWholeWord
Toggle whole-word matching.
ToggleSearchRegex
Toggle regular expression matching.
ToggleSearchMultiline
Expand or collapse multiline search inputs.
ToggleSearchReplace
Show or hide the replacement row.
SearchInputAction(Action)
Edit the multiline query.
ReplaceInputAction(Action)
Edit the multiline replacement.
SelectAllSearchMatches
Turn every search match into an editable selection (Alt+Enter).
FindNext
Find next match (F3)
FindPrevious
Find previous match (Shift+F3)
ReplaceNext
Replace current match
ReplaceAll
Replace all matches
SearchDialogTab
Tab pressed in search dialog (cycle forward)
SearchDialogShiftTab
Shift+Tab pressed in search dialog (cycle backward)
CanvasFocusGained
Canvas gained focus (mouse click)
CanvasFocusLost
Canvas lost focus (external widget interaction)
JumpClick(Point)
Triggered when the user performs a Ctrl+Click (or Cmd+Click on macOS) on the editor content, intending to jump to the definition of the symbol under the cursor.
ImeOpened
IME input method opened
ImePreedit(String, Option<Range<usize>>)
IME pre-edit update (content, selection range)
ImeCommit(String)
IME commit text
ImeClosed
IME input method closed
AltClick(Point)
Alt+Click: add a new cursor at the given canvas position
AddCursorAbove
Ctrl+Alt+Up: add a cursor on the line above the primary cursor
AddCursorBelow
Ctrl+Alt+Down: add a cursor on the line below the primary cursor
SelectNextOccurrence
Ctrl+D: select the next occurrence of the currently selected text (or word under cursor)
ToggleFold(usize)
Toggle the collapsed state of the fold whose header is the given logical line.
ToggleFoldAtCursor
Toggle the collapsed state of the innermost block containing the primary cursor.
FoldAll
Fold every foldable block in the buffer.
UnfoldAll
Unfold every collapsed block in the buffer.
MoveLineUp
Alt+Up: move the current line (or selected line range) up by one line.
MoveLineDown
Alt+Down: move the current line (or selected line range) down by one line.
DuplicateLineUp
Shift+Alt+Up: duplicate the current line (or selected line range) above.
DuplicateLineDown
Shift+Alt+Down: duplicate the current line (or selected line range) below.
ToggleComment
Ctrl+/: toggle line comments on the current line or primary selection.
StickyScrollJump(usize)
Scroll back to the given logical line, whose sticky-scroll header was clicked.
Trait Implementations§
Source§impl Program<Message> for CodeEditor
impl Program<Message> for CodeEditor
Source§fn draw(
&self,
_state: &Self::State,
renderer: &Renderer,
_theme: &Theme,
bounds: Rectangle,
_cursor: Cursor,
) -> Vec<Geometry>
fn draw( &self, _state: &Self::State, renderer: &Renderer, _theme: &Theme, bounds: Rectangle, _cursor: Cursor, ) -> Vec<Geometry>
Renders the code editor’s visual elements on the canvas, including text layout, syntax highlighting, cursor positioning, and other graphical aspects.
§Arguments
state- The current state of the canvasrenderer- The renderer used for drawingtheme- The theme for stylingbounds- The rectangle bounds of the canvascursor- The mouse cursor position
§Returns
A vector of Geometry objects representing the drawn elements
Source§fn update(
&self,
state: &mut Self::State,
event: &Event,
bounds: Rectangle,
cursor: Cursor,
) -> Option<Action<Message>>
fn update( &self, state: &mut Self::State, event: &Event, bounds: Rectangle, cursor: Cursor, ) -> Option<Action<Message>>
Handles Canvas trait events, specifically keyboard input events and focus management for the code editor widget.
§Arguments
_state- The mutable state of the canvas (unused in this implementation)event- The input event to handle, such as keyboard pressesbounds- The rectangle bounds of the canvas widgetcursor- The current mouse cursor position and status
§Returns
An optional Action<Message> to perform, such as sending a message or redrawing the canvas
Source§fn mouse_interaction(
&self,
_state: &Self::State,
bounds: Rectangle,
cursor: Cursor,
) -> Interaction
fn mouse_interaction( &self, _state: &Self::State, bounds: Rectangle, cursor: Cursor, ) -> Interaction
Uses the text-selection cursor over the editable code area.
The gutter keeps the default cursor, except for an interactive fold
chevron. Checking the cursor against bounds is important because a
canvas program’s interaction can otherwise remain active out of bounds.
Auto Trait Implementations§
impl Forget for Message
impl Freeze for Message
impl Move for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.