1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use serde::{Deserialize, Serialize};
use std::{error::Error, io::Stdout};
use tui::{backend::CrosstermBackend, Frame, Terminal};
pub type DynResult = Result<(), Box<dyn Error>>;
pub type CrossTerminal = Terminal<CrosstermBackend<Stdout>>;
pub type TerminalFrame<'a> = Frame<'a, CrosstermBackend<Stdout>>;
#[derive(Serialize, Deserialize, Clone)]
pub struct Quest {
pub title: String,
pub completed: bool,
}
impl Quest {
pub fn new(title: String) -> Self {
Self {
title,
completed: false,
}
}
}
#[derive(Serialize, Deserialize, Default)]
pub struct QuestList {
pub quests: Vec<Quest>,
}
impl QuestList {
pub fn new(quests: &[Quest]) -> Self {
Self {
quests: quests.to_vec(),
}
}
}
pub enum InputMode {
Normal,
Editing,
}
pub struct App {
pub input: String,
pub input_mode: InputMode,
pub quests: Vec<Quest>,
pub should_exit: bool,
pub selected_quest: Option<usize>,
}
impl App {
pub fn new(quests: &[Quest]) -> Self {
Self {
quests: quests.to_vec(),
selected_quest: Some(0),
input: String::new(),
input_mode: InputMode::Normal,
should_exit: false,
}
}
}