mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 10:18:05 +00:00
Docs: intra-doc links resolve under -D warnings
This commit is contained in:
@@ -402,7 +402,7 @@ impl<'a> ShortcutsDialog<'a> {
|
||||
|
||||
/// Sets the value `field` names in `state`, as the user editing that control would
|
||||
/// (`search`, `area`, `command`, `pressed`; `assign` true presses Assign; `remove` takes the text
|
||||
/// of one of the command's keys, as [`DialogSnapshot::keys`] reports it), for automation. It builds the words `Env` that [`DialogState::set_field`] needs. `Err` says why
|
||||
/// of one of the command's keys, as [`DialogSnapshot::keys`] reports it), for automation. It builds the words `Env` that `DialogState::set_field` needs. `Err` says why
|
||||
/// the field was refused.
|
||||
pub fn set_json_field(self, ui: &Ui, state: &mut DialogState, field: &str, value: &serde_json::Value) -> Result<(), String> {
|
||||
use craft_ui::dialog::FieldRefusal;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The rulers around one page of a [`PageView`](super::PageView): [`VerticalRuler`] with table row grips, and
|
||||
//! [`PageRulers`], which joins a [`TextRuler`](craft_text::ui::ruler::TextRuler), a [`VerticalRuler`] and
|
||||
//! [`MarginHandles`](super::MarginHandles) around the page.
|
||||
//! [`PageRulers`], which joins a [`TextRuler`], a [`VerticalRuler`] and
|
||||
//! [`MarginHandles`] around the page.
|
||||
|
||||
#[cfg(feature = "screen-testing")]
|
||||
mod stories;
|
||||
|
||||
@@ -528,7 +528,7 @@ pub struct TextMarks<'a> {
|
||||
areas: &'a [MarkArea],
|
||||
}
|
||||
|
||||
/// What a [`MarkArea`] marks; each kind has its [`MarkLook`] fill.
|
||||
/// What a [`MarkArea`] marks; each kind has its `MarkLook` fill.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum MarkKind {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! replacing what the user copied ([`Clipboard::set_synthetic`]), and remembers what it wrote
|
||||
//! last so the app can tell its own copy from one made in another app
|
||||
//! ([`Clipboard::holds_ours`]).
|
||||
//! - [`ClipboardBackend`]: where the bytes go. [`SystemClipboard`] is the OS clipboard on the
|
||||
//! - [`ClipboardBackend`]: where the bytes go. `SystemClipboard` is the OS clipboard on the
|
||||
//! desktop (feature `clipboard-system`, opened on first use); [`EventClipboard`] is the
|
||||
//! browser's, fed from paste events, with a queue for pastes that arrive between passes
|
||||
//! ([`LateOffers`]); [`MemoryClipboard`] holds flavours in memory for tests and hosts without
|
||||
|
||||
@@ -16,21 +16,21 @@ use super::types::{ClipboardError, ClipboardImage, Flavor};
|
||||
pub enum Written {
|
||||
/// The clipboard holds the new contents.
|
||||
Written,
|
||||
/// Dropped: the write came from synthetic input ([`Clipboard::set_synthetic`]), and the
|
||||
/// Dropped: the write came from synthetic input ([`Clipboard::set_synthetic`](crate::clipboard::Clipboard::set_synthetic)), and the
|
||||
/// clipboard keeps what the user copied.
|
||||
Fenced,
|
||||
}
|
||||
|
||||
/// Where clipboard bytes go: the OS clipboard, the browser's, or a test's.
|
||||
///
|
||||
/// `Send` so a [`ClipboardProbe`] can own one on its worker thread. Every method may block on a
|
||||
/// `Send` so a [`ClipboardProbe`](crate::clipboard::ClipboardProbe) can own one on its worker thread. Every method may block on a
|
||||
/// slow clipboard owner (an X11 client that never answers); the UI thread calls only
|
||||
/// [`Clipboard`]'s reads and writes, on a user's copy or paste.
|
||||
/// [`Clipboard`](crate::clipboard::Clipboard)'s reads and writes, on a user's copy or paste.
|
||||
pub trait ClipboardBackend: Send {
|
||||
/// Replaces the clipboard's contents with `flavors`, best first, as one offer; none empties
|
||||
/// it. A backend may hold fewer flavours than an app offers, so it answers the index in
|
||||
/// `flavors` of the one it wrote (`0` when it emptied the clipboard);
|
||||
/// [`Clipboard::holds_ours`] compares that one.
|
||||
/// [`Clipboard::holds_ours`](crate::clipboard::Clipboard::holds_ours) compares that one.
|
||||
fn write(&mut self, flavors: &[Flavor]) -> Result<usize, ClipboardError>;
|
||||
/// The first of `mimes` the clipboard holds, at most `limit` bytes of it (more is
|
||||
/// [`ClipboardError::TooLarge`]). `BITMAP` matches any bitmap, returned as an `RGBA8` flavor.
|
||||
@@ -42,7 +42,7 @@ pub trait ClipboardBackend: Send {
|
||||
/// Does the clipboard hold one of `mimes`? Cheap enough to ask a few times a second.
|
||||
fn has(&mut self, mimes: &[&str]) -> bool;
|
||||
/// The flavours of a paste the host delivered as an event (the browser's Paste). Only
|
||||
/// [`EventClipboard`] keeps them; the system clipboard ignores them.
|
||||
/// [`EventClipboard`](crate::clipboard::EventClipboard) keeps them; the system clipboard ignores them.
|
||||
fn offer(&mut self, _flavors: Vec<Flavor>) {}
|
||||
/// The MIME names of the formats on offer.
|
||||
fn formats(&mut self) -> Vec<String> {
|
||||
@@ -107,7 +107,7 @@ impl SystemClipboard {
|
||||
Self { handle: None, unreadable: false, decode: None, offer: offer::Offer::new(), owner: owner_token() }
|
||||
}
|
||||
|
||||
/// Decodes a `image/png` flavor to pixels for [`ClipboardBackend::write`], which hands the
|
||||
/// Decodes a `image/png` flavor to pixels for [`ClipboardBackend::write`](crate::clipboard::ClipboardBackend::write), which hands the
|
||||
/// platform pixels only. Without one, a write offers no PNG.
|
||||
pub fn decoder(mut self, decode: impl Fn(&[u8]) -> Option<ClipboardImage> + Send + 'static) -> Self {
|
||||
self.decode = Some(Box::new(decode));
|
||||
|
||||
@@ -14,7 +14,7 @@ use super::types::{BITMAP, ClipboardError, ClipboardImage, Flavor, RGBA8, URI_LI
|
||||
///
|
||||
/// [`offer`](Self::offer) holds one paste's flavours for the pass it was offered in. The
|
||||
/// clipboard counts passes itself (`pass`), so a menu Paste in a later pass finds nothing and
|
||||
/// [`Clipboard::has`] is false: the browser can't be read outside a paste event. The app does
|
||||
/// [`Clipboard::has`](crate::clipboard::Clipboard::has) is false: the browser can't be read outside a paste event. The app does
|
||||
/// nothing at the end of a pass.
|
||||
pub struct EventClipboard {
|
||||
pasted: Vec<Flavor>,
|
||||
@@ -30,7 +30,7 @@ struct LateInner {
|
||||
wake: Mutex<Option<Box<dyn Fn() + Send + Sync>>>,
|
||||
}
|
||||
|
||||
/// The queue of an [`EventClipboard`] for a paste the browser delivers outside a pass; `Send + Sync`.
|
||||
/// The queue of an [`EventClipboard`](crate::clipboard::EventClipboard) for a paste the browser delivers outside a pass; `Send + Sync`.
|
||||
#[derive(Clone)]
|
||||
pub struct LateOffers {
|
||||
inner: Arc<LateInner>,
|
||||
@@ -49,13 +49,13 @@ impl LateOffers {
|
||||
/// The number of the host's current pass; it changes when a pass ends.
|
||||
pub(super) type PassClock = Box<dyn Fn() -> u64 + Send>;
|
||||
|
||||
/// Where an [`EventClipboard`]'s writes go.
|
||||
/// Where an [`EventClipboard`](crate::clipboard::EventClipboard)'s writes go.
|
||||
pub(super) type CopyOut = Box<dyn FnMut(&[Flavor]) -> Result<usize, ClipboardError> + Send>;
|
||||
|
||||
impl EventClipboard {
|
||||
/// `pass` answers the host's pass number (any counter that changes when a pass ends). `out`
|
||||
/// puts the flavours where the host's copy goes and answers the index of the one it wrote
|
||||
/// ([`ClipboardBackend::write`]).
|
||||
/// ([`ClipboardBackend::write`](crate::clipboard::ClipboardBackend::write)).
|
||||
pub fn new(pass: impl Fn() -> u64 + Send + 'static, out: impl FnMut(&[Flavor]) -> Result<usize, ClipboardError> + Send + 'static) -> Self {
|
||||
let late = LateOffers { inner: Arc::new(LateInner { queue: Mutex::new(VecDeque::new()), wake: Mutex::new(None) }) };
|
||||
Self { pasted: Vec::new(), offered_in: 0, pass: Box::new(pass), out: Box::new(out), late }
|
||||
|
||||
@@ -121,7 +121,7 @@ impl Clipboard {
|
||||
}
|
||||
|
||||
/// Does the clipboard hold one of `mimes`? For Paste's enabled state on the web and in
|
||||
/// tests; on the desktop a [`ClipboardProbe`] asks off the UI thread.
|
||||
/// tests; on the desktop a [`ClipboardProbe`](crate::clipboard::ClipboardProbe) asks off the UI thread.
|
||||
pub fn has(&mut self, mimes: &[&str]) -> bool {
|
||||
self.backend.has(mimes)
|
||||
}
|
||||
@@ -172,8 +172,8 @@ impl Clipboard {
|
||||
matches!(self.ours, Some(Ours::Image(signature)) if signature == image_signature(image.width, image.height, &image.rgba))
|
||||
}
|
||||
|
||||
/// A paste event's flavours for the backend ([`ClipboardBackend::offer`]); the web shell
|
||||
/// calls it with [`flavors_from_event`] before the paste command runs.
|
||||
/// A paste event's flavours for the backend ([`ClipboardBackend::offer`](crate::clipboard::ClipboardBackend::offer)); the web shell
|
||||
/// calls it with `flavors_from_event` before the paste command runs.
|
||||
pub fn offer_paste(&mut self, flavors: Vec<Flavor>) {
|
||||
self.backend.offer(flavors);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ pub struct ClipboardProbe {
|
||||
|
||||
impl ClipboardProbe {
|
||||
/// Starts the worker with the backend `make` builds there, asking for `mimes`. `None` on wasm
|
||||
/// or when the thread can't be spawned: the app asks [`Clipboard::has`] in line instead.
|
||||
/// or when the thread can't be spawned: the app asks [`Clipboard::has`](crate::clipboard::Clipboard::has) in line instead.
|
||||
// vectorcraft: crates/ui-egui/src/clipboard_probe.rs:33 Probe::start
|
||||
pub fn start(make: Box<dyn FnOnce() -> Box<dyn ClipboardBackend> + Send>, mimes: Vec<&'static str>, wake: Wake) -> Option<Self> {
|
||||
if cfg!(target_arch = "wasm32") {
|
||||
|
||||
@@ -20,10 +20,10 @@ pub const PDF: &str = "application/pdf";
|
||||
/// `text/uri-list`: copied files, one `file://` URI per line (CRLF line ends, RFC 2483).
|
||||
pub const URI_LIST: &str = "text/uri-list";
|
||||
/// Any bitmap the clipboard holds (`image/png`, `image/bmp`, a TIFF on macOS…). A read returns it
|
||||
/// as an [`RGBA8`] flavor (never PNG: this crate has no PNG encoder); [`ClipboardBackend::read_image`]
|
||||
/// returns it as [`ClipboardImage`]. Also for [`ClipboardBackend::has`] and [`Clipboard::has`].
|
||||
/// as an [`RGBA8`] flavor (never PNG: this crate has no PNG encoder); [`ClipboardBackend::read_image`](crate::clipboard::ClipboardBackend::read_image)
|
||||
/// returns it as [`ClipboardImage`]. Also for [`ClipboardBackend::has`](crate::clipboard::ClipboardBackend::has) and [`Clipboard::has`](crate::clipboard::Clipboard::has).
|
||||
pub const BITMAP: &str = "image/*";
|
||||
/// A raw bitmap as [`EventClipboard`] carries it: width and height as little-endian `u32`s, then
|
||||
/// A raw bitmap as [`EventClipboard`](crate::clipboard::EventClipboard) carries it: width and height as little-endian `u32`s, then
|
||||
/// the straight RGBA8 pixels. The form an `RGBA8` flavour carries.
|
||||
pub const RGBA8: &str = "image/x-rgba8";
|
||||
|
||||
@@ -77,7 +77,7 @@ pub struct ClipboardImage {
|
||||
|
||||
impl ClipboardImage {
|
||||
/// True when the size is not zero and `rgba` holds exactly `width * height * 4` bytes.
|
||||
/// [`Clipboard::read_image`] drops images that fail this (PhotoCraft
|
||||
/// [`Clipboard::read_image`](crate::clipboard::Clipboard::read_image) drops images that fail this (PhotoCraft
|
||||
/// `import_os_clipboard`'s filter).
|
||||
// pc: crates/ui-egui/src/app/clipboard.rs:60 image.filter
|
||||
pub fn is_whole(&self) -> bool {
|
||||
|
||||
@@ -85,7 +85,7 @@ impl SettingsFiles for DiskFiles {
|
||||
|
||||
/// An advisory lock on `.<file>.lock` beside `path`, so two processes saving at once (logging out closes every
|
||||
/// window together) take turns at checking, merging and replacing the file instead of one losing the other's
|
||||
/// changes. `None` (save unlocked) when the lock file cannot be opened or is not free within [`LOCK_WAIT`].
|
||||
/// changes. `None` (save unlocked) when the lock file cannot be opened or is not free within `LOCK_WAIT`.
|
||||
fn lock(&self, path: &Path) -> Option<Box<dyn Any + Send>> {
|
||||
let name = path.file_name().map_or_else(|| "config.toml".into(), |n| n.to_string_lossy().into_owned());
|
||||
let lock = path.with_file_name(format!(".{name}.lock"));
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn ruler_text(unit: DocUnit, units: &Units) -> RulerText {
|
||||
/// (1/16 in for inches), so it does not change with the zoom the ruler is shown at.
|
||||
const SNAP_ZOOM: f64 = 2.0;
|
||||
|
||||
/// The distance a snapping drag moves by: the ruler's smallest tick at [`SNAP_ZOOM`], in points.
|
||||
/// The distance a snapping drag moves by: the ruler's smallest tick at `SNAP_ZOOM`, in points.
|
||||
pub fn snap_step(text: &RulerText, unit: DocUnit) -> f32 {
|
||||
let ticks = Rulers::ticks(&text.units, TickRule::of_unit(unit.kind), SNAP_ZOOM, 0.0..=0.0);
|
||||
let gap = ticks.windows(2).find_map(|pair| match pair {
|
||||
|
||||
@@ -257,7 +257,7 @@ impl Fixture {
|
||||
}
|
||||
|
||||
/// The command input of every following pass, whole, as an app's `FrameInput.commands` gives it: the states and
|
||||
/// gate a runner folds from the stories it shows ([`Story::command_input`]).
|
||||
/// gate a runner folds from the stories it shows ([`Story::command_states`]).
|
||||
pub fn commands(&mut self, commands: CommandInput) -> &mut Self {
|
||||
self.commands = commands;
|
||||
self.frames.commands(self.commands.clone());
|
||||
|
||||
Reference in New Issue
Block a user