Flesh out the editor example a bit more
This commit is contained in:
parent
8446fe6de5
commit
e7326f0af6
10 changed files with 311 additions and 27 deletions
|
|
@ -125,6 +125,10 @@ impl text::Editor for () {
|
|||
text::editor::Cursor::Caret(Point::ORIGIN)
|
||||
}
|
||||
|
||||
fn cursor_position(&self) -> (usize, usize) {
|
||||
(0, 0)
|
||||
}
|
||||
|
||||
fn selection(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ pub trait Editor: Sized + Default {
|
|||
|
||||
fn cursor(&self) -> Cursor;
|
||||
|
||||
fn cursor_position(&self) -> (usize, usize);
|
||||
|
||||
fn selection(&self) -> Option<String>;
|
||||
|
||||
fn line(&self, index: usize) -> Option<&str>;
|
||||
|
|
@ -52,6 +54,12 @@ pub enum Action {
|
|||
Drag(Point),
|
||||
}
|
||||
|
||||
impl Action {
|
||||
pub fn is_edit(&self) -> bool {
|
||||
matches!(self, Self::Edit(_))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Edit {
|
||||
Insert(char),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue