From d9ed5c631a76dd9fee1e34213277cbcea5a39431 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 8 Mar 2021 10:21:06 -0500 Subject: [PATCH] Start of lines for editing --- src/document.rs | 6 ++++++ src/editor.rs | 8 ++++++-- src/main.rs | 6 +++++- src/row.rs | 3 +++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/document.rs create mode 100644 src/row.rs diff --git a/src/document.rs b/src/document.rs new file mode 100644 index 0000000..1a2d1b1 --- /dev/null +++ b/src/document.rs @@ -0,0 +1,6 @@ +use crate::Row; + +#[derive(Default)] +pub struct Document { + rows: Vec, +} \ No newline at end of file diff --git a/src/editor.rs b/src/editor.rs index 4971d9c..0240284 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -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"); diff --git a/src/main.rs b/src/main.rs index b78daea..693fc5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(); diff --git a/src/row.rs b/src/row.rs new file mode 100644 index 0000000..5a74fc3 --- /dev/null +++ b/src/row.rs @@ -0,0 +1,3 @@ +pub struct Row { + string: String, +} \ No newline at end of file