Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:42:45.763Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

text_wrapper.rs

139 lines · 4.7 KB · rust
1#![cfg_attr(target_family = "wasm", no_main)]
2
3use gpui::{
4    App, Bounds, Context, TextOverflow, Window, WindowBounds, WindowOptions, div, prelude::*, px,
5    size,
6};
7use gpui_platform::application;
8
9struct HelloWorld {}
10
11impl Render for HelloWorld {
12    fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
13        let text = "The longest word 你好世界这段是中文,こんにちはこの段落は日本語です in any of the major \
14            English language dictionaries is pneumonoultramicroscopicsilicovolcanoconiosis, a word that \
15            refers to a lung disease contracted from the inhalation of very fine silica particles, \
16            a url https://github.com/zed-industries/zed/pull/35724?query=foo&bar=2, \
17            specifically from a volcano; medically, it is the same as silicosis.";
18        div()
19            .id("page")
20            .size_full()
21            .flex()
22            .flex_col()
23            .p_2()
24            .gap_2()
25            .bg(gpui::white())
26            .child(
27                div()
28                    .flex()
29                    .flex_row()
30                    .flex_shrink_0()
31                    .gap_2()
32                    .child(
33                        div()
34                            .flex()
35                            .border_1()
36                            .border_color(gpui::red())
37                            .text_ellipsis()
38                            .child("longer text in flex 1"),
39                    )
40                    .child(
41                        div()
42                            .flex()
43                            .border_1()
44                            .border_color(gpui::red())
45                            .text_ellipsis()
46                            .child("short flex"),
47                    )
48                    .child(
49                        div()
50                            .overflow_hidden()
51                            .border_1()
52                            .border_color(gpui::red())
53                            .text_ellipsis()
54                            .w_full()
55                            .child("A short text in normal div"),
56                    ),
57            )
58            .child(
59                div()
60                    .flex_shrink_0()
61                    .text_xl()
62                    .truncate()
63                    .border_1()
64                    .border_color(gpui::blue())
65                    .child("ELLIPSIS: ".to_owned() + text),
66            )
67            .child(
68                div()
69                    .flex_shrink_0()
70                    .text_xl()
71                    .overflow_hidden()
72                    .text_ellipsis()
73                    .line_clamp(2)
74                    .border_1()
75                    .border_color(gpui::blue())
76                    .child("ELLIPSIS 2 lines: ".to_owned() + text),
77            )
78            .child(
79                div()
80                    .flex_shrink_0()
81                    .text_xl()
82                    .overflow_hidden()
83                    .text_overflow(TextOverflow::Truncate("".into()))
84                    .border_1()
85                    .border_color(gpui::green())
86                    .child("TRUNCATE: ".to_owned() + text),
87            )
88            .child(
89                div()
90                    .flex_shrink_0()
91                    .text_xl()
92                    .overflow_hidden()
93                    .text_overflow(TextOverflow::Truncate("".into()))
94                    .line_clamp(3)
95                    .border_1()
96                    .border_color(gpui::green())
97                    .child("TRUNCATE 3 lines: ".to_owned() + text),
98            )
99            .child(
100                div()
101                    .flex_shrink_0()
102                    .text_xl()
103                    .whitespace_nowrap()
104                    .overflow_hidden()
105                    .border_1()
106                    .border_color(gpui::black())
107                    .child("NOWRAP: ".to_owned() + text),
108            )
109            .child(div().text_xl().w_full().child(text))
110    }
111}
112
113fn run_example() {
114    application().run(|cx: &mut App| {
115        let bounds = Bounds::centered(None, size(px(800.0), px(600.0)), cx);
116        cx.open_window(
117            WindowOptions {
118                window_bounds: Some(WindowBounds::Windowed(bounds)),
119                ..Default::default()
120            },
121            |_, cx| cx.new(|_| HelloWorld {}),
122        )
123        .unwrap();
124        cx.activate(true);
125    });
126}
127
128#[cfg(not(target_family = "wasm"))]
129fn main() {
130    run_example();
131}
132
133#[cfg(target_family = "wasm")]
134#[wasm_bindgen::prelude::wasm_bindgen(start)]
135pub fn start() {
136    gpui_platform::web_init();
137    run_example();
138}
139
Served at tenant.openagents/omega Member data and write actions are omitted.