qframe/widget/pointer_shape.rs
1//! The shape of the mouse pointer a widget asks for over part of itself.
2
3/// The shape the terminal gives the mouse pointer, asked for while painting with
4/// [`PaintCx::pointer_shape`](super::PaintCx::pointer_shape).
5///
6/// The runtime tells the terminal with OSC 22 (`ESC ] 22 ; <name> ESC \`), which foot, kitty and
7/// WezTerm understand, and only when the shape under the pointer changed. Other terminals are not
8/// sent anything and keep their own pointer. The names are the CSS cursor names those terminals
9/// use.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
11pub enum PointerShape {
12 /// The terminal's usual pointer.
13 #[default]
14 Default,
15 /// A horizontal double arrow, for a side that moves left and right (`ew-resize`).
16 EwResize,
17 /// A vertical double arrow, for a side that moves up and down (`ns-resize`).
18 NsResize,
19 /// A diagonal double arrow from the top left to the bottom right corner (`nwse-resize`).
20 NwseResize,
21 /// A diagonal double arrow from the top right to the bottom left corner (`nesw-resize`).
22 NeswResize,
23}
24
25impl PointerShape {
26 /// The shape's name as OSC 22 carries it, such as `"ew-resize"`.
27 #[must_use]
28 pub fn name(self) -> &'static str {
29 match self {
30 Self::Default => "default",
31 Self::EwResize => "ew-resize",
32 Self::NsResize => "ns-resize",
33 Self::NwseResize => "nwse-resize",
34 Self::NeswResize => "nesw-resize",
35 }
36 }
37}