product editor: update diagnostics view
This commit is contained in:
parent
8eea49a688
commit
06c90197da
2 changed files with 31 additions and 9 deletions
|
@ -13,7 +13,7 @@ pub fn bg_style_from_depth(depth: usize) -> TerminalStyle {
|
|||
|
||||
pub fn fg_style_from_depth(depth: usize) -> TerminalStyle {
|
||||
match depth % 6 {
|
||||
0 => TerminalStyle::fg_color((40, 180, 230)),
|
||||
0 => TerminalStyle::fg_color((180, 180, 180)),
|
||||
1 => TerminalStyle::fg_color((120, 120, 120)),
|
||||
2 => TerminalStyle::fg_color((250, 165, 40)),
|
||||
3 => TerminalStyle::fg_color((80, 180, 200)),
|
||||
|
|
|
@ -14,6 +14,7 @@ use {
|
|||
|
||||
tree_nav::{TreeNav, TerminalTreeEditor, TreeNavResult},
|
||||
diagnostics::{Diagnostics, Message},
|
||||
terminal::{TerminalStyle}
|
||||
},
|
||||
cgmath::{Vector2, Point2},
|
||||
std::sync::{Arc, RwLock},
|
||||
|
@ -137,6 +138,7 @@ impl ProductEditor {
|
|||
*cur_depth = cur.tree_addr.len();
|
||||
}
|
||||
|
||||
|
||||
*cur_dist = cur.tree_addr[0] - idx
|
||||
} else {
|
||||
*cur_dist = isize::MAX;
|
||||
|
@ -149,6 +151,19 @@ impl ProductEditor {
|
|||
b.push(crate::diagnostics::make_todo(crate::terminal::make_label(&format!("complete {}", self.ctx.read().unwrap().type_term_to_str(&t[0])))));
|
||||
|
||||
self.msg_buf.update(idx as usize, Some(b.get_port().to_sequence()));
|
||||
|
||||
if cur.tree_addr.len() > 0 {
|
||||
if cur.tree_addr[0] == idx {
|
||||
self.msg_buf.update(idx as usize, Some(b.get_port().to_sequence().map(
|
||||
|msg| {
|
||||
let mut msg = msg.clone();
|
||||
msg.port = msg.port.map_item(|p,a| a.add_style_back(TerminalStyle::bg_color((40,40,40))));
|
||||
msg
|
||||
}
|
||||
)));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -173,17 +188,20 @@ impl TerminalEditor for ProductEditor {
|
|||
}
|
||||
|
||||
fn handle_terminal_event(&mut self, event: &TerminalEvent) -> TerminalEditorResult {
|
||||
if let Some(mut segment) = self.get_cur_segment_mut().as_deref_mut() {
|
||||
let mut update_segment = false;
|
||||
|
||||
let result = if let Some(mut segment) = self.get_cur_segment_mut().as_deref_mut() {
|
||||
if let Some(ProductEditorSegment::N{ t, editor, ed_depth, cur_depth, cur_dist }) = segment.deref_mut() {
|
||||
*cur_depth = self.get_cursor().tree_addr.len();
|
||||
|
||||
let result = if let Some(e) = editor.clone() {
|
||||
if let Some(e) = editor.clone() {
|
||||
let mut ce = e.write().unwrap();
|
||||
match ce.handle_terminal_event(event) {
|
||||
TerminalEditorResult::Exit =>
|
||||
match event {
|
||||
TerminalEvent::Input(Event::Key(Key::Backspace)) => {
|
||||
*editor = None;
|
||||
update_segment = true;
|
||||
TerminalEditorResult::Continue
|
||||
}
|
||||
_ => {
|
||||
|
@ -203,20 +221,24 @@ impl TerminalEditor for ProductEditor {
|
|||
} else {
|
||||
let e = make_editor(self.ctx.clone(), t, *ed_depth+1);
|
||||
*editor = Some(e.clone());
|
||||
update_segment = true;
|
||||
|
||||
e.write().unwrap().dn();
|
||||
let x = e.write().unwrap().handle_terminal_event(event);
|
||||
*cur_depth = e.write().unwrap().get_cursor().tree_addr.len();
|
||||
x
|
||||
};
|
||||
|
||||
self.update_cur_segment();
|
||||
result
|
||||
}
|
||||
} else {
|
||||
unreachable!()
|
||||
unreachable!();
|
||||
TerminalEditorResult::Exit
|
||||
}
|
||||
} else {
|
||||
TerminalEditorResult::Exit
|
||||
};
|
||||
|
||||
if update_segment {
|
||||
self.update_cur_segment();
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue