aboutsummaryrefslogtreecommitdiffstats
path: root/src/linebuf.rs
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-07 18:47:22 +0100
committerJonas Maier <>2026-03-07 18:47:22 +0100
commit86cdb8c21dec737a3f0a40311782de851c1203d1 (patch)
treee8aeac2d0d5dd81b39bf37016782afb3f087b69a /src/linebuf.rs
parent8fcde466805466c7ecebfc3cd7d4340117a29576 (diff)
downloadpish-86cdb8c21dec737a3f0a40311782de851c1203d1.tar.gz
Ctrl+Left and Ctrl+Right
Diffstat (limited to 'src/linebuf.rs')
-rw-r--r--src/linebuf.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/linebuf.rs b/src/linebuf.rs
index 86c4f95..f5bd95f 100644
--- a/src/linebuf.rs
+++ b/src/linebuf.rs
@@ -61,6 +61,14 @@ impl LineBuf {
n
}
+ pub fn get_left(&self) -> Option<u8>{
+ self.pre.last().cloned()
+ }
+
+ pub fn get_right(&self) -> Option<u8>{
+ self.post.last().cloned()
+ }
+
pub fn add(&mut self, chr: u8) {
self.dirty = true;
self.pre.push(chr);
@@ -108,6 +116,10 @@ impl LineBuf {
self.dirty = false;
}
+ pub fn display_pre(&self) {
+ std::io::stdout().write_all(&self.pre).unwrap();
+ }
+
/// TODO: kinda ugly that this is here
pub fn display_post(&self, post: &[u8]) {
for &x in self.post.iter().rev() {