multiverse/widgets/
help.rs
1use ratatui::{
2 prelude::*,
3 widgets::{Block, Borders, Cell, Clear, Padding, Row, Table, TableState},
4};
5
6use crate::popup_area;
7
8#[derive(Default)]
9pub struct HelpView {}
10
11impl HelpView {
12 pub fn new() -> Self {
13 Self {}
14 }
15}
16
17impl Widget for &mut HelpView {
18 fn render(self, area: Rect, buf: &mut Buffer) {
19 let block =
20 Block::bordered().title(" Help Menu ").borders(Borders::ALL).padding(Padding::left(2));
21 let area = popup_area(area, 50, 50);
22 Clear.render(area, buf);
23
24 let rows = vec![
25 Row::new(vec![Cell::from("F1"), Cell::from("Open Help")]),
26 Row::new(vec![Cell::from("F10"), Cell::from("Open the encryption settings")]),
27 Row::new(vec![Cell::from("ALT-l"), Cell::from("Open the linked chunk details view")]),
28 Row::new(vec![Cell::from("ALT-e"), Cell::from("Open the events details view")]),
29 Row::new(vec![Cell::from("ALT-r"), Cell::from("Open the read receipt details view")]),
30 Row::new(vec![Cell::from("Ctrl-q"), Cell::from("Quit Multiverse")]),
31 Row::new(vec![
32 Cell::from("Ctrl-j / Ctrl-down"),
33 Cell::from("Switch to the next room in the list"),
34 ]),
35 Row::new(vec![
36 Cell::from("Ctrl-k / Ctrl-up"),
37 Cell::from("Switch to the previous room in the list"),
38 ]),
39 Row::new(vec![
40 Cell::from("Page-Up"),
41 Cell::from("Backpaginate the currently selected room"),
42 ]),
43 Row::new(vec![
44 Cell::from("Ctrl-l"),
45 Cell::from("Like the last message in the selected room"),
46 ]),
47 ];
48 let widths = [Constraint::Length(5), Constraint::Length(5)];
49
50 let help_table = Table::new(rows, widths)
51 .block(block)
52 .widths([Constraint::Length(20), Constraint::Min(30)]);
53
54 StatefulWidget::render(help_table, area, buf, &mut TableState::default());
55 }
56}