Skip to main content

synaps_cli/
toast.rs

1//! Public toast notification primitives for extensions and host UIs.
2//!
3//! Terminal rendering lives in `chatui`; these types define the stable position
4//! vocabulary extensions can target, including corners/diagonals and persistent
5//! overlay-style widgets.
6
7/// Horizontal anchor for toast placement.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum ToastX {
10    Left,
11    Center,
12    Right,
13}
14
15/// Vertical anchor for toast placement.
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum ToastY {
18    Top,
19    Middle,
20    Bottom,
21}
22
23/// Screen position for a toast/overlay.
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub struct ToastPosition {
26    pub x: ToastX,
27    pub y: ToastY,
28}
29
30impl ToastPosition {
31    pub const TOP_LEFT: Self = Self { x: ToastX::Left, y: ToastY::Top };
32    pub const TOP_CENTER: Self = Self { x: ToastX::Center, y: ToastY::Top };
33    pub const TOP_RIGHT: Self = Self { x: ToastX::Right, y: ToastY::Top };
34    pub const MIDDLE_LEFT: Self = Self { x: ToastX::Left, y: ToastY::Middle };
35    pub const CENTER: Self = Self { x: ToastX::Center, y: ToastY::Middle };
36    pub const MIDDLE_RIGHT: Self = Self { x: ToastX::Right, y: ToastY::Middle };
37    pub const BOTTOM_LEFT: Self = Self { x: ToastX::Left, y: ToastY::Bottom };
38    pub const BOTTOM_CENTER: Self = Self { x: ToastX::Center, y: ToastY::Bottom };
39    pub const BOTTOM_RIGHT: Self = Self { x: ToastX::Right, y: ToastY::Bottom };
40}
41
42impl Default for ToastPosition {
43    fn default() -> Self {
44        Self::TOP_CENTER
45    }
46}