-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21a200a
commit 6326801
Showing
14 changed files
with
94 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,5 @@ impl Buffer { | |
|
||
pub fn enter_command_mode(&mut self) { | ||
self.mode = BufferMode::Command; | ||
self.command.reset(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod explorer; | ||
pub mod read_file; | ||
pub mod write_file; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
use std::fs::File; | ||
use std::io::Read; | ||
|
||
use crate::buffer::Buffer; | ||
use crate::editor::Editor; | ||
|
||
pub struct ReadFileCommand {} | ||
|
||
impl ReadFileCommand { | ||
pub fn run(buffer: &mut Buffer) { | ||
if buffer.command.text.len() > 2 { | ||
let file_name = &buffer.command.text[2..]; | ||
if file_name.starts_with("~/") { | ||
let mut home_path = home::home_dir().unwrap(); | ||
home_path.push(&file_name[2..]); | ||
buffer.file_name = Some(home_path.display().to_string()); | ||
} else { | ||
buffer.file_name = Some(String::from(file_name)); | ||
} | ||
let mut content = String::new(); | ||
let file_path = buffer.file_name.as_ref().unwrap(); | ||
let mut file = File::open(file_path).unwrap(); | ||
file.read_to_string(&mut content).unwrap(); | ||
buffer.set_content(content); | ||
pub fn run(editor: &mut Editor) { | ||
let command = editor.command.text.clone(); | ||
let buffer = editor.get_active_buffer_mut(); | ||
let file_name = &command.trim()[2..]; | ||
if file_name.starts_with("~/") { | ||
let mut home_path = home::home_dir().unwrap(); | ||
home_path.push(&file_name[2..]); | ||
buffer.file_name = Some(home_path.display().to_string()); | ||
} else { | ||
buffer.file_name = Some(String::from(file_name)); | ||
} | ||
let mut content = String::new(); | ||
let file_path = buffer.file_name.as_ref().unwrap(); | ||
let mut file = File::open(file_path).unwrap(); | ||
file.read_to_string(&mut content).unwrap(); | ||
buffer.set_content(content); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters