Cursors: Caps Lock gives the drawing tools the crosshair

While Caps Lock is on, the tools whose pointer General > Use Precise
Cursors changes show the crosshair, and the saved preference does not
change. The desktop app reads the lock state on macOS, Windows and
Linux X11 and passes each change to the new view.capsLock command. A
change to view.capsLock or usePreciseCursors through app.run refreshes
the canvas pointer. The view.preciseCursors command is labeled Use
Precise Cursors, so command search finds it by the preference's name.
This commit is contained in:
dotCooCoo
2026-11-01 01:59:54 +07:00
committed by bflatastic
parent 1bb52c5b38
commit dfd07552c8
16 changed files with 321 additions and 10 deletions
+8
View File
@@ -9,6 +9,7 @@ use super::{CommandSpec, Result, Session, always, bad, bool_or, cmd, f64_req, fi
pub fn specs() -> Vec<CommandSpec> {
vec![
cmd!(query "view.capsLock", "Caps Lock Cursor State", [], None, "{on?: bool} set or read the Caps Lock state the desktop app reports; while it is on, the drawing tools show the precise crosshair, and Use Precise Cursors keeps its saved value → {on}", always, caps_lock),
cmd!(
"view.saved.new",
"New View…",
@@ -54,6 +55,13 @@ fn glyph_snap_options(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!(s.prefs.glyph_snap))
}
fn caps_lock(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(on) = p.get("on") {
s.caps_lock = on.as_bool().ok_or_else(|| bad("view.capsLock", "on must be true or false"))?;
}
Ok(json!({ "on": s.caps_lock }))
}
fn transparency_grid(s: &mut Session, p: &Value) -> Result<Value> {
let st = s.doc_mut()?;
st.transparency_grid = p.get("on").and_then(Value::as_bool).unwrap_or(!st.transparency_grid);