From efb4cd39da3ac8ff7156a32474736e99ef6cdc58 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Fri, 11 Aug 2023 01:51:41 +0200 Subject: [PATCH] char editor: use null char to avoid option --- nested/src/editors/char/mod.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/nested/src/editors/char/mod.rs b/nested/src/editors/char/mod.rs index 68dc193..d54b60b 100644 --- a/nested/src/editors/char/mod.rs +++ b/nested/src/editors/char/mod.rs @@ -18,7 +18,7 @@ use { pub struct CharEditor { ctx: Arc>, - data: SingletonBuffer> + data: SingletonBuffer } impl ObjCommander for CharEditor { @@ -36,7 +36,7 @@ impl ObjCommander for CharEditor { if self.ctx.read().unwrap().meta_chars.contains(&value) { TreeNavResult::Exit } else { - self.data.set(Some(value)); + self.data.set(value); TreeNavResult::Continue } } else { @@ -52,20 +52,20 @@ impl CharEditor { pub fn new(ctx: Arc>) -> Self { CharEditor { ctx, - data: SingletonBuffer::new(None) + data: SingletonBuffer::new('\0') } } - pub fn get_port(&self) -> OuterViewPort>> { + pub fn get_port(&self) -> OuterViewPort> { self.data.get_port() } pub fn get(&self) -> char { - self.get_port().get_view().unwrap().get().unwrap_or('?') + self.get_port().get_view().unwrap().get() } pub fn new_node(ctx0: Arc>) -> NestedNode { - let data = SingletonBuffer::new(None); + let data = SingletonBuffer::new('\0'); let ctx = ctx0.clone(); @@ -81,12 +81,7 @@ impl CharEditor { ) .set_view(data .get_port() - .map(move |c| { - match c { - Some(c) => TerminalAtom::from(c), - None => TerminalAtom::new(' ', TerminalStyle::bg_color((255,0,0))) - } - }) + .map(move |c| TerminalAtom::from(c)) .to_grid() ) .set_cmd( editor.clone() )