Skip to main content

tui_pages/focus/
query.rs

1use crate::focus::FocusTarget;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub struct FocusQuery<O = ()> {
5    pub current: Option<FocusTarget<O>>,
6}
7
8impl<O> FocusQuery<O> {
9    pub fn is_on_canvas(&self) -> bool {
10        self.current
11            .as_ref()
12            .map(FocusTarget::is_canvas)
13            .unwrap_or(false)
14    }
15}
16
17impl<O: PartialEq> FocusQuery<O> {
18    pub fn is_focused(&self, target: &FocusTarget<O>) -> bool {
19        self.current.as_ref() == Some(target)
20    }
21}