luminol_config/global.rs
1// Copyright (C) 2024 Melody Madeline Lyons
2//
3// This file is part of Luminol.
4//
5// Luminol is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Luminol is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Luminol. If not, see <http://www.gnu.org/licenses/>.
17//
18// Additional permission under GNU GPL version 3 section 7
19//
20// If you modify this Program, or any covered work, by linking or combining
21// it with Steamworks API by Valve Corporation, containing parts covered by
22// terms of the Steamworks API by Valve Corporation, the licensors of this
23// Program grant you additional permission to convey the resulting work.
24
25#[cfg(not(target_arch = "wasm32"))]
26use crate::terminal;
27use crate::CodeTheme;
28use std::collections::VecDeque;
29
30/// The state saved by Luminol between sessions.
31#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
32#[serde(default)]
33pub struct Config {
34 #[cfg(not(target_arch = "wasm32"))]
35 /// Recently open projects.
36 pub recent_projects: VecDeque<String>,
37 #[cfg(target_arch = "wasm32")]
38 /// Recently open projects.
39 pub recent_projects: VecDeque<(String, String)>,
40 #[cfg(not(target_arch = "wasm32"))]
41 pub terminal: terminal::Config,
42
43 /// The current code theme
44 pub theme: CodeTheme,
45 #[cfg(not(target_arch = "wasm32"))]
46 pub rtp_paths: indexmap::IndexMap<String, String>,
47}
48
49impl Default for Config {
50 fn default() -> Self {
51 Self::new()
52 }
53}
54
55impl Config {
56 pub fn new() -> Self {
57 Self {
58 recent_projects: VecDeque::new(),
59 theme: CodeTheme::dark(),
60 #[cfg(not(target_arch = "wasm32"))]
61 rtp_paths: indexmap::IndexMap::new(),
62 #[cfg(not(target_arch = "wasm32"))]
63 terminal: terminal::Config::default(),
64 }
65 }
66}