diff options
author | 2023-09-16 15:27:25 +0200 | |
---|---|---|
committer | 2023-09-16 15:27:25 +0200 | |
commit | c6d0443627c22dcf1576303e5a426aa3622f1b7d (patch) | |
tree | 13d0b2a4d3378065709a7d81f6c54ea8edb10e77 /core/src | |
parent | f7fc13d98c52a9260b1ab55394a0c3d2693318ed (diff) | |
download | iced-c6d0443627c22dcf1576303e5a426aa3622f1b7d.tar.gz iced-c6d0443627c22dcf1576303e5a426aa3622f1b7d.tar.bz2 iced-c6d0443627c22dcf1576303e5a426aa3622f1b7d.zip |
Implement methods to query the contents of a `TextEditor`
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/renderer/null.rs | 12 | ||||
-rw-r--r-- | core/src/text/editor.rs | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs index e714e492..01a52c7a 100644 --- a/core/src/renderer/null.rs +++ b/core/src/renderer/null.rs @@ -125,6 +125,18 @@ impl text::Editor for () { text::editor::Cursor::Caret(Point::ORIGIN) } + fn selection(&self) -> Option<String> { + None + } + + fn line(&self, _index: usize) -> Option<&str> { + None + } + + fn line_count(&self) -> usize { + 0 + } + fn perform(&mut self, _action: text::editor::Action) {} fn bounds(&self) -> Size { diff --git a/core/src/text/editor.rs b/core/src/text/editor.rs index 56cda3ef..5532fac5 100644 --- a/core/src/text/editor.rs +++ b/core/src/text/editor.rs @@ -9,6 +9,12 @@ pub trait Editor: Sized + Default { fn cursor(&self) -> Cursor; + fn selection(&self) -> Option<String>; + + fn line(&self, index: usize) -> Option<&str>; + + fn line_count(&self) -> usize; + fn perform(&mut self, action: Action); /// Returns the current boundaries of the [`Editor`]. |