platform-w3: net change of 2 commits

- platform-w3: written from its sheet
- platform-w3: review fixes (review-1)
This commit is contained in:
Martin Ball
2026-11-18 17:25:03 +00:00
parent 53b958dfef
commit 1ca3168b02
7 changed files with 284 additions and 68 deletions
@@ -1,9 +1,9 @@
//! The clipboard handle `Commands::clipboard` returns, over `runtime::egui::clipboard`.
//! The clipboard handle `Commands::clipboard` returns, over the clipboard `runtime::egui::clipboard` keeps installed.
use crate::runtime::egui::clipboard;
use crate::runtime::keys;
use crate::runtime::pending::Pending;
use craft_platform::clipboard::{ClipboardError, ClipboardImage, Flavor, Written};
use craft_platform::clipboard::{ClipboardError, ClipboardImage, Flavor, HTML, MATHML, RTF, Written};
use egui::{ColorImage, Context, Id};
use std::path::PathBuf;
use std::sync::Arc;
@@ -35,8 +35,25 @@ pub enum ClipItem {
impl ClipItem {
/// An item of an app-defined type: `bytes` under the MIME type `mime`.
pub fn custom(mime: impl Into<Arc<str>>, bytes: impl Into<Arc<[u8]>>) -> ClipItem {
let _ = (mime.into(), bytes.into());
todo!("pf.C-R3")
ClipItem::Custom { mime: mime.into(), bytes: bytes.into() }
}
/// The flavour the clipboard carries this item as; an image goes as straight-alpha `RGBA8`.
fn flavor(&self) -> Result<Flavor, ClipboardError> {
Ok(match self {
ClipItem::Text(text) => Flavor::text(text),
ClipItem::Html(html) => Flavor::new(HTML, html.as_bytes().to_vec()),
ClipItem::Rtf(rtf) => Flavor::new(RTF, rtf.as_bytes().to_vec()),
ClipItem::MathMl(mathml) => Flavor::new(MATHML, mathml.as_bytes().to_vec()),
ClipItem::Custom { mime, bytes } => Flavor::new(mime.to_string(), bytes.to_vec()),
ClipItem::Image(image) => {
let image = clipboard::clipboard_image(image);
if !image.is_whole() {
return Err(ClipboardError::BadImage);
}
Flavor::rgba8(&image)
}
})
}
}
@@ -53,8 +70,8 @@ pub struct ClipContent {
#[non_exhaustive]
pub struct ClipError(pub String);
/// The component's paste slot over the system clipboard. egui carries text and images, so `Html` and `Custom`
/// items are not written.
/// The component's paste slot over the installed clipboard (the host's, else egui's). Every call goes to the
/// clipboard installed in the context; the handle holds nothing else.
pub struct ClipboardHandle {
ctx: Context,
slot: Pending<ClipContent, ClipError>,
@@ -69,73 +86,65 @@ impl ClipboardHandle {
ClipboardHandle { ctx: ctx.clone(), slot }
}
/// The clipboard handle of `ctx`, over the installed clipboard.
/// The clipboard handle of `ctx`, over the installed clipboard, for code outside a component; its paste slot
/// stays loading, as no component takes the paste.
pub fn of(ctx: &Context) -> ClipboardHandle {
let _ = ctx;
todo!("pf.C-R3")
ClipboardHandle::new(ctx, None)
}
/// Offers `items` in the caller's order, as one offer, and says which flavour the clipboard kept.
/// Offers `items` in the caller's order, as one offer, and says which flavour the clipboard kept. A measuring run
/// writes nothing and answers `Written::Fenced`.
pub fn offer(&self, items: &[ClipItem]) -> Result<Written, ClipboardError> {
let _ = items;
todo!("pf.C-R3")
if !crate::runtime::measure::effect(&self.ctx, "clipboard::offer") {
return Ok(Written::Fenced);
}
let flavors = items.iter().map(ClipItem::flavor).collect::<Result<Vec<_>, _>>()?;
clipboard::with(&self.ctx, |clipboard| clipboard.write(&flavors))
}
/// The first of `mimes` the installed clipboard holds.
pub fn read(&self, mimes: &[&str]) -> Result<Option<Flavor>, ClipboardError> {
let _ = mimes;
todo!("pf.C-R3")
clipboard::with(&self.ctx, |clipboard| clipboard.read(mimes))
}
/// The clipboard's text.
pub fn read_text(&self) -> Result<Option<String>, ClipboardError> {
todo!("pf.C-R3")
clipboard::with(&self.ctx, |clipboard| clipboard.read_text())
}
/// The clipboard's image as straight-alpha RGBA8 pixels.
/// The clipboard's image as straight-alpha RGBA8 pixels; `ColorImage::from_rgba_unmultiplied` turns them back.
pub fn read_image(&self) -> Result<Option<ClipboardImage>, ClipboardError> {
todo!("pf.C-R3")
clipboard::with(&self.ctx, |clipboard| clipboard.read_image())
}
/// The files the clipboard holds.
pub fn read_files(&self) -> Result<Option<Vec<PathBuf>>, ClipboardError> {
todo!("pf.C-R3")
clipboard::with(&self.ctx, |clipboard| clipboard.read_files())
}
/// Whether the clipboard holds one of `mimes`.
pub fn has(&self, mimes: &[&str]) -> bool {
let _ = mimes;
todo!("pf.C-R3")
clipboard::with(&self.ctx, |clipboard| clipboard.has(mimes))
}
/// Whether the clipboard still holds what this app last offered.
pub fn holds_ours(&self) -> bool {
todo!("pf.C-R3")
clipboard::with(&self.ctx, |clipboard| clipboard.holds_ours())
}
/// The MIME names of the formats on the clipboard.
pub fn formats(&self) -> Vec<String> {
todo!("pf.C-R3")
clipboard::with(&self.ctx, |clipboard| clipboard.formats())
}
/// Whether a late paste offer arrived this frame; true in every pass of that frame.
pub fn arrived(&self) -> bool {
todo!("pf.C-R3")
clipboard::arrived(&self.ctx)
}
/// Writes every flavour of `items` that the clipboard carries.
/// Offers `items` as one offer ([`offer`](Self::offer)), for a caller that does not ask what was kept.
pub fn put(&self, items: &[ClipItem]) {
if !crate::runtime::measure::effect(&self.ctx, "clipboard::put") {
return;
}
for item in items {
match item {
ClipItem::Text(text) => clipboard::copy_text(&self.ctx, text.to_string()),
ClipItem::Image(image) => clipboard::copy_image(&self.ctx, (**image).clone()),
// P3(platform-w3): pf.C-R3: the new items are written through `offer`.
ClipItem::Html(_) | ClipItem::Rtf(_) | ClipItem::MathMl(_) | ClipItem::Custom { .. } => {}
}
}
let _ = self.offer(items);
}
/// The pasted content: ready in the pass that delivers the paste to the focused component that lists Paste.
+132 -22
View File
@@ -1,17 +1,60 @@
//! Clipboard output commands.
//! The installed clipboard, its egui backend, and the once-per-frame late paste flag.
use craft_platform::clipboard::{Clipboard, ClipboardBackend, ClipboardError, ClipboardImage, Flavor};
use crate::runtime::pass_state;
use craft_platform::clipboard::{Clipboard, ClipboardBackend, ClipboardError, ClipboardImage, Flavor, RGBA8, TEXT};
use egui::{ColorImage, Context};
use std::path::PathBuf;
use std::sync::{Arc, Mutex, PoisonError};
/// The backend the runtime installs when the host gives no clipboard: egui's own copy and paste commands.
#[allow(dead_code)] // P3(platform-w3): pf.C-R2
pub(crate) struct EguiClipboard;
/// The backend the runtime installs when the host gives no clipboard: egui's own copy and paste commands. egui
/// carries one value of text or of an image, and the last copy command of a frame wins, so a write acts on the first
/// flavour egui carries and skips the rest. It holds no `Context` (the context owns the clipboard, so a clone would
/// be a cycle): a write is left in a slot that `with` hands to the context's output.
pub(crate) struct EguiClipboard {
copies: Copies,
}
/// The copy command an `EguiClipboard` write leaves for `with`.
enum EguiCopy {
Text(String),
Image(ColorImage),
}
/// Where an `EguiClipboard` leaves its write until `with` sends it to egui.
type Copies = Arc<Mutex<Option<EguiCopy>>>;
impl EguiClipboard {
/// The backend that leaves its writes in `copies`.
fn new(copies: Copies) -> Self {
EguiClipboard { copies }
}
fn leave(&self, copy: EguiCopy) {
*self.copies.lock().unwrap_or_else(PoisonError::into_inner) = Some(copy);
}
}
impl ClipboardBackend for EguiClipboard {
fn write(&mut self, flavors: &[Flavor]) -> Result<usize, ClipboardError> {
let _ = flavors;
todo!("pf.C-R2")
if flavors.is_empty() {
self.leave(EguiCopy::Text(String::new()));
return Ok(0);
}
for (at, flavor) in flavors.iter().enumerate() {
if flavor.mime == TEXT
&& let Ok(text) = std::str::from_utf8(&flavor.data)
{
self.leave(EguiCopy::Text(text.to_owned()));
return Ok(at);
}
if flavor.mime == RGBA8
&& let Some(image) = flavor.rgba8_image().and_then(|image| color_image(&image))
{
self.leave(EguiCopy::Image(image));
return Ok(at);
}
}
Err(ClipboardError::NoFormat)
}
/// egui delivers pasted text only as an input event, so a read finds nothing.
@@ -20,44 +63,111 @@ impl ClipboardBackend for EguiClipboard {
Ok(None)
}
/// egui has no clipboard read.
fn read_image(&mut self, limit: u64) -> Result<Option<ClipboardImage>, ClipboardError> {
let _ = limit;
todo!("pf.C-R2")
Ok(None)
}
/// egui has no clipboard read.
fn read_files(&mut self, limit: usize) -> Result<Option<Vec<PathBuf>>, ClipboardError> {
let _ = limit;
todo!("pf.C-R2")
Ok(None)
}
/// egui cannot look at the clipboard, so it holds nothing it could name.
fn has(&mut self, mimes: &[&str]) -> bool {
let _ = mimes;
todo!("pf.C-R2")
false
}
}
/// Runs `f` on the clipboard installed in `ctx`'s runtime memory.
#[allow(dead_code)] // P3(platform-w3): pf.C-R2
/// The clipboard of a context and whether a late paste arrived this frame. The clipboard is an install-time handle,
/// shared so `with` can lend it after the pass-state borrow ends.
#[derive(Default)]
pub(crate) struct Installed {
clipboard: Option<Arc<Mutex<Clipboard>>>,
/// What the egui backend wrote, until `with` sends it to the context.
copies: Copies,
/// Assigned once per frame by `begin_frame`, so it is a fact of that frame alone.
arrived: bool,
}
/// Keeps `clipboard` as the context's clipboard; `None` leaves the choice to `with`, which builds egui's.
pub(crate) fn install(ctx: &Context, clipboard: Option<Clipboard>) {
pass_state::with::<Installed, _>(ctx, |installed| {
installed.clipboard = clipboard.map(|clipboard| Arc::new(Mutex::new(clipboard)));
installed.arrived = false;
});
}
/// Runs `f` on the clipboard installed in `ctx`'s runtime memory: the host's, else egui's, built here once.
pub(crate) fn with<R>(ctx: &Context, f: impl FnOnce(&mut Clipboard) -> R) -> R {
let _ = (ctx, f);
todo!("pf.C-R2")
let (shared, copies) = pass_state::with::<Installed, _>(ctx, |installed| {
let copies = Arc::clone(&installed.copies);
let clipboard = installed
.clipboard
.get_or_insert_with(|| Arc::new(Mutex::new(Clipboard::new(EguiClipboard::new(Arc::clone(&copies))))));
(Arc::clone(clipboard), copies)
});
let result = {
let mut clipboard = shared.lock().unwrap_or_else(PoisonError::into_inner);
f(&mut clipboard)
};
let copy = copies.lock().unwrap_or_else(PoisonError::into_inner).take();
match copy {
Some(EguiCopy::Text(text)) => ctx.copy_text(text),
Some(EguiCopy::Image(image)) => ctx.copy_image(image),
None => {}
}
result
}
/// Once per frame, in the pass that receives input: takes a late paste offer for this frame.
#[allow(dead_code)] // P3(platform-w3): pf.C-R2
/// Once per frame, from `set_input`: takes a late paste offer for this frame. The flag is assigned, never or-ed, so it
/// holds in every pass of this frame (passes a frame reruns do not call `set_input`) and goes with the next frame.
pub(crate) fn begin_frame(ctx: &Context) {
let _ = ctx;
todo!("pf.C-R2")
let arrived = with(ctx, Clipboard::take_arrived_paste);
pass_state::with::<Installed, _>(ctx, |installed| installed.arrived = arrived);
}
/// Puts `text` on the system clipboard.
/// Whether a late paste offer arrived this frame.
pub(crate) fn arrived(ctx: &Context) -> bool {
pass_state::with::<Installed, _>(ctx, |installed| installed.arrived)
}
/// `image` as straight-alpha RGBA8 pixels, the form every clipboard flavour of a bitmap carries. A side too long for
/// a `u32` gives an image that is not whole, which a write refuses.
pub(crate) fn clipboard_image(image: &ColorImage) -> ClipboardImage {
let [width, height] = image.size;
ClipboardImage {
width: u32::try_from(width).unwrap_or(0),
height: u32::try_from(height).unwrap_or(0),
rgba: image.pixels.iter().flat_map(|pixel| pixel.to_srgba_unmultiplied()).collect(),
}
}
/// The pixels of `image` for egui, `None` when its pixels do not match its size.
fn color_image(image: &ClipboardImage) -> Option<ColorImage> {
if !image.is_whole() {
return None;
}
let size = [usize::try_from(image.width).ok()?, usize::try_from(image.height).ok()?];
Some(ColorImage::from_rgba_unmultiplied(size, &image.rgba))
}
/// Puts `text` on the installed clipboard.
pub(crate) fn copy_text(ctx: &Context, text: String) {
ctx.copy_text(text);
with(ctx, |clipboard| {
let _ = clipboard.write_text(&text);
});
}
/// Puts `image` on the system clipboard.
/// Puts `image` on the installed clipboard.
pub(crate) fn copy_image(ctx: &Context, image: ColorImage) {
ctx.copy_image(image);
with(ctx, |clipboard| {
let _ = clipboard.write_image(&clipboard_image(&image));
});
}
/// Asks the platform for the clipboard text, which arrives as a paste event.
+8 -2
View File
@@ -3,8 +3,8 @@
use crate::runtime::commands::{self, CommandInput, CommandSet as _, Fired};
use crate::runtime::egui::input::{self as raw_input, Arrived, HeldInput, RawInput};
use crate::runtime::egui::memory as store;
use crate::runtime::egui::{pass, scale, style};
use crate::runtime::env::{Env, RootEnv, WindowKey};
use crate::runtime::egui::{clipboard, pass, scale, style};
use crate::runtime::env::{AltCodePages, Env, RootEnv, WheelSpeed, WindowKey};
use crate::runtime::pass_state;
use crate::runtime::{access, cursor, drag, focus, ime, keys, layout_memory, measure, memory, motion, overlay, pointer, toast, wheel, windows};
use craft_behavior::{DocKey, GestureId};
@@ -305,6 +305,7 @@ pub fn set_input(ctx: &Context, input: FrameInput) {
ran
});
commands::set_input(ctx, &commands);
clipboard::begin_frame(ctx);
windows::set_input(ctx);
debug_assert!(hooks_ran, "the runtime plugin's hooks did not run for the previous pass: drive frames with `Context::run_ui` or `run_pass`");
scale::set_interface_scale(ctx, scale.0);
@@ -341,6 +342,11 @@ fn frame_hit(ctx: &Context) -> HitSizes {
pass_state::with::<FrameState, _>(ctx, |state| state.hit.as_ref().map(|(_, hit)| *hit)).unwrap_or_else(|| resolved_hit(&AppSizes::default()))
}
/// The wheel speed and Alt-code pages of the frame's root values; the defaults before the app sets any input.
pub(crate) fn root_input(ctx: &Context) -> (WheelSpeed, AltCodePages) {
pass_state::with::<FrameState, _>(ctx, |state| state.input.as_ref().map(|input| (input.root.wheel, input.root.alt_codes))).unwrap_or_default()
}
/// How far a press may move and still be a click, in points: the app's hit tolerances (`HitSizes::slop`). egui's own
/// click options stay the app's.
pub(crate) fn slop(ctx: &Context) -> f32 {
+5 -4
View File
@@ -1,6 +1,6 @@
//! `runtime::install`: adds the runtime plugin once and sets the egui options the runtime owns.
use crate::runtime::egui::{input, plugin};
use crate::runtime::egui::{clipboard, input, plugin};
use crate::runtime::env::{SystemReader, system};
use crate::runtime::pen::PenSource;
use crate::runtime::{commands, frame, pen, windows};
@@ -90,9 +90,9 @@ impl InstallSpec {
}
/// Installs the host's clipboard (system, browser event, memory) in place of the runtime's own.
pub fn clipboard(self, clipboard: craft_platform::clipboard::Clipboard) -> Self {
let _ = clipboard;
todo!("pf.C-R1")
pub fn clipboard(mut self, clipboard: craft_platform::clipboard::Clipboard) -> Self {
self.clipboard = Some(clipboard);
self
}
/// Loads the stories' command sets too, for an install that shows stories.
@@ -211,6 +211,7 @@ pub fn install(ctx: &Context, spec: InstallSpec) -> Result<(), InstallError> {
input::set_wheel_modifiers(ctx, spec.wheel.zoom, spec.wheel.sideways);
system::install(ctx, spec.system);
pen::install(ctx, spec.pen);
clipboard::install(ctx, spec.clipboard);
windows::install(ctx, with_browser_caps(spec.shell_info), spec.window_system, spec.placement, spec.frame, spec.app_id);
frame::set_frame_layers(ctx, spec.frame_layers);
frame::seed_hooked_passes(ctx);
@@ -107,6 +107,7 @@ pass_state! {
inspect: crate::runtime::inspect::Log,
recorder: crate::runtime::replay::Recorder,
pen: crate::runtime::pen::InstalledPen,
clipboard: crate::runtime::egui::clipboard::Installed,
#[cfg(feature = "testing")]
noted: crate::runtime::egui::widgets::noted::Noted,
#[cfg(feature = "testing")]
@@ -1 +1,78 @@
//! Clipboard trials (owed by platform-w3: this placeholder lets shell-w1's `mod clipboard;` line compile; platform-w3 writes the trials).
//! The clipboard handle: a write is one offer of every flavour, and a late paste reads only in the frame it arrived in.
use craft_platform::clipboard::{Clipboard, EventClipboard, Flavor, HTML, MemoryClipboard, RTF, TEXT};
use craft_ui::runtime::commands::{ClipItem, ClipboardHandle};
use craft_ui::runtime::frame;
use craft_ui::testing::{Frames, install_spec, trial};
use std::sync::Arc;
use std::sync::atomic::{AtomicU64, Ordering};
/// The text of the clipboard's `mime` flavour.
fn text_of(handle: &ClipboardHandle, mime: &str) -> Option<String> {
handle.read(&[mime]).expect("the clipboard reads").map(|flavor| String::from_utf8(flavor.data).expect("the flavour is UTF-8"))
}
/// One frame that puts `items` (once, in its first pass) and reads every text flavour back in each pass.
fn put_frame(frames: &mut Frames, items: Vec<ClipItem>) -> Vec<[Option<String>; 3]> {
let mut items = Some(items);
let mut seen = Vec::new();
frames.frame(Vec::new(), |ui| {
let handle = ClipboardHandle::of(ui.ctx());
if let Some(items) = items.take() {
handle.put(&items);
}
seen.push([TEXT, HTML, RTF].map(|mime| text_of(&handle, mime)));
});
seen
}
/// One frame, counted as the host counts frames (once per `set_input`), and what each of its passes saw: whether a
/// late paste arrived and the clipboard's text. With `rerun` the frame reruns its first pass.
fn paste_frame(frames: &mut Frames, frame_nr: &AtomicU64, rerun: bool) -> Vec<(bool, Option<String>)> {
frame_nr.fetch_add(1, Ordering::SeqCst);
let mut passes = Vec::new();
let mut reran = false;
frames.frame(Vec::new(), |ui| {
let handle = ClipboardHandle::of(ui.ctx());
passes.push((handle.arrived(), handle.read_text().expect("the clipboard reads")));
if rerun && !reran && frame::discardable(ui.ctx()) {
reran = true;
frame::discard_pass(ui.ctx(), "clipboard trial: a rerun pass");
}
});
passes
}
#[trial]
fn a_clipboard_handle_writes_one_offer_and_a_late_paste_reads_only_in_its_frame() {
let mut frames = Frames::uninstalled();
craft_ui::install(&frames.ctx, install_spec().clipboard(Clipboard::new(MemoryClipboard::default()))).expect("the runtime installs once");
let rich = [ClipItem::Text("plain".into()), ClipItem::Html("<b>rich</b>".into()), ClipItem::Rtf("{\\rtf1 rich}".into())];
let seen = put_frame(&mut frames, rich.to_vec());
let all = [Some("plain".to_owned()), Some("<b>rich</b>".to_owned()), Some("{\\rtf1 rich}".to_owned())];
assert_eq!(seen.last(), Some(&all), "one put offers text, HTML and RTF together");
let handle = ClipboardHandle::of(&frames.ctx);
assert!(handle.has(&[RTF]), "the clipboard holds the RTF flavour of the offer");
assert!(handle.holds_ours(), "the clipboard holds what the app offered");
let seen = put_frame(&mut frames, vec![ClipItem::Text("again".into())]);
assert_eq!(seen.last(), Some(&[Some("again".to_owned()), None, None]), "a later put replaces every flavour of the earlier one");
let frame_nr = Arc::new(AtomicU64::new(0));
let counter = Arc::clone(&frame_nr);
let event = EventClipboard::new(move || counter.load(Ordering::SeqCst), |_: &[Flavor]| Ok(0));
let late = event.late_offers();
let mut frames = Frames::uninstalled();
craft_ui::install(&frames.ctx, install_spec().clipboard(Clipboard::new(event))).expect("the runtime installs once");
assert_eq!(paste_frame(&mut frames, &frame_nr, false), [(false, None)], "nothing arrived before the offer");
late.offer(vec![Flavor::text("late"), Flavor::new(HTML, b"<i>late</i>".to_vec())]);
let passes = paste_frame(&mut frames, &frame_nr, true);
assert_eq!(passes.len(), 2, "the frame reran its pass");
assert!(
passes.iter().all(|pass| *pass == (true, Some("late".to_owned()))),
"the late paste arrived and reads in every pass of its frame, the rerun one included: {passes:?}"
);
assert_eq!(paste_frame(&mut frames, &frame_nr, false), [(false, None)], "the arrival and its flavours stay with the frame it came in");
}
+16 -4
View File
@@ -3144,9 +3144,20 @@ The command board: the registry and typed sets, per-frame state, the queue, firi
- `pub const fn toggle(self) -> ChromeToggle`. The toggle the command writes to the output.
- `craft_ui::runtime::commands::ClipContent`: `pub struct ClipContent { pub text: Option<Arc<str>> }`. What a paste delivers.
- `craft_ui::runtime::commands::ClipError`: `pub struct ClipError(pub String)`. Why a paste has no content.
- `craft_ui::runtime::commands::ClipItem`: `pub enum ClipItem { Text(Arc<str>), Html(Arc<str>), Image(Arc<ColorImage>), Custom { mime: Arc<str>, bytes: Arc<[u8]> } }`. One clipboard item.
- `craft_ui::runtime::commands::ClipboardHandle`: `pub struct ClipboardHandle`. The component's paste slot over the system clipboard. egui carries text and images, so `Html` and `Custom`
- `pub fn put(&self, items: &[ClipItem])`. Writes every flavour of `items` that the clipboard carries.
- `craft_ui::runtime::commands::ClipItem`: `pub enum ClipItem { Text(Arc<str>), Html(Arc<str>), Image(Arc<ColorImage>), Rtf(Arc<str>), MathMl(Arc<str>), Custom { mime: Arc<str>, bytes: Arc<[u8]> } }`. One clipboard item.
- `pub fn custom(mime: impl Into<Arc<str>>, bytes: impl Into<Arc<[u8]>>) -> ClipItem`. An item of an app-defined type: `bytes` under the MIME type `mime`.
- `craft_ui::runtime::commands::ClipboardHandle`: `pub struct ClipboardHandle`. The component's paste slot over the installed clipboard (the host's, else egui's). Every call goes to the
- `pub fn of(ctx: &Context) -> ClipboardHandle`. The clipboard handle of `ctx`, over the installed clipboard, for code outside a component; its paste slot
- `pub fn offer(&self, items: &[ClipItem]) -> Result<Written, ClipboardError>`. Offers `items` in the caller's order, as one offer, and says which flavour the clipboard kept. A measuring run
- `pub fn read(&self, mimes: &[&str]) -> Result<Option<Flavor>, ClipboardError>`. The first of `mimes` the installed clipboard holds.
- `pub fn read_text(&self) -> Result<Option<String>, ClipboardError>`. The clipboard's text.
- `pub fn read_image(&self) -> Result<Option<ClipboardImage>, ClipboardError>`. The clipboard's image as straight-alpha RGBA8 pixels; `ColorImage::from_rgba_unmultiplied` turns them back.
- `pub fn read_files(&self) -> Result<Option<Vec<PathBuf>>, ClipboardError>`. The files the clipboard holds.
- `pub fn has(&self, mimes: &[&str]) -> bool`. Whether the clipboard holds one of `mimes`.
- `pub fn holds_ours(&self) -> bool`. Whether the clipboard still holds what this app last offered.
- `pub fn formats(&self) -> Vec<String>`. The MIME names of the formats on the clipboard.
- `pub fn arrived(&self) -> bool`. Whether a late paste offer arrived this frame; true in every pass of that frame.
- `pub fn put(&self, items: &[ClipItem])`. Offers `items` as one offer ([`offer`](Self::offer)), for a caller that does not ask what was kept.
- `pub fn paste(&self) -> &Pending<ClipContent, ClipError>`. The pasted content: ready in the pass that delivers the paste to the focused component that lists Paste.
- `craft_ui::runtime::commands::CommandDef`: re-export of `craft_keymap::CommandDef` (outside these crates).
- `craft_ui::runtime::commands::CommandDefError`: `pub enum CommandDefError { Binding { command: &'static str, error: BindingError }, Scope { command: &'static str }, Duplicate { command: String } }`. Why a command definition is unusable.
@@ -3570,13 +3581,14 @@ Decision records and findings: what each pipeline step did, kept in frames a tes
`runtime::install`: adds the runtime plugin once and sets the egui options the runtime owns.
- `craft_ui::runtime::install::InstallError`: `pub enum InstallError { AlreadyInstalled, DuplicateStyle(DuplicateStyle), Commands(commands::CommandDefError) }`. Why `install` refused a spec.
- `craft_ui::runtime::install::InstallSpec`: `pub struct InstallSpec { pub shell_info: ShellInfo, pub window_system: Arc<dyn WindowSystem>, pub placement: Option<Arc<Mutex<Store>>>, pub frame_layers: Option<fn(&Context)>, pub looks: StyleReplacements, pub frame: Option<Decision>, pub system: SystemReader }`. What `install` takes.
- `craft_ui::runtime::install::InstallSpec`: `pub struct InstallSpec { pub shell_info: ShellInfo, pub window_system: Arc<dyn WindowSystem>, pub placement: Option<Arc<Mutex<Store>>>, pub frame_layers: Option<fn(&Context)>, pub looks: StyleReplacements, pub frame: Option<Decision>, pub system: SystemReader, pub clipboard: Option<craft_platform::clipboard::Clipboard> }`. What `install` takes.
- `pub fn new(shell_info: ShellInfo, window_system: Arc<dyn WindowSystem>) -> Self`. A spec for `shell_info` and `window_system`, with no ghost-layer painter.
- `pub fn placement(mut self, store: Arc<Mutex<Store>>) -> Self`. Sets the store viewport mounts save their window placement in.
- `pub fn looks(mut self, looks: impl Into<StyleReplacements>) -> Self`. Sets the app's style replacements.
- `pub fn system(mut self, reader: SystemReader) -> Self`. Sets the reader of the OS's appearance; the host starts it (`SystemReader::start`) with a wake that repaints.
- `pub fn frame(mut self, decision: Decision) -> Self`. Sets the root window's decided frame (`craft_window::policy::decide_for`).
- `pub fn frame_layers(mut self, painter: Option<fn(&Context)>) -> Self`. Sets the end hook's ghost-layer painter.
- `pub fn clipboard(mut self, clipboard: craft_platform::clipboard::Clipboard) -> Self`. Installs the host's clipboard (system, browser event, memory) in place of the runtime's own.
- `craft_ui::runtime::install::install`: `pub fn install(ctx: &Context, spec: InstallSpec) -> Result<(), InstallError>`. Adds the runtime plugin to `ctx` and sets the egui options the runtime owns: interface scale is a command, and
## `craft_ui::runtime::keys`