mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 10:13:09 -06:00
Merge branch 'port/deckcraft/look/app-2' into port/deckcraft/area/app
This commit is contained in:
@@ -12,7 +12,7 @@ use serde_json::{Value, json};
|
||||
|
||||
use crate::{Services, SlideApp};
|
||||
|
||||
/// The sample deck with a shape, a picture, a table and a diagram added, each alone on a new slide, in that order;
|
||||
/// The sample deck with a shape, a picture, a table, a diagram and a chart added, each alone on a new slide, in that order;
|
||||
/// returns their ids.
|
||||
fn harness() -> (Harness<'static, SlideApp>, Vec<ShapeId>) {
|
||||
let mut s = Session::new();
|
||||
@@ -24,6 +24,7 @@ fn harness() -> (Harness<'static, SlideApp>, Vec<ShapeId>) {
|
||||
("insert.picture", json!({"data": deckcraft_engine::cmd::base64_encode(&png), "name": "a.png", "rect": [100, 100, 400, 200]})),
|
||||
("insert.table", json!({"rows": 2, "cols": 2, "rect": [80, 80, 600, 160]})),
|
||||
("insert.smartArt", json!({"kind": "process", "items": ["Plan", "Build", "Ship"]})),
|
||||
("insert.chart", json!({})),
|
||||
] {
|
||||
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
|
||||
s.execute(cmd, ¶ms).unwrap();
|
||||
@@ -121,6 +122,15 @@ fn no_collection_shares_a_scrolling_body() {
|
||||
h.run_steps(3);
|
||||
close_dialogs(&mut h);
|
||||
}
|
||||
// Chart Data shows its sheet only over a selected chart.
|
||||
select(&mut h, shapes[4]);
|
||||
let opening = Opening("the chartData dialog over a chart".into());
|
||||
dialog(&mut h, "ui.dialog.open", json!({"id": "chartData"})).unwrap_or_else(|error| panic!("chartData: {error}"));
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label("Chart data").is_some(), "the sheet is shown");
|
||||
close_dialogs(&mut h);
|
||||
drop(opening);
|
||||
select(&mut h, shapes[0]);
|
||||
for id in ["paragraph", "tabs", "hyperlink", "customShow", "spelling", "accessibility", "find", "about", "preferences", "autocorrect"] {
|
||||
let _opening = Opening(format!("the {id} dialog"));
|
||||
dialog(&mut h, "ui.dialog.open", json!({"id": id})).unwrap_or_else(|error| panic!("{id}: {error}"));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! The app's control method table, shared by transports, agents and tests.
|
||||
//!
|
||||
//! Engine edits use `engine.execute`, `engine.key` and `engine.text`. Window input uses
|
||||
//! `craft::automation::synthetic`: `ui.click {hold: true}`, `ui.move`, then `ui.release`
|
||||
//! Engine edits use `engine.execute`, `engine.key` and `engine.text` (also `ui.text`). Window input uses
|
||||
//! `craft::automation::synthetic`: `ui.drag`, or `ui.click {hold: true}`, `ui.move`, then `ui.release`,
|
||||
//! form a drag. Input replies wait for the window host to consume its steps.
|
||||
//! `app.focusWindow` raises the OS window; `ui.focus` targets a named control.
|
||||
//! Screenshots resolve the app's window names before entering the library's capture queue.
|
||||
@@ -95,6 +95,7 @@ pub fn handle(app: &mut SlideApp, ctx: &egui::Context, req: &ControlRequest) ->
|
||||
method,
|
||||
"ui.click"
|
||||
| "ui.move"
|
||||
| "ui.drag"
|
||||
| "ui.release"
|
||||
| "ui.key"
|
||||
| "ui.type"
|
||||
@@ -107,10 +108,16 @@ pub fn handle(app: &mut SlideApp, ctx: &egui::Context, req: &ControlRequest) ->
|
||||
| "ui.screenshot"
|
||||
| "ui.window"
|
||||
) {
|
||||
let (viewport, params) = match window_target(app, ctx, &req.params) {
|
||||
let (viewport, mut params) = match window_target(app, ctx, &req.params) {
|
||||
Ok(target) => target,
|
||||
Err(error) => return err(error),
|
||||
};
|
||||
// `active` is the protocol's older name for the preedit's converted segment.
|
||||
if method == "ui.ime"
|
||||
&& let Some(active) = params.as_object_mut().and_then(|fields| fields.remove("active"))
|
||||
{
|
||||
params["cursor"] = active;
|
||||
}
|
||||
if method == "ui.screenshot" {
|
||||
let params = match ScreenshotParams::from_params(¶ms) {
|
||||
Ok(params) => params,
|
||||
@@ -199,7 +206,7 @@ pub fn handle(app: &mut SlideApp, ctx: &egui::Context, req: &ControlRequest) ->
|
||||
}
|
||||
wrap(app.session.key(key, mods_from(p)).map_err(|e| e.to_string()))
|
||||
}
|
||||
"engine.text" => {
|
||||
"engine.text" | "ui.text" => {
|
||||
let Some(text) = s("text") else { return err("missing `text`") };
|
||||
wrap(app.session.type_text(text).map_err(|e| e.to_string()))
|
||||
}
|
||||
@@ -930,6 +937,17 @@ mod tests {
|
||||
.ok_or("edited title")?
|
||||
.text();
|
||||
assert!(after.len() < before.len(), "the engine received the editing key");
|
||||
let reply = call(&mut harness, &sender, "ui.text", json!({"text": "!!"}))?;
|
||||
assert_eq!(reply["ok"], true, "{reply}");
|
||||
let typed = harness
|
||||
.state()
|
||||
.session
|
||||
.active()
|
||||
.and_then(|document| document.shape(title))
|
||||
.and_then(|shape| shape.text.as_ref())
|
||||
.ok_or("edited title")?
|
||||
.text();
|
||||
assert!(typed.len() > after.len(), "the protocol's ui.text types through the engine as engine.text does");
|
||||
|
||||
let recent = vec!["/quarterly.deckcraft", "/annual.deckcraft"];
|
||||
let reply = call(&mut harness, &sender, "ui.set", json!({"recent": recent}))?;
|
||||
|
||||
@@ -34,6 +34,7 @@ mod paragraph;
|
||||
mod photo_album;
|
||||
/// Preferences drafts and their nested AutoCorrect transaction.
|
||||
pub(crate) mod preferences;
|
||||
mod protocol_fields;
|
||||
mod replace_fonts;
|
||||
mod reuse_slides;
|
||||
mod size_position;
|
||||
@@ -328,13 +329,16 @@ pub(crate) fn control(app: &mut SlideApp, ctx: &Context, method: &str, params: &
|
||||
let params = Params(params).only(None, &["id", "params", "fields"])?;
|
||||
let params_view = Params(¶ms);
|
||||
let id = params_view.str_field("id")?.ok_or("missing `id`")?;
|
||||
let fields = match params.get("fields") {
|
||||
let mut fields = match params.get("fields") {
|
||||
Some(Value::Object(fields)) => fields.iter().map(|(key, value)| (key.clone(), value.clone())).collect::<Vec<_>>(),
|
||||
Some(_) => return Err("fields must be an object".into()),
|
||||
None => Vec::new(),
|
||||
};
|
||||
let opened = open_now(app, ctx, host, id, params.get("params").unwrap_or(&Value::Null))?;
|
||||
let opener = protocol_fields::opener(id, params.get("params").unwrap_or(&Value::Null), &mut fields);
|
||||
let opened = open_now(app, ctx, host, id, &opener)?;
|
||||
if let Some(opened) = opened {
|
||||
let tab = opener.get("tab").and_then(Value::as_str).unwrap_or("click");
|
||||
let fields = protocol_fields::typed(id, ¤t_fields(host, opened), tab, fields)?;
|
||||
host.set_json_fields(ctx, opened, &fields)?;
|
||||
} else if !fields.is_empty() {
|
||||
return Err("the request completed without a dialog to set fields on".into());
|
||||
@@ -353,10 +357,45 @@ pub(crate) fn control(app: &mut SlideApp, ctx: &Context, method: &str, params: &
|
||||
host.close_by_id(id);
|
||||
Ok(Value::Null)
|
||||
})()),
|
||||
"ui.dialog.set" => Some((|| {
|
||||
let params = Params(params).only(None, &["dialog", "field", "value", "fields"])?;
|
||||
let id = automation::dialog_id(host, ¶ms)?;
|
||||
let fields = match (params.get("fields"), params.get("field")) {
|
||||
(Some(_), Some(_)) => return Err("`fields` takes the place of `field` and `value`".into()),
|
||||
(Some(Value::Array(items)), None) => items
|
||||
.iter()
|
||||
.map(|item| {
|
||||
let field = item.get("field").and_then(Value::as_str).ok_or("an item of `fields` has no string `field`")?;
|
||||
Ok((field.to_owned(), item.get("value").cloned().unwrap_or(Value::Null)))
|
||||
})
|
||||
.collect::<Result<Vec<_>, String>>()?,
|
||||
(Some(_), None) => return Err("`fields` is not a list".into()),
|
||||
(None, Some(Value::String(field))) => vec![(field.clone(), params.get("value").cloned().unwrap_or(Value::Null))],
|
||||
(None, _) => return Err("missing `field`".into()),
|
||||
};
|
||||
let key = dialog_key(host, id).unwrap_or_default();
|
||||
let fields = protocol_fields::typed(&key, ¤t_fields(host, id), "click", fields)?;
|
||||
let list: Vec<Value> = fields.into_iter().map(|(field, value)| json!({"field": field, "value": value})).collect();
|
||||
automation::dialog_method(host, ctx, method, &json!({"dialog": id.value().to_string(), "fields": list})).unwrap_or(Ok(Value::Null))
|
||||
})()),
|
||||
_ => automation::dialog_method(host, ctx, method, params),
|
||||
})
|
||||
}
|
||||
|
||||
/// The automation fields dialog `id` shows now, `null` when it has none.
|
||||
fn current_fields(host: &DialogHost, id: DialogId) -> Value {
|
||||
host.open_dialogs().into_iter().find(|dialog| dialog.id == id).and_then(|dialog| dialog.fields).unwrap_or(Value::Null)
|
||||
}
|
||||
|
||||
/// The dialog key `id` opened under: the typed dialogs' own, or the key a form carries.
|
||||
fn dialog_key(host: &DialogHost, id: DialogId) -> Option<String> {
|
||||
["paragraph", "tabs", "hyperlink", "customShow", "spelling", "find", "quit", "about"]
|
||||
.into_iter()
|
||||
.find(|key| matching_dialog(host, key) == Some(id))
|
||||
.map(str::to_owned)
|
||||
.or_else(|| host.open_dialogs().into_iter().find(|dialog| dialog.id == id).and_then(|dialog| dialog.key))
|
||||
}
|
||||
|
||||
/// Returns the host's automation inspection of every open dialog.
|
||||
pub(crate) fn inspect(ctx: &Context) -> Value {
|
||||
WindowDialogs::of(ctx, &WindowKey::main()).with(|host| automation::inspect(host))
|
||||
|
||||
@@ -11,8 +11,9 @@ use serde_json::{Value, json};
|
||||
|
||||
use crate::SlideApp;
|
||||
|
||||
/// Opens both action tabs over the first selected shape's settings.
|
||||
pub(crate) fn open(app: &SlideApp, ctx: &Context, _params: &Value) -> HostedParamDialog {
|
||||
/// Opens both action tabs over the first selected shape's settings, on Mouse Over when `params.tab` is `hover`.
|
||||
pub(crate) fn open(app: &SlideApp, ctx: &Context, params: &Value) -> HostedParamDialog {
|
||||
let tab = usize::from(params.get("tab").and_then(Value::as_str) == Some("hover"));
|
||||
let state = app.session.active();
|
||||
let shape = state.and_then(|s| s.selected_shapes().first().copied());
|
||||
let slides: Vec<_> = state
|
||||
@@ -38,6 +39,7 @@ pub(crate) fn open(app: &SlideApp, ctx: &Context, _params: &Value) -> HostedPara
|
||||
.layout(ParamLayout::Document)
|
||||
.caption_column(true)
|
||||
})
|
||||
.tab(tab)
|
||||
}
|
||||
|
||||
fn seed(fields: &mut DialogFields, on: &str, link: Option<&Hyperlink>, slides: &[(deckcraft_model::SlideId, String)], shows: &[String]) {
|
||||
|
||||
@@ -99,7 +99,8 @@ pub(crate) fn open(app: &crate::SlideApp, ctx: &egui::Context, _params: &Value)
|
||||
let mut model = ChartGrid::new(cells, &Env::of(ui));
|
||||
let mut changed = false;
|
||||
let mut state = state.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
|
||||
let out = CellGrid::new(Word::plain("Chart data"), &model, &mut state).headings(false).show_sheet(ui);
|
||||
// Every row shows, as the dialog's other rows do; the dialog's body scrolls a long sheet.
|
||||
let out = CellGrid::new(Word::plain("Chart data"), &model, &mut state).headings(false).natural_height(true).show_sheet(ui);
|
||||
if let Some(edit) = out.committed
|
||||
&& let Some(cell) = model.cells.get_mut(edit.cell.row as usize).and_then(|row| row.get_mut(edit.cell.column as usize))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
//! The control protocol's dialog fields. A client may send any value as text (a number as its digits, a check box as
|
||||
//! `1` or `0`), and some dialogs take the protocol's names for what their dialog calls otherwise: Find's `text`,
|
||||
//! Hyperlink's `mode: slide`, Action Settings' `tab` and `kind`, Bullets' `tab`, Paragraph's `lineKind` and
|
||||
//! `lineValue`, Tabs' `stops` as `position:align|…` with positions in inches, and Reuse Slides' `off{index}`, which
|
||||
//! unticks a slide with `1`.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
/// The opener parameters of dialog `id`, with the fields that choose how it opens taken out of `fields`: the tab
|
||||
/// Bullets and Action Settings open on.
|
||||
pub(super) fn opener(id: &str, params: &Value, fields: &mut Vec<(String, Value)>) -> Value {
|
||||
let mut params = if params.is_object() { params.clone() } else { json!({}) };
|
||||
if matches!(id, "bullets" | "action")
|
||||
&& let Some(at) = fields.iter().position(|(field, _)| field == "tab")
|
||||
{
|
||||
params["tab"] = fields.remove(at).1;
|
||||
}
|
||||
params
|
||||
}
|
||||
|
||||
/// `fields` as dialog `key` takes them, read against its current fields `current`; `tab` is the Action Settings tab
|
||||
/// a `kind` applies to.
|
||||
pub(super) fn typed(key: &str, current: &Value, tab: &str, fields: Vec<(String, Value)>) -> Result<Vec<(String, Value)>, String> {
|
||||
let mut out = Vec::new();
|
||||
let mut line: Option<(Option<String>, Option<f64>)> = None;
|
||||
let mut unticked: Vec<(u64, bool)> = Vec::new();
|
||||
for (field, value) in fields {
|
||||
let slide = field.strip_prefix("off").and_then(|index| index.parse::<u64>().ok());
|
||||
match (key, field.as_str()) {
|
||||
("reuseSlides", _) if slide.is_some() => {
|
||||
let off = as_typed(Some(&json!(false)), value.clone());
|
||||
unticked.push((slide.unwrap_or_default(), off.as_bool().ok_or_else(|| format!("`{field}` must be 1 or 0"))?));
|
||||
}
|
||||
("find", "text") => out.push(("find".to_owned(), value)),
|
||||
("hyperlink", "mode") if value == "slide" => out.push((field, json!("place"))),
|
||||
("action", "kind") => {
|
||||
let kind = value.as_str().ok_or("`kind` must be text")?;
|
||||
if matches!(kind, "none" | "program" | "playMedia") {
|
||||
out.push((format!("{tab}.kind"), value));
|
||||
} else {
|
||||
out.push((format!("{tab}.kind"), json!("link")));
|
||||
out.push((format!("{tab}.target"), value));
|
||||
}
|
||||
}
|
||||
("paragraph", "lineKind") => line.get_or_insert_default().0 = Some(value.as_str().ok_or("`lineKind` must be text")?.to_owned()),
|
||||
("paragraph", "lineValue") => line.get_or_insert_default().1 = Some(number(&value).ok_or("`lineValue` must be a number")?),
|
||||
("tabs", "stops") if value.is_string() => out.push((field, stops(&value)?)),
|
||||
_ => out.push((field, value)),
|
||||
}
|
||||
}
|
||||
if let Some((kind, value)) = line {
|
||||
out.push(("line_spacing".to_owned(), line_spacing(current, kind.as_deref(), value)?));
|
||||
}
|
||||
if !unticked.is_empty() {
|
||||
let mut ticked: Vec<u64> = current["ticked"].as_array().into_iter().flatten().filter_map(Value::as_u64).collect();
|
||||
for (slide, off) in unticked {
|
||||
ticked.retain(|at| *at != slide);
|
||||
if !off {
|
||||
ticked.push(slide);
|
||||
}
|
||||
}
|
||||
ticked.sort_unstable();
|
||||
out.push(("ticked".to_owned(), json!(ticked)));
|
||||
}
|
||||
Ok(out
|
||||
.into_iter()
|
||||
.map(|(field, value)| {
|
||||
let value = as_typed(current.get(&field), value);
|
||||
(field, value)
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
fn number(value: &Value) -> Option<f64> {
|
||||
value.as_f64().or_else(|| value.as_str()?.trim().parse().ok()).filter(|n: &f64| n.is_finite())
|
||||
}
|
||||
|
||||
/// A text value as the type the field holds now: a number field takes its digits, a check box `1`, `0`, `true` or
|
||||
/// `false`. Other values, and text the type cannot read, go as they are for the dialog to accept or refuse.
|
||||
fn as_typed(now: Option<&Value>, value: Value) -> Value {
|
||||
let Some(text) = value.as_str().map(str::trim) else { return value };
|
||||
let read = match now {
|
||||
Some(Value::Number(_)) => text.parse::<i64>().map(Value::from).ok().or_else(|| number(&value).map(Value::from)),
|
||||
Some(Value::Bool(_)) => match text {
|
||||
"1" | "true" => Some(Value::Bool(true)),
|
||||
"0" | "false" => Some(Value::Bool(false)),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
read.unwrap_or(value)
|
||||
}
|
||||
|
||||
/// Paragraph's line spacing set to `kind` (`multiple` or `exactly`, the current kind when absent) and `value` (a
|
||||
/// multiple, or points). Without a value a kind keeps its current one, and a change of kind starts at single spacing
|
||||
/// or 18 pt.
|
||||
fn line_spacing(current: &Value, kind: Option<&str>, value: Option<f64>) -> Result<Value, String> {
|
||||
let (now, now_value) = match ¤t["line_spacing"] {
|
||||
Value::Object(spacing) => spacing.iter().next().map(|(kind, value)| (kind.clone(), value.as_f64())).unwrap_or_default(),
|
||||
_ => (String::new(), None),
|
||||
};
|
||||
let kind = match kind {
|
||||
Some("exactly") => "Exactly",
|
||||
Some("multiple") => "Multiple",
|
||||
None if now == "Exactly" => "Exactly",
|
||||
None => "Multiple",
|
||||
Some(other) => return Err(format!("`lineKind` can't take {other:?} (multiple or exactly)")),
|
||||
};
|
||||
let value = value.or(now_value.filter(|_| now == kind)).unwrap_or(if kind == "Exactly" { 18.0 } else { 1.0 });
|
||||
Ok(json!({ kind: value }))
|
||||
}
|
||||
|
||||
/// Tabs' stops in the protocol's text form, `position:align|…`: positions in inches, aligns `l`, `ctr`, `r` or `dec`.
|
||||
fn stops(value: &Value) -> Result<Value, String> {
|
||||
let refused = |stop: &str| format!("`stops` can't take {stop:?} (position:align in inches, align l, ctr, r or dec)");
|
||||
value
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
.split('|')
|
||||
.filter(|stop| !stop.trim().is_empty())
|
||||
.map(|stop| {
|
||||
let (at, align) = stop.split_once(':').ok_or_else(|| refused(stop))?;
|
||||
let inches = number(&json!(at)).ok_or_else(|| refused(stop))?;
|
||||
let align = match align.trim() {
|
||||
"l" => "left",
|
||||
"ctr" => "center",
|
||||
"r" => "right",
|
||||
"dec" => "decimal",
|
||||
_ => return Err(refused(stop)),
|
||||
};
|
||||
Ok(json!({"position": inches * 72.0, "align": align, "leader": "none"}))
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map(Value::from)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Text values take the type of the field they set; a value the type cannot read is left for the dialog to refuse.
|
||||
#[test]
|
||||
fn text_values_take_their_field_s_type() {
|
||||
let current = json!({"size": 18.0, "count": 1, "bold": false, "family": "Inter"});
|
||||
let fields = vec![
|
||||
("size".to_owned(), json!("28")),
|
||||
("count".to_owned(), json!("40")),
|
||||
("bold".to_owned(), json!("1")),
|
||||
("family".to_owned(), json!("12")),
|
||||
("size".to_owned(), json!("big")),
|
||||
];
|
||||
let typed = typed("font", ¤t, "click", fields).unwrap_or_default();
|
||||
let values: Vec<&Value> = typed.iter().map(|(_, value)| value).collect();
|
||||
assert!(values[0].is_number() && values[1].is_i64() && values[2] == &json!(true), "{typed:?}");
|
||||
assert!(values[3].is_string() && values[4].is_string(), "text fields and unreadable text stay text: {typed:?}");
|
||||
}
|
||||
|
||||
/// The protocol's names reach the fields the dialogs have: an action kind becomes a hyperlink target on the tab it
|
||||
/// is for, Exactly line spacing a paragraph format, text tab stops the dialog's stops in points.
|
||||
#[test]
|
||||
fn protocol_names_reach_the_dialogs_fields() {
|
||||
let action = typed("action", &json!({}), "hover", vec![("kind".to_owned(), json!("url"))]).unwrap_or_default();
|
||||
assert!(action.contains(&("hover.kind".to_owned(), json!("link"))) && action.contains(&("hover.target".to_owned(), json!("url"))));
|
||||
|
||||
let current = json!({"line_spacing": {"Multiple": 1.0}, "tab": "indents"});
|
||||
let paragraph = typed("paragraph", ¤t, "click", vec![("lineKind".to_owned(), json!("exactly"))]).unwrap_or_default();
|
||||
assert_eq!(paragraph.first().map(|(field, _)| field.as_str()), Some("line_spacing"));
|
||||
let spacing = ¶graph[0].1["Exactly"];
|
||||
assert!(spacing.as_f64().is_some_and(|pt| pt > 1.0), "exactly starts at a distance in points: {paragraph:?}");
|
||||
|
||||
let tabs = typed("tabs", &json!({}), "click", vec![("stops".to_owned(), json!("0.5:l|2.25:r"))]).unwrap_or_default();
|
||||
let stops = tabs[0].1.as_array().cloned().unwrap_or_default();
|
||||
assert_eq!(stops.len(), 2);
|
||||
assert!(stops[1]["position"].as_f64() > stops[0]["position"].as_f64() && stops[1]["align"] == "right", "{stops:?}");
|
||||
assert!(typed("tabs", &json!({}), "click", vec![("stops".to_owned(), json!("0.5:sideways"))]).is_err());
|
||||
|
||||
let reuse = typed("reuseSlides", &json!({"ticked": [0, 1, 2]}), "click", vec![("off1".to_owned(), json!("1"))]).unwrap_or_default();
|
||||
assert_eq!(reuse, vec![("ticked".to_owned(), json!([0, 2]))], "off1 unticks the second slide only");
|
||||
}
|
||||
}
|
||||
@@ -36,17 +36,18 @@ Coordinates are slide points (1/72 inch; a 16:9 slide is 960 × 540) unless note
|
||||
| `ui.tool.select` | `{tool, preset?}` | `select`, `text`, `shape` + preset, any preset name, `curve`, `freeform`, `scribble`, `pen`, `highlighter`, `eraser` |
|
||||
| `ui.pointer` | `{events: [{kind: down\|drag\|up\|move\|doubleclick\|tripleclick\|contextclick, x, y, mods?, pressure?}], mods?}` | Send slide-point pointer events through the active tool's mouse path. `contextclick` performs the right-click selection used by context menus; `pressure` is `0..=1` for a pen and can be omitted for a mouse |
|
||||
| `engine.key` | `{key, shift?, alt?, cmd?}` | Send a key press. During an active slide show, digits followed by Enter jump to that slide; G opens See All Slides, Z arms zoom, T toggles the presenter timer's pause, R resets it, and `[` / `]` resize notes. Esc clears a typed slide number or backs out of the grid/zoom before ending the active show. Close See All Slides with Esc or G before using the other listed show shortcuts. Slide-show keys ignore modifier flags; use `show.end` to leave the end-of-show screen. Outside a show, Escape stops canvas animation preview |
|
||||
| `engine.text` | `{text}` | Insert into the current text edit. With one shape selected and no active text edit, begin editing and replace the shape's existing text |
|
||||
| `ui.key` / `ui.type` / `ui.ime` | `{key, modifiers?, hold?, window?}` / `{text, window?}` / `{preedit, cursor?: [start,end], window?}` or `{commit, window?}` | Input through the window's focused control; IME cursor offsets count characters. `engine.key` and `engine.text` address the session directly |
|
||||
| `ui.click` / `ui.move` / `ui.release` | Screen points or a named control; optional `window` | Window input reaches widgets, menus and panes. Drag with `ui.click {hold: true}`, then `ui.move`, then `ui.release`; there is no `ui.drag` method |
|
||||
| `engine.text` (also `ui.text`) | `{text}` | Insert into the current text edit. With one shape selected and no active text edit, begin editing and replace the shape's existing text |
|
||||
| `ui.key` / `ui.type` / `ui.ime` | `{key, modifiers?, hold?, window?}` / `{text, window?}` / `{preedit, cursor?: [start,end], window?}` or `{commit, window?}` | Input through the window's focused control; IME cursor offsets count characters (`active` is another name for `cursor`). `engine.key` and `engine.text` address the session directly |
|
||||
| `ui.click` / `ui.move` / `ui.release` | Screen points, a named control, or for `ui.click` and `ui.move` a widget's `label` or `id`; optional `window` | Window input reaches widgets, menus and panes. `ui.move {label}` hovers the centre of the one widget with that label |
|
||||
| `ui.drag` | `{x, y, toX, toY, coordinates?, steps?, button?, window?}` | A press at the start, `steps` moves (default 8, at most 120) and the release at the end. A drag with modifiers or a pause is `ui.click {hold: true}`, `ui.move`, then `ui.release` |
|
||||
| `ui.focus` / `ui.find` | A named control and optional `window`; `ui.find` takes `{name, role?, within?, index?, window?}` | Focus or inspect a control through the window's accessibility tree. `within` names an ancestor; `index` selects a match in reading order |
|
||||
| `ui.accessTree` | `{}` | Return the main window's settled accessibility tree, waiting for a presented tree when necessary |
|
||||
| `ui.window` | `{maximized: bool, window?: docWindow\|presenter}` | Maximize or restore the named window, or the main window when omitted; refused where window commands are unavailable (desktop only) |
|
||||
| `ui.wheel` / `ui.drop` / `ui.capsLock` | Library synthetic-input parameters | Wheel input, file drops and Caps Lock state through the window host |
|
||||
| `ui.set` | `{tab?, view?, pane?, notes?, zoom?, dark?, recent?, palette?: {query, selected?}, backstage?: {page?, query?, exportTask?, fileType?, printLayout?, printRange?}, paneWidth?, thumbsWidth?, notesHeight?, caretBlink?, presenterView?, handoutPerPage?, …}` | Set UI state and return the full state. Pane sizes are finite numbers in points, clamped to the supported ranges. `caretBlink: false` requests a solid editor caret; true inherits the motion policy. `recent` is a list of paths. Palette selection is a displayed-result ordinal, excluding headings and dividers; it is normalized by the palette. File-page keyboard focus uses `ui.focus` on the entry label |
|
||||
| `ui.notify` | `{text, kind?: toast\|status}` | Post a notice; the default kind is `toast` |
|
||||
| `ui.dialog.open` | `{id, params?, fields?}` | Open a dialog through its registered implementation; `fields` pre-fills its fields |
|
||||
| `ui.dialog.set` / `ui.dialog.confirm` / `ui.dialog.cancel` / `ui.dialog.close` | Dialog selector and fields for `set` | Edit or answer the real hosted dialog; closing follows its cancel path |
|
||||
| `ui.dialog.open` | `{id, params?, fields?}` | Open a dialog through its registered implementation; `fields` pre-fills its fields, and `tab` among them picks the tab Bullets and Action Settings open on |
|
||||
| `ui.dialog.set` / `ui.dialog.confirm` / `ui.dialog.cancel` / `ui.dialog.close` | Dialog selector and fields for `set` | Edit or answer the real hosted dialog; closing follows its cancel path. A value may be text: a number field takes its digits, a check box `1`/`0` or `true`/`false`. Some dialogs also take these names: Find `text` (Find what), Hyperlink `mode: slide` (a place in this document), Action Settings `kind` (`none`, `program`, `playMedia` or a hyperlink target such as `url`), Paragraph `lineKind` (`multiple` or `exactly`) and `lineValue`, Tabs `stops` as `position:align\|…` (inches; `l`, `ctr`, `r`, `dec`), Reuse Slides `off{index}: 1` (untick a slide). A value outside a field's range is refused at `set` |
|
||||
| `ui.screenshot` | `{path?, region?: [x0,y0,x1,y1], window?: docWindow\|presenter}` | Capture a PNG of the named window or the main window. A region is in window points. Without a path, return `{base64, mime, width, height, pixels_per_point}`; with a path, return `{path, width, height, pixels_per_point}`. Unknown or closed windows are refused |
|
||||
| `ui.render` | `{path?, slide?, scale?}` | Render a slide headlessly |
|
||||
| `ui.resize` / `app.focusWindow` | `{width, height}` / `{}` | Resize or focus the main OS window |
|
||||
|
||||
Reference in New Issue
Block a user