aboutsummaryrefslogtreecommitdiffstats
path: root/src/linebuf.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/linebuf.rs')
-rw-r--r--src/linebuf.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/linebuf.rs b/src/linebuf.rs
index 91d0306..15a8182 100644
--- a/src/linebuf.rs
+++ b/src/linebuf.rs
@@ -1,5 +1,5 @@
-use std::io::Write;
use crate::cursor::*;
+use std::io::Write;
pub struct LineBuf {
pre: Vec<u8>,
@@ -45,6 +45,16 @@ impl LineBuf {
self.pre.push(chr);
}
+ pub fn is_empty(&self) -> bool {
+ self.pre.is_empty() && self.post.is_empty()
+ }
+
+ /// sets content all to the left
+ pub fn set_content(&mut self, buf: Vec<u8>) {
+ self.pre = buf;
+ self.post = Vec::new();
+ }
+
/// returns the whole contents of the buffer, and empties it in the process
pub fn dump(&mut self) -> Vec<u8> {
while self.right() {}