list editor: avoid empty lists when splitting at multiple levels
adds compatibility to load shell pipeline from file
This commit is contained in:
parent
c2a9d8e3bd
commit
aafc9235ab
5 changed files with 43 additions and 57 deletions
|
@ -5,7 +5,8 @@ name = "nested"
|
|||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
r3vi = { git = "https://git.exobiont.de/senvas/r3vi.git" }
|
||||
#r3vi = { git = "https://git.exobiont.de/senvas/r3vi.git" }
|
||||
r3vi = { path = "../../r3vi" }
|
||||
no_deadlocks = "*"
|
||||
cgmath = { version = "0.18.0", features = ["serde"] }
|
||||
termion = "1.5.5"
|
||||
|
|
|
@ -91,7 +91,7 @@ impl CharEditor {
|
|||
.map(move |c| {
|
||||
match c {
|
||||
Some(c) => TerminalAtom::from(c),
|
||||
None => TerminalAtom::new('*', TerminalStyle::fg_color((255,0,0)))
|
||||
None => TerminalAtom::new(' ', TerminalStyle::bg_color((255,0,0)))
|
||||
}
|
||||
})
|
||||
.to_grid()
|
||||
|
|
|
@ -250,26 +250,16 @@ impl ListEditor {
|
|||
}
|
||||
|
||||
if self.is_listlist() {
|
||||
if idx > 0 && idx < self.data.len() {
|
||||
let prev_idx = idx - 1;
|
||||
if idx > 0 && idx < self.data.len()+1 {
|
||||
let prev_idx = idx - 1; // we are in insert mode, last element before cursor
|
||||
let prev_node = self.data.get(prev_idx);
|
||||
|
||||
if let Some(prev_editor) = prev_node.editor.clone() {
|
||||
eprintln!("prev prev editor");
|
||||
let mut prev_editor = prev_editor.downcast::<RwLock<ListEditor>>().unwrap();
|
||||
let mut prev_editor = prev_editor.write().unwrap();
|
||||
if prev_editor.get_data_port().get_view().unwrap()
|
||||
.iter().filter(
|
||||
|x|
|
||||
/*
|
||||
if let Some(data) = x.data.clone() {
|
||||
let data = data.;
|
||||
data.read().unwrap().is_some()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
*/ true
|
||||
).count() == 0
|
||||
|
||||
if prev_editor.get_data_port().get_view().unwrap().iter()
|
||||
.filter_map(|x| x.get_data_view::<dyn SingletonView<Item = Option<char>>>(vec![].into_iter())?.get()).count() == 0
|
||||
{
|
||||
drop(prev_editor);
|
||||
self.data.remove(prev_idx);
|
||||
|
|
|
@ -144,6 +144,8 @@ impl PTYListEditor {
|
|||
let head = head_editor.downcast::<RwLock<ListEditor>>().unwrap();
|
||||
let mut head = head.write().unwrap();
|
||||
|
||||
if head.data.len() > 0 {
|
||||
|
||||
if cur.tree_addr.len() > 2 {
|
||||
PTYListEditor::split(&mut head);
|
||||
}
|
||||
|
@ -184,6 +186,7 @@ impl PTYListEditor {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn join_pxev(e: &mut ListEditor, idx: isize, item: &NestedNode) {
|
||||
{
|
||||
|
|
|
@ -73,21 +73,13 @@ pub fn init_editor_ctx(parent: Arc<RwLock<Context>>) -> Arc<RwLock<Context>> {
|
|||
id: _, args
|
||||
} => {
|
||||
if args.len() > 0 {
|
||||
|
||||
let editor = PTYListEditor::new(
|
||||
ctx,
|
||||
args[0].clone(),
|
||||
Some(','),
|
||||
depth + 1
|
||||
);
|
||||
|
||||
let view = editor.pty_view(
|
||||
(
|
||||
"{".into(),
|
||||
", ".into(),
|
||||
"}".into()
|
||||
)
|
||||
);
|
||||
let view = editor.pty_view(("{",", ", "}"));
|
||||
|
||||
Some(editor
|
||||
.into_node()
|
||||
|
|
Loading…
Reference in a new issue