on master help sign in
added file rendering
commit8958f06f0824965d030adc7522303129da014315 authorJan Hrastnik <jan.hrastnik2@gmail.com> dateTue 16 Jun 2020, 22:46 (6 years ago) parent8119f1e
3 files changed+15−1
helix-core/src/state.rs+6 helix-term/src/editor.rs+6−1 helix-term/test.txt+3
helix-core/src/state.rs+6
@@ -117,6 +117,12 @@ impl State {
117117 Selection::new(ranges.collect(), sel.primary_index)
118118 // TODO: update selection in state via transaction
119119 }
120+
121+ pub fn file(&self) -> &Rope {
122+ // used to access file contents for rendering to screen
123+ let copy = &self.doc.contents;
124+ copy
125+ }
120126}
121127
122128/// Coordinates are a 0-indexed line and column pair.
helix-term/src/editor.rs+6−1
@@ -2,7 +2,8 @@ use crossterm::{
22 cursor,
33 cursor::position,
44 event::{self, read, Event, EventStream, KeyCode, KeyEvent},
5− execute, queue, style,
5+ execute, queue,
6+ style::Print,
67 terminal::{self, disable_raw_mode, enable_raw_mode},
78};
89use futures::{future::FutureExt, select, StreamExt};
@@ -39,6 +40,10 @@ impl Editor {
3940
4041 fn render(&self) {
4142 // TODO:
43+ match &self.state {
44+ Some(s) => execute!(stdout(), cursor::MoveTo(0, 0), Print(s.file())).unwrap(),
45+ None => (),
46+ }
4247 }
4348
4449 pub async fn print_events(&mut self) {
helix-term/test.txtnew file+3
@@ -0,0 +1,3 @@
1+aaa
2+bbb
3+ccc