freya_core/style/
text_overflow.rs1#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2#[derive(Default, Clone, Debug, PartialEq, Hash)]
3pub enum TextOverflow {
4 #[default]
5 Clip,
6 Ellipsis,
7 Custom(String),
8}
9
10impl TextOverflow {
11 pub fn get_ellipsis(&self) -> Option<&str> {
12 match self {
13 Self::Clip => None,
14 Self::Ellipsis => Some("…"),
15 Self::Custom(custom) => Some(custom),
16 }
17 }
18
19 pub fn pretty(&self) -> String {
20 match self {
21 TextOverflow::Clip => "clip".to_string(),
22 TextOverflow::Ellipsis => "ellipsis".to_string(),
23 TextOverflow::Custom(text_overflow) => text_overflow.to_string(),
24 }
25 }
26}