diff options
author | Blaž Hrastnik | 2020-05-25 04:02:21 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-05-25 04:02:21 +0000 |
commit | 44ff4d3c1f5da05e57ce99ba9d67b80a334def83 (patch) | |
tree | 232b8eebab7f709eaf84b8649791a6c74448bfdb /helix-core/src/buffer.rs | |
parent | 240e5f4e3d27415b792776dd126d15302d53e83b (diff) |
Implement a new core based on CodeMirror.
Diffstat (limited to 'helix-core/src/buffer.rs')
-rw-r--r-- | helix-core/src/buffer.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/helix-core/src/buffer.rs b/helix-core/src/buffer.rs new file mode 100644 index 00000000..9dd22773 --- /dev/null +++ b/helix-core/src/buffer.rs @@ -0,0 +1,18 @@ +use anyhow::Error; +use ropey::Rope; +use std::{env, fs::File, io::BufReader, path::PathBuf}; + +pub struct Buffer { + pub contents: Rope, +} + +impl Buffer { + pub fn load(path: PathBuf) -> Result<Self, Error> { + let current_dir = env::current_dir()?; + + let contents = Rope::from_reader(BufReader::new(File::open(path)?))?; + + // TODO: create if not found + Ok(Buffer { contents }) + } +} |