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![
31                Cell::from("Alt-t"),
32                Cell::from("Switch the detail view tiling direction"),
33            ]),
34            Row::new(vec![
35                Cell::from("Alt-m"),
36                Cell::from("Mark the currently selected room as read"),
37            ]),
38            Row::new(vec![Cell::from("Ctrl-q"), Cell::from("Quit Multiverse")]),
39            Row::new(vec![
40                Cell::from("Ctrl-j / Ctrl-down"),
41                Cell::from("Switch to the next room in the list"),
42            ]),
43            Row::new(vec![
44                Cell::from("Ctrl-k / Ctrl-up"),
45                Cell::from("Switch to the previous room in the list"),
46            ]),
47            Row::new(vec![
48                Cell::from("Page-Up"),
49                Cell::from("Backpaginate the currently selected room"),
50            ]),
51            Row::new(vec![
52                Cell::from("Ctrl-l"),
53                Cell::from("Like the last message in the selected room"),
54            ]),
55            Row::new(vec![
56                Cell::from("Ctrl-n"),
57                Cell::from("Focus on the next item in the timeline view"),
58            ]),
59            Row::new(vec![
60                Cell::from("Ctrl-p"),
61                Cell::from("Focus on the previous item in the timeline view"),
62            ]),
63            Row::new(vec![
64                Cell::from("Ctrl-t"),
65                Cell::from("Open a thread on the focused timeline item"),
66            ]),
67            Row::new(vec![Cell::from("Ctrl-r"), Cell::from("Create a new room")]),
68            Row::new(vec![Cell::from("Ctrl-s"), Cell::from("Search")]),
69        ];
70        let widths = [Constraint::Length(5), Constraint::Length(5)];
71
72        let help_table = Table::new(rows, widths)
73            .block(block)
74            .widths([Constraint::Length(20), Constraint::Min(30)]);
75
76        StatefulWidget::render(help_table, area, buf, &mut TableState::default());
77    }
78}