on master help sign in
added file rendering
8958f06Jan Hrastnik
helix-core/src/state.rs+6
@@ -117,6 +117,12 @@ impl State {
117 Selection::new(ranges.collect(), sel.primary_index)
117 Selection::new(ranges.collect(), sel.primary_index)
118 // TODO: update selection in state via transaction
118 // TODO: update selection in state via transaction
119 }
119 }
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+ }
120}
126}
121
127
122/// Coordinates are a 0-indexed line and column pair.
128/// Coordinates are a 0-indexed line and column pair.
helix-term/src/editor.rs+6−1
@@ -2,7 +2,8 @@ use crossterm::{
2 cursor,
2 cursor,
3 cursor::position,
3 cursor::position,
4 event::{self, read, Event, EventStream, KeyCode, KeyEvent},
4 event::{self, read, Event, EventStream, KeyCode, KeyEvent},
5− execute, queue, style,
5+ execute, queue,
6+ style::Print,
6 terminal::{self, disable_raw_mode, enable_raw_mode},
7 terminal::{self, disable_raw_mode, enable_raw_mode},
7};
8};
8use futures::{future::FutureExt, select, StreamExt};
9use futures::{future::FutureExt, select, StreamExt};
@@ -39,6 +40,10 @@ impl Editor {
39
40
40 fn render(&self) {
41 fn render(&self) {
41 // TODO:
42 // TODO:
43+ match &self.state {
44+ Some(s) => execute!(stdout(), cursor::MoveTo(0, 0), Print(s.file())).unwrap(),
45+ None => (),
46+ }
42 }
47 }
43
48
44 pub async fn print_events(&mut self) {
49 pub async fn print_events(&mut self) {
helix-term/test.txtnew file+3
@@ -0,0 +1,3 @@
1+aaa
2+bbb
3+ccc