char editor: use null char to avoid option
This commit is contained in:
parent
8e03a1711d
commit
efb4cd39da
1 changed files with 7 additions and 12 deletions
|
@ -18,7 +18,7 @@ use {
|
||||||
|
|
||||||
pub struct CharEditor {
|
pub struct CharEditor {
|
||||||
ctx: Arc<RwLock<Context>>,
|
ctx: Arc<RwLock<Context>>,
|
||||||
data: SingletonBuffer<Option<char>>
|
data: SingletonBuffer<char>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjCommander for CharEditor {
|
impl ObjCommander for CharEditor {
|
||||||
|
@ -36,7 +36,7 @@ impl ObjCommander for CharEditor {
|
||||||
if self.ctx.read().unwrap().meta_chars.contains(&value) {
|
if self.ctx.read().unwrap().meta_chars.contains(&value) {
|
||||||
TreeNavResult::Exit
|
TreeNavResult::Exit
|
||||||
} else {
|
} else {
|
||||||
self.data.set(Some(value));
|
self.data.set(value);
|
||||||
TreeNavResult::Continue
|
TreeNavResult::Continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,20 +52,20 @@ impl CharEditor {
|
||||||
pub fn new(ctx: Arc<RwLock<Context>>) -> Self {
|
pub fn new(ctx: Arc<RwLock<Context>>) -> Self {
|
||||||
CharEditor {
|
CharEditor {
|
||||||
ctx,
|
ctx,
|
||||||
data: SingletonBuffer::new(None)
|
data: SingletonBuffer::new('\0')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_port(&self) -> OuterViewPort<dyn SingletonView<Item = Option<char>>> {
|
pub fn get_port(&self) -> OuterViewPort<dyn SingletonView<Item = char>> {
|
||||||
self.data.get_port()
|
self.data.get_port()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self) -> char {
|
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<RwLock<Context>>) -> NestedNode {
|
pub fn new_node(ctx0: Arc<RwLock<Context>>) -> NestedNode {
|
||||||
let data = SingletonBuffer::new(None);
|
let data = SingletonBuffer::new('\0');
|
||||||
|
|
||||||
let ctx = ctx0.clone();
|
let ctx = ctx0.clone();
|
||||||
|
|
||||||
|
@ -81,12 +81,7 @@ impl CharEditor {
|
||||||
)
|
)
|
||||||
.set_view(data
|
.set_view(data
|
||||||
.get_port()
|
.get_port()
|
||||||
.map(move |c| {
|
.map(move |c| TerminalAtom::from(c))
|
||||||
match c {
|
|
||||||
Some(c) => TerminalAtom::from(c),
|
|
||||||
None => TerminalAtom::new(' ', TerminalStyle::bg_color((255,0,0)))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.to_grid()
|
.to_grid()
|
||||||
)
|
)
|
||||||
.set_cmd( editor.clone() )
|
.set_cmd( editor.clone() )
|
||||||
|
|
Loading…
Reference in a new issue