Show available key bindings with F1/?
This commit is contained in:
parent
a51bb60342
commit
6c1ce49236
6 changed files with 355 additions and 87 deletions
|
|
@ -14,7 +14,7 @@ use crate::euph::{self, Joined, Status};
|
|||
use crate::vault::EuphVault;
|
||||
|
||||
use super::chat::{ChatState, Reaction};
|
||||
use super::input::{key, KeyEvent};
|
||||
use super::input::{key, KeyBindingsList, KeyEvent};
|
||||
use super::widgets::background::Background;
|
||||
use super::widgets::border::Border;
|
||||
use super::widgets::editor::EditorState;
|
||||
|
|
@ -302,6 +302,37 @@ impl EuphRoom {
|
|||
list.into()
|
||||
}
|
||||
|
||||
pub async fn list_key_bindings(&self, bindings: &mut KeyBindingsList) {
|
||||
bindings.heading("Room");
|
||||
|
||||
match &self.state {
|
||||
State::Normal => {
|
||||
// TODO Use if-let chain
|
||||
bindings.binding("esc", "leave room");
|
||||
let can_compose = if let Some(room) = &self.room {
|
||||
if let Ok(Some(Status::Joined(_))) = room.status().await {
|
||||
bindings.binding("n", "change nick");
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
bindings.empty();
|
||||
self.chat.list_key_bindings(bindings, can_compose).await;
|
||||
}
|
||||
State::ChooseNick(_) => {
|
||||
bindings.binding("esc", "abort");
|
||||
bindings.binding("enter", "set nick");
|
||||
bindings.binding("←/→", "move cursor left/right");
|
||||
bindings.binding("backspace", "delete before cursor");
|
||||
bindings.binding("delete", "delete after cursor");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn handle_key_event(
|
||||
&mut self,
|
||||
terminal: &mut Terminal,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue