summaryrefslogtreecommitdiff
path: root/helix-core/src/state.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-09-05 13:01:05 +0000
committerBlaž Hrastnik2020-09-07 02:21:26 +0000
commit579b6899f1fe7f0a06857c4528f55f316e2975e9 (patch)
tree1b850ba7f2abc1698763fc55cf7eebdad0fe9c8f /helix-core/src/state.rs
parente806446379db3f5c7e3bc6fd823ddd6969ed6f32 (diff)
Work on insert mode.
Diffstat (limited to 'helix-core/src/state.rs')
-rw-r--r--helix-core/src/state.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/helix-core/src/state.rs b/helix-core/src/state.rs
index 9c227a92..8568c3c3 100644
--- a/helix-core/src/state.rs
+++ b/helix-core/src/state.rs
@@ -1,10 +1,16 @@
use crate::graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary, RopeGraphemes};
use crate::{Buffer, Rope, RopeSlice, Selection, SelectionRange};
+pub enum Mode {
+ Normal,
+ Insert,
+}
+
/// A state represents the current editor state of a single buffer.
pub struct State {
pub doc: Buffer,
pub selection: Selection,
+ pub mode: Mode,
}
#[derive(Copy, Clone, PartialEq, Eq)]
@@ -26,6 +32,7 @@ impl State {
Self {
doc,
selection: Selection::single(0, 0),
+ mode: Mode::Normal,
}
}
@@ -119,10 +126,15 @@ impl State {
// TODO: update selection in state via transaction
}
- pub fn file(&self) -> &Rope {
+ pub fn contents(&self) -> &Rope {
// used to access file contents for rendering to screen
&self.doc.contents
}
+
+ pub fn contents_mut(&mut self) -> &mut Rope {
+ // used to access file contents for rendering to screen
+ &mut self.doc.contents
+ }
}
/// Coordinates are a 0-indexed line and column pair.