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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//! Trait definitions for settings UI dependencies.
//!
//! These traits define the interface between the settings UI crate
//! and the main terminal implementation. The main crate implements
//! these traits to provide concrete functionality.
use crate::{ArrangementInfo, UpdateCheckResult};
use par_term_config::{Profile, ProfileId};
/// Profile management operations.
///
/// Implemented by the main crate to provide profile management
/// functionality to the settings UI.
pub trait ProfileOps {
/// Get all profiles in display order
fn get_profiles(&self) -> Vec<Profile>;
/// Save profiles to persistent storage
fn save_profiles(&mut self, profiles: Vec<Profile>) -> anyhow::Result<()>;
/// Get a profile by ID
fn get_profile(&self, id: &ProfileId) -> Option<Profile>;
/// Add or update a profile
fn upsert_profile(&mut self, profile: Profile);
/// Delete a profile by ID
fn delete_profile(&mut self, id: &ProfileId) -> bool;
/// Get available shell options
fn get_available_shells(&self) -> Vec<String>;
}
/// Window arrangement operations.
///
/// Implemented by the main crate to provide window layout
/// save/restore functionality.
pub trait ArrangementOps {
/// Get all saved arrangements
fn get_arrangements(&self) -> Vec<ArrangementInfo>;
/// Save current window layout as a new arrangement
fn save_arrangement(&mut self, name: &str) -> anyhow::Result<uuid::Uuid>;
/// Restore a saved arrangement
fn restore_arrangement(&mut self, id: uuid::Uuid) -> anyhow::Result<()>;
/// Delete a saved arrangement
fn delete_arrangement(&mut self, id: uuid::Uuid) -> anyhow::Result<()>;
/// Rename a saved arrangement
fn rename_arrangement(&mut self, id: uuid::Uuid, new_name: &str) -> anyhow::Result<()>;
/// Check if an arrangement with the given name exists
fn arrangement_exists(&self, name: &str) -> bool;
/// Find arrangement by name
fn find_arrangement_by_name(&self, name: &str) -> Option<ArrangementInfo>;
}
/// Update checking and installation operations.
///
/// Implemented by the main crate to provide self-update
/// functionality.
pub trait UpdateOps {
/// Check for updates (may be async)
fn check_for_updates(&self) -> UpdateCheckResult;
/// Get the last update check result
fn last_check_result(&self) -> Option<UpdateCheckResult>;
/// Install an available update
fn install_update(&mut self, version: &str) -> anyhow::Result<()>;
/// Get update installation status
fn is_installing(&self) -> bool;
/// Get installation progress message
fn installation_status(&self) -> Option<String>;
}
/// Coprocess management operations.
///
/// Implemented by the main crate to provide coprocess
/// control functionality.
pub trait CoprocessOps {
/// Get the number of configured coprocesses
fn coprocess_count(&self) -> usize;
/// Get the running status of a coprocess
fn is_running(&self, index: usize) -> bool;
/// Get the last error from a coprocess
fn get_error(&self, index: usize) -> Option<String>;
/// Get buffered output from a coprocess
fn get_output(&self, index: usize) -> Vec<String>;
/// Start a coprocess
fn start(&mut self, index: usize) -> anyhow::Result<()>;
/// Stop a coprocess
fn stop(&mut self, index: usize) -> anyhow::Result<()>;
/// Clear output buffer for a coprocess
fn clear_output(&mut self, index: usize);
}
/// Script management operations.
///
/// Implemented by the main crate to provide script
/// control functionality.
pub trait ScriptOps {
/// Get the number of configured scripts
fn script_count(&self) -> usize;
/// Get the running status of a script
fn is_running(&self, index: usize) -> bool;
/// Get the last error from a script
fn get_error(&self, index: usize) -> Option<String>;
/// Get buffered output from a script
fn get_output(&self, index: usize) -> Vec<String>;
/// Start a script
fn start(&mut self, index: usize) -> anyhow::Result<()>;
/// Stop a script
fn stop(&mut self, index: usize) -> anyhow::Result<()>;
/// Clear output buffer for a script
fn clear_output(&mut self, index: usize);
/// Get panel state for a script (title, content)
fn get_panel(&self, index: usize) -> Option<(String, String)>;
}
/// Shader management operations.
///
/// Implemented by the main crate to provide shader
/// installation functionality.
pub trait ShaderOps {
/// Install bundled shaders
fn install_shaders(&mut self, force_overwrite: bool) -> anyhow::Result<InstallResult>;
/// Get available shader files
fn get_available_shaders(&self) -> Vec<String>;
/// Get available cubemap prefixes
fn get_available_cubemaps(&self) -> Vec<String>;
/// Get shader directory path
fn shaders_dir(&self) -> std::path::PathBuf;
}
/// Result of a shader installation operation.
#[derive(Debug, Clone)]
pub struct InstallResult {
/// Number of shaders installed
pub installed: usize,
/// Number of shaders skipped (unchanged)
pub skipped: usize,
/// Number of obsolete shaders removed
pub removed: usize,
}
/// Shell integration operations.
///
/// Implemented by the main crate to provide shell integration
/// installation functionality.
pub trait ShellIntegrationOps {
/// Install shell integration for the given shell
fn install_integration(&mut self, shell: par_term_config::ShellType) -> anyhow::Result<()>;
/// Uninstall shell integration for the given shell
fn uninstall_integration(&mut self, shell: par_term_config::ShellType) -> anyhow::Result<()>;
/// Check if shell integration is installed
fn is_integration_installed(&self, shell: par_term_config::ShellType) -> bool;
/// Get the path to the shell integration script
fn integration_script_path(&self, shell: par_term_config::ShellType) -> std::path::PathBuf;
}