context: fix is_list_type for App&Ladder types; properly reset cursor when remaining in same height after insert

This commit is contained in:
Michael Sippel 2023-09-15 15:15:59 +02:00
parent 119105c6a2
commit 120d0e1df0
Signed by: senvas
GPG key ID: F96CF119C34B64A6
4 changed files with 59 additions and 45 deletions

View file

@ -71,11 +71,11 @@ impl ObjCommander for ListEditor {
match cur.mode {
ListCursorMode::Select => {
if let Some(mut item) = self.get_item().clone() {
if self.is_listlist() {
let item_cur = item.get_cursor();
match cmd.get() {
ListCmd::DeletePxev => {
eprintln!("SELECT: delete pxev");
if idx > 0
&& item_cur.tree_addr.iter().fold(
true,
@ -117,9 +117,7 @@ impl ObjCommander for ListEditor {
}
}
} else {
TreeNavResult::Exit
}
} else {
eprintln!("ptylist: no item");
TreeNavResult::Exit
}
},

View file

@ -245,6 +245,8 @@ impl ListEditor {
if self.is_listlist() {
cur.mode = ListCursorMode::Select;
} else {
eprintln!("list insert: is not a listlist ({:?})", self.typ);
item.write().unwrap().goto(TreeCursor::none());
cur.idx = Some(idx + 1);
}
}

View file

@ -65,6 +65,8 @@ impl PTYListStyle {
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
// todo: rename to CharController
pub struct PTYListController {
pub editor: Arc<RwLock<ListEditor>>,

View file

@ -196,6 +196,18 @@ impl Context {
TypeTerm::TypeID(id) => {
self.list_types.contains(id)
}
TypeTerm::Ladder(args) |
TypeTerm::App(args) => {
if args.len() > 0 {
if self.is_list_type(&args[0]) {
true
} else {
false
}
} else {
false
}
}
_ => false
}
}