1use gpui::*;
2
3struct HelloWorld {}
4
5impl Render for HelloWorld {
6 fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
7 let text = "The longest word 你好世界这段是中文,こんにちはこの段落は日本語です in any of the major English language dictionaries is pneumonoultramicroscopicsilicovolcanoconiosis, a word that refers to a lung disease contracted from the inhalation of very fine silica particles, specifically from a volcano; medically, it is the same as silicosis.";
8 div()
9 .id("page")
10 .size_full()
11 .flex()
12 .flex_col()
13 .p_2()
14 .gap_2()
15 .bg(gpui::white())
16 .child(
17 div()
18 .flex()
19 .flex_row()
20 .gap_2()
21 .child(
22 div()
23 .flex()
24 .border_1()
25 .border_color(gpui::red())
26 .text_ellipsis()
27 .child("longer text in flex 1"),
28 )
29 .child(
30 div()
31 .flex()
32 .border_1()
33 .border_color(gpui::red())
34 .text_ellipsis()
35 .child("short flex"),
36 )
37 .child(
38 div()
39 .overflow_hidden()
40 .border_1()
41 .border_color(gpui::red())
42 .text_ellipsis()
43 .w_full()
44 .child("A short text in normal div"),
45 ),
46 )
47 .child(
48 div()
49 .text_xl()
50 .overflow_hidden()
51 .text_ellipsis()
52 .border_1()
53 .border_color(gpui::red())
54 .child("ELLIPSIS: ".to_owned() + text),
55 )
56 .child(
57 div()
58 .text_xl()
59 .overflow_hidden()
60 .truncate()
61 .border_1()
62 .border_color(gpui::green())
63 .child("TRUNCATE: ".to_owned() + text),
64 )
65 .child(
66 div()
67 .text_xl()
68 .whitespace_nowrap()
69 .overflow_hidden()
70 .border_1()
71 .border_color(gpui::blue())
72 .child("NOWRAP: ".to_owned() + text),
73 )
74 .child(div().text_xl().w_full().child(text))
75 }
76}
77
78fn main() {
79 App::new().run(|cx: &mut AppContext| {
80 let bounds = Bounds::centered(None, size(px(600.0), px(480.0)), cx);
81 cx.open_window(
82 WindowOptions {
83 window_bounds: Some(WindowBounds::Windowed(bounds)),
84 ..Default::default()
85 },
86 |cx| cx.new_view(|_cx| HelloWorld {}),
87 )
88 .unwrap();
89 });
90}