Start of lines for editing

This commit is contained in:
Timothy Warren 2021-03-08 10:21:06 -05:00
parent 3c9b18fcb4
commit d9ed5c631a
4 changed files with 20 additions and 3 deletions

6
src/document.rs Normal file
View File

@ -0,0 +1,6 @@
use crate::Row;
#[derive(Default)]
pub struct Document {
rows: Vec<Row>,
}

View File

@ -1,8 +1,10 @@
use crate::Document;
use crate::Terminal;
use termion::event::Key;
const VERSION: &str = env!("CARGO_PKG_VERSION");
#[derive(Default)]
pub struct Position {
pub x: usize,
pub y: usize,
@ -12,6 +14,7 @@ pub struct Editor {
should_quit: bool,
terminal: Terminal,
cursor_position: Position,
document: Document,
}
impl Editor {
@ -33,13 +36,14 @@ impl Editor {
Self {
should_quit: false,
terminal: Terminal::default().expect("Failed to initialize terminal"),
cursor_position: Position { x: 0, y: 0 }
document: Document::default(),
cursor_position: Position::default(),
}
}
fn refresh_screen(&self) -> Result<(), std::io::Error> {
Terminal::cursor_hide();
Terminal::cursor_position(&Position { x: 0, y: 0});
Terminal::cursor_position(&Position::default());
if self.should_quit {
Terminal::clear_screen();
println!("Goodbye.\r");

View File

@ -1,10 +1,14 @@
#![warn(clippy::all, clippy::pedantic)]
mod document;
mod editor;
mod row;
mod terminal;
pub use document::Document;
use editor::Editor;
pub use terminal::Terminal;
pub use editor::Position;
pub use row::Row;
pub use terminal::Terminal;
fn main() {
Editor::default().run();

3
src/row.rs Normal file
View File

@ -0,0 +1,3 @@
pub struct Row {
string: String,
}