Start of lines for editing
This commit is contained in:
parent
3c9b18fcb4
commit
d9ed5c631a
6
src/document.rs
Normal file
6
src/document.rs
Normal file
@ -0,0 +1,6 @@
|
||||
use crate::Row;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Document {
|
||||
rows: Vec<Row>,
|
||||
}
|
@ -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");
|
||||
|
@ -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
3
src/row.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub struct Row {
|
||||
string: String,
|
||||
}
|
Loading…
Reference in New Issue
Block a user