aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src/state.rs')
-rw-r--r--helix-core/src/state.rs32
1 files changed, 28 insertions, 4 deletions
diff --git a/helix-core/src/state.rs b/helix-core/src/state.rs
index be2b3317..e41ee565 100644
--- a/helix-core/src/state.rs
+++ b/helix-core/src/state.rs
@@ -4,6 +4,7 @@ use anyhow::Error;
use std::path::PathBuf;
+#[derive(Copy, Clone)]
pub enum Mode {
Normal,
Insert,
@@ -12,10 +13,10 @@ pub enum Mode {
/// A state represents the current editor state of a single buffer.
pub struct State {
/// Path to file on disk.
- pub path: Option<PathBuf>,
- pub doc: Rope,
- pub selection: Selection,
- pub mode: Mode,
+ pub(crate) path: Option<PathBuf>,
+ pub(crate) doc: Rope,
+ pub(crate) selection: Selection,
+ pub(crate) mode: Mode,
}
#[derive(Copy, Clone, PartialEq, Eq)]
@@ -58,6 +59,29 @@ impl State {
// TODO: doc/selection accessors
+ // TODO: be able to take either Rope or RopeSlice
+ #[inline]
+ pub fn doc(&self) -> &Rope {
+ &self.doc
+ }
+
+ #[inline]
+ pub fn selection(&self) -> &Selection {
+ &self.selection
+ }
+
+ #[inline]
+ pub fn mode(&self) -> Mode {
+ self.mode
+ }
+
+ // pub fn doc<R>(&self, range: R) -> RopeSlice
+ // where
+ // R: std::ops::RangeBounds<usize>,
+ // {
+ // self.doc.slice(range)
+ // }
+
// update/transact:
// update(desc) => transaction ? transaction.doc() for applied doc
// transaction.apply(doc)