T44d Web · Hidden demos keep still, wide ones scroll whole, pastes read the web's clipboard

This commit is contained in:
ZacharyZhang-NY committed 2026-09-29 22:13:27 -04:00
1 parent d2018f8510
commit 752e7cba0c
26 files changed
+211 -101

No files matched your search

+13 -13
View File
@@ -13,7 +13,7 @@ use gpui::{
use crate::{
probe::probe,
ui::{code, row, section, web_note},
ui::{code, row, section, set},
};
pub fn boxes(cx: &App) -> impl IntoElement + use<> {
@@ -442,13 +442,9 @@ pub fn clipboard(window: &mut Window, cx: &mut App) -> impl IntoElement + use<>
let muted = cx.theme().colors.fg_muted;
section(
"Clipboard",
"write_to_clipboard and read_from_clipboard on App.",
"write_to_clipboard and read_from_clipboard_async on App; a browser asks before it hands the clipboard over.",
cx,
)
.children(web_note(
"A browser reads its clipboard only as it pastes, into a field: on the web gpui's read_from_clipboard finds nothing, so Paste reports no text. Copy works.",
cx,
))
.child(
row()
.gap_3()
@@ -464,14 +460,18 @@ pub fn clipboard(window: &mut Window, cx: &mut App) -> impl IntoElement + use<>
.variant(ButtonVariant::Ghost)
.icon(IconName::Clipboard)
.on_click(move |_, _, cx| {
let text = cx.read_from_clipboard().and_then(|item| item.text());
pasted.update(cx, |pasted, cx| {
*pasted = Some(match text {
Some(text) => text.into(),
None => "The clipboard holds no text.".into(),
});
cx.notify();
let (read, pasted) = (cx.read_from_clipboard_async(), pasted.clone());
cx.spawn(async move |cx| {
let said: SharedString = match read.await {
Ok(item) => match item.and_then(|item| item.text()) {
Some(text) => text.into(),
None => "The clipboard holds no text.".into(),
},
Err(error) => format!("The clipboard stayed shut: {error:?}").into(),
};
cx.update(|cx| set(&pasted, Some(said), cx));
})
.detach();
}),
)
.when_some(shown, |row, text| {