ListEditor: better NavResult in dn(): avoid jumping when calling dn on lowest level

This commit is contained in:
Michael Sippel 2021-08-31 02:11:49 +02:00
parent fdd5e925b1
commit 73eec59f58
Signed by: senvas
GPG key ID: F96CF119C34B64A6
2 changed files with 12 additions and 5 deletions

View file

@ -130,7 +130,7 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static,
mode: new_cur.leaf_mode,
idx: None
});
TreeNavResult::Exit
TreeNavResult::Continue
}
}
@ -328,12 +328,12 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static,
);
}
}
TreeNavResult::Continue
}
ListCursorMode::Modify => {
self.get_item().unwrap().write().unwrap().dn();
self.get_item().unwrap().write().unwrap().dn()
}
}
TreeNavResult::Continue
}
fn pxev(&mut self) -> TreeNavResult {

View file

@ -210,10 +210,13 @@ write::
}
}
TerminalEvent::Input(Event::Key(Key::Up)) => { te.up(); }
TerminalEvent::Input(Event::Key(Key::Down)) => { te.dn(); te.goto_home(); }
TerminalEvent::Input(Event::Key(Key::Down)) => {
if te.dn() == TreeNavResult::Continue {
te.goto_home();
}
}
TerminalEvent::Input(Event::Key(Key::Home)) => {
if te.goto_home() == TreeNavResult::Exit {
te.goto_home();
}
}
@ -334,6 +337,10 @@ write::
status_chars.push(TerminalAtom::new(c, TerminalStyle::fg_color((200, 200, 20))));
}
status_chars.push(TerminalAtom::new(':', TerminalStyle::fg_color((120, 80, 80)).add(TerminalStyle::bold(true))));
} else {
for c in "Press <DN> to enter".chars() {
status_chars.push(TerminalAtom::new(c, TerminalStyle::fg_color((200, 200, 20))));
}
}
}