Skip to main content

agent_tui/
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 {
32        x: ToastX::Left,
33        y: ToastY::Top,
34    };
35    pub const TOP_CENTER: Self = Self {
36        x: ToastX::Center,
37        y: ToastY::Top,
38    };
39    pub const TOP_RIGHT: Self = Self {
40        x: ToastX::Right,
41        y: ToastY::Top,
42    };
43    pub const MIDDLE_LEFT: Self = Self {
44        x: ToastX::Left,
45        y: ToastY::Middle,
46    };
47    pub const CENTER: Self = Self {
48        x: ToastX::Center,
49        y: ToastY::Middle,
50    };
51    pub const MIDDLE_RIGHT: Self = Self {
52        x: ToastX::Right,
53        y: ToastY::Middle,
54    };
55    pub const BOTTOM_LEFT: Self = Self {
56        x: ToastX::Left,
57        y: ToastY::Bottom,
58    };
59    pub const BOTTOM_CENTER: Self = Self {
60        x: ToastX::Center,
61        y: ToastY::Bottom,
62    };
63    pub const BOTTOM_RIGHT: Self = Self {
64        x: ToastX::Right,
65        y: ToastY::Bottom,
66    };
67}
68
69impl Default for ToastPosition {
70    fn default() -> Self {
71        Self::TOP_CENTER
72    }
73}