From 579b6899f1fe7f0a06857c4528f55f316e2975e9 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sat, 5 Sep 2020 22:01:05 +0900 Subject: Work on insert mode. --- helix-core/src/state.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'helix-core/src/state.rs') 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. -- cgit v1.2.3-70-g09d2