1pub mod console;
4pub mod list;
5pub mod reports;
6pub mod select_list;
7#[cfg(test)]
8mod tests;
9
10use crate::hits::Hits;
11use tvui::{FrameState, Theme};
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub enum ViewId {
15 Accounts = 0,
16 Transactions = 1,
17 Commodities = 2,
18 Reports = 3,
19 Config = 4,
20 SshKeys = 5,
21 Tags = 6,
22 Templates = 7,
23 Console = 8,
24 Scripts = 9,
25 Viewer = 10,
27}
28
29impl ViewId {
30 pub const ALL: [ViewId; 10] = [
31 ViewId::Accounts,
32 ViewId::Transactions,
33 ViewId::Commodities,
34 ViewId::Reports,
35 ViewId::Config,
36 ViewId::SshKeys,
37 ViewId::Tags,
38 ViewId::Templates,
39 ViewId::Console,
40 ViewId::Scripts,
41 ];
42
43 pub fn index(self) -> usize {
44 self as usize
45 }
46
47 pub fn label(self) -> &'static str {
48 match self {
49 ViewId::Accounts => "Accounts",
50 ViewId::Transactions => "Transactions",
51 ViewId::Commodities => "Commodities",
52 ViewId::Reports => "Reports",
53 ViewId::Config => "Config",
54 ViewId::SshKeys => "SSH keys",
55 ViewId::Tags => "Tags",
56 ViewId::Templates => "Templates",
57 ViewId::Scripts => "Scripts",
58 ViewId::Console => "Console",
59 ViewId::Viewer => "Viewer",
60 }
61 }
62}
63
64pub type Tab = ViewId;
66
67pub struct DrawCtx<'a> {
68 pub is_active: bool,
70 pub frame: FrameState,
72 pub title: String,
74 pub theme: &'a Theme,
75 pub hits: &'a mut Hits,
77}
78
79pub enum Handled {
80 Consumed(Vec<Cmd>),
81 Ignored,
82}
83
84pub enum Cmd {
85 Status(String),
86 SwitchView(ViewId),
87}