Implement cursor movement
This commit is contained in:
parent
a1c714d116
commit
fee405b573
5 changed files with 234 additions and 172 deletions
|
|
@ -29,24 +29,30 @@ impl<M: Msg> TreeView<M> {
|
|||
|
||||
pub async fn handle_key_event<S: MsgStore<M>>(
|
||||
&mut self,
|
||||
store: &mut S,
|
||||
room: &str,
|
||||
cursor: &mut Option<Cursor<M::Id>>,
|
||||
r: &str,
|
||||
s: &mut S,
|
||||
c: &mut Option<Cursor<M::Id>>,
|
||||
f: &mut Frame,
|
||||
z: Size,
|
||||
event: KeyEvent,
|
||||
frame: &mut Frame,
|
||||
size: Size,
|
||||
) {
|
||||
match event.code {
|
||||
KeyCode::Char('k') => self.move_to_prev_msg(store, room, cursor).await,
|
||||
KeyCode::Char('z') => self.center_cursor(cursor).await,
|
||||
KeyCode::Char('z') | KeyCode::Char('Z') => self.center_cursor(r, s, c, f, z).await,
|
||||
KeyCode::Char('k') => self.move_up(r, s, c, f, z).await,
|
||||
KeyCode::Char('j') => self.move_down(r, s, c, f, z).await,
|
||||
KeyCode::Char('K') => self.move_up_sibling(r, s, c, f, z).await,
|
||||
KeyCode::Char('J') => self.move_down_sibling(r, s, c, f, z).await,
|
||||
KeyCode::Char('g') => self.move_to_first(r, s, c, f, z).await,
|
||||
KeyCode::Char('G') => self.move_to_last(r, s, c, f, z).await,
|
||||
KeyCode::Esc => *c = None, // TODO Make 'G' do the same thing?
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn render<S: MsgStore<M>>(
|
||||
&mut self,
|
||||
store: &mut S,
|
||||
room: &str,
|
||||
store: &mut S,
|
||||
cursor: &Option<Cursor<M::Id>>,
|
||||
frame: &mut Frame,
|
||||
pos: Pos,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue