fret_runtime/
window_key_context_stack.rs1use std::collections::HashMap;
2use std::sync::Arc;
3
4use fret_core::AppWindowId;
5
6#[derive(Debug, Default)]
12pub struct WindowKeyContextStackService {
13 by_window: HashMap<AppWindowId, Vec<Arc<str>>>,
14}
15
16impl WindowKeyContextStackService {
17 pub fn snapshot(&self, window: AppWindowId) -> Option<&[Arc<str>]> {
18 self.by_window.get(&window).map(|v| v.as_slice())
19 }
20
21 pub fn set_snapshot(&mut self, window: AppWindowId, key_contexts: Vec<Arc<str>>) {
22 self.by_window.insert(window, key_contexts);
23 }
24
25 pub fn remove_window(&mut self, window: AppWindowId) {
26 self.by_window.remove(&window);
27 }
28}