PTYListEditor: move style into node constructor
This commit is contained in:
parent
4afdb61b87
commit
d43d99c6d3
3 changed files with 29 additions and 43 deletions
|
@ -125,13 +125,14 @@ impl PosIntEditor {
|
||||||
TypeTerm::Num(radix as i64)
|
TypeTerm::Num(radix as i64)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
None,
|
||||||
|
0
|
||||||
|
).into_node(
|
||||||
match radix {
|
match radix {
|
||||||
16 => SeqDecorStyle::Hex,
|
16 => SeqDecorStyle::Hex,
|
||||||
_ => SeqDecorStyle::Plain
|
_ => SeqDecorStyle::Plain
|
||||||
},
|
}
|
||||||
None,
|
)
|
||||||
0
|
|
||||||
).into_node()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,7 @@ use {
|
||||||
pub struct PTYListEditor {
|
pub struct PTYListEditor {
|
||||||
pub editor: Arc<RwLock<ListEditor>>,
|
pub editor: Arc<RwLock<ListEditor>>,
|
||||||
split_char: Option<char>,
|
split_char: Option<char>,
|
||||||
|
depth: usize
|
||||||
style: SeqDecorStyle,
|
|
||||||
depth: usize,
|
|
||||||
|
|
||||||
pub diag: OuterViewPort<dyn SequenceView<Item = crate::diagnostics::Message>>,
|
|
||||||
pub view: OuterViewPort<dyn TerminalView>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
||||||
|
@ -40,27 +35,38 @@ impl PTYListEditor {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
ctx: Arc<RwLock<Context>>,
|
ctx: Arc<RwLock<Context>>,
|
||||||
typ: TypeTerm,
|
typ: TypeTerm,
|
||||||
style: SeqDecorStyle,
|
|
||||||
split_char: Option<char>,
|
split_char: Option<char>,
|
||||||
depth: usize
|
depth: usize
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::from_editor(
|
Self::from_editor(
|
||||||
ListEditor::new(ctx, typ, depth), style, split_char, depth)
|
ListEditor::new(ctx, typ, depth), split_char, depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_editor(
|
pub fn from_editor(
|
||||||
editor: ListEditor,
|
editor: ListEditor,
|
||||||
style: SeqDecorStyle,
|
|
||||||
split_char: Option<char>,
|
split_char: Option<char>,
|
||||||
depth: usize
|
depth: usize
|
||||||
) -> Self {
|
) -> Self {
|
||||||
PTYListEditor {
|
PTYListEditor {
|
||||||
split_char,
|
split_char,
|
||||||
style,
|
|
||||||
depth,
|
depth,
|
||||||
|
editor: Arc::new(RwLock::new(editor)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
view: editor.get_seg_seq_view().pty_decorate(style, depth),
|
pub fn into_node(self, style: SeqDecorStyle) -> NestedNode {
|
||||||
diag: editor.get_data_port()
|
let editor = Arc::new(RwLock::new(self));
|
||||||
|
|
||||||
|
let ed = editor.read().unwrap();
|
||||||
|
let edd = ed.editor.read().unwrap();
|
||||||
|
|
||||||
|
NestedNode::new()
|
||||||
|
.set_cmd(editor.clone())
|
||||||
|
.set_nav(ed.editor.clone())
|
||||||
|
.set_ctx(edd.ctx.clone())
|
||||||
|
.set_view(edd.get_seg_seq_view().pty_decorate(style, ed.depth))
|
||||||
|
.set_diag(
|
||||||
|
edd.get_data_port()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(
|
.map(
|
||||||
|(idx, item_editor)| {
|
|(idx, item_editor)| {
|
||||||
|
@ -76,24 +82,8 @@ impl PTYListEditor {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.flatten(),
|
.flatten()
|
||||||
|
)
|
||||||
editor: Arc::new(RwLock::new(editor)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn into_node(self) -> NestedNode {
|
|
||||||
let editor = Arc::new(RwLock::new(self));
|
|
||||||
|
|
||||||
let ed = editor.read().unwrap();
|
|
||||||
let edd = ed.editor.read().unwrap();
|
|
||||||
|
|
||||||
NestedNode::new()
|
|
||||||
.set_cmd(editor.clone())
|
|
||||||
.set_nav(ed.editor.clone())
|
|
||||||
.set_ctx(edd.ctx.clone())
|
|
||||||
.set_diag(ed.diag.clone())
|
|
||||||
.set_view(ed.view.clone())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_data_port(&self) -> OuterViewPort<dyn SequenceView<Item = NestedNode>> {
|
pub fn get_data_port(&self) -> OuterViewPort<dyn SequenceView<Item = NestedNode>> {
|
||||||
|
@ -111,10 +101,6 @@ impl PTYListEditor {
|
||||||
pub fn set_depth(&mut self, depth: usize) {
|
pub fn set_depth(&mut self, depth: usize) {
|
||||||
self.depth = depth;
|
self.depth = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_style(&mut self, style: SeqDecorStyle) {
|
|
||||||
self.style = style;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Commander for PTYListEditor {
|
impl Commander for PTYListEditor {
|
||||||
|
|
|
@ -74,10 +74,9 @@ pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
|
||||||
PTYListEditor::new(
|
PTYListEditor::new(
|
||||||
ctx.clone(),
|
ctx.clone(),
|
||||||
args[0].clone(),
|
args[0].clone(),
|
||||||
style,
|
|
||||||
delim,
|
delim,
|
||||||
depth
|
depth
|
||||||
).into_node()
|
).into_node(style)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in a new issue