@@ -16,13 +16,35 @@ use anyhow::Error;
16use crate::{keymap, Args};
16use crate::{keymap, Args};
17use helix_core::{Buffer, State};
17use helix_core::{Buffer, State};
26+ pub fn render(&self) {
29+ cursor::MoveTo(self.x, self.y),
19pub struct Editor {
35pub struct Editor {
20 state: Option<State>,
36 state: Option<State>,
23impl Editor {
41impl Editor {
24 pub fn new(mut args: Args) -> Result<Self, Error> {
42 pub fn new(mut args: Args) -> Result<Self, Error> {
25− let mut editor = Editor { state: None };
43+ let mut editor = Editor {
46+ size: terminal::size().unwrap(),
27 if let Some(file) = args.files.pop() {
49 if let Some(file) = args.files.pop() {
28 editor.open(file)?;
50 editor.open(file)?;
@@ -38,10 +60,25 @@ impl Editor {
41− fn render(&self) {
63+ fn render(&mut self) {
43 match &self.state {
66 match &self.state {
44− Some(s) => execute!(stdout(), cursor::MoveTo(0, 0), Print(s.file())).unwrap(),
67+ Some(s) => {
70+ .lines_at(self.current_line as usize)
71+ .take(self.size.1 as usize)
75+ y: self.current_line,
76+ contents: line.as_str().unwrap(),
79+ self.current_line += 1;
45 None => (),
82 None => (),