feat(math): offer the result next to a handwritten = (Issue #46, stage 3)

New module math_assist.rs: when the last two strokes form an = and the pen
rests for 500 ms, the strokes left of it (in a band around the =, up to a
wide gap) are recognized and computed. The suggestion appears next to
the = and shows what was read, e.g. "2⁴ = 16"; tapping it with the pen
or clicking inserts the result as a text box in the ink color and as high
as the handwriting, as one undo step. The chip is not interactive for
egui, so fingers and palms pass through. Any new stroke drops it. In a
chain like x = 2 · 3 = the part after the previous = is computed.

Off by default: ☰ → Input → "Compute formulas after =", saved in
ui.json. math::display writes the recognized expression neatly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
haraldandClaude Opus 5.5 committed 2026-10-28 14:45:00 +01:00
1 parent d16cd2db72
commit 307c803246
10 files changed
+775 -14

No files matched your search

+4
View File
@@ -232,6 +232,8 @@ pub struct UiSettings {
/// Folder of the notebooks, e.g. inside a Nextcloud folder; default location if unset
/// (Issue #49)
pub storage_dir: Option<PathBuf>,
/// Compute handwritten math after `=` (Issue #46)
pub math_assist: bool,
}
impl Default for UiSettings {
@@ -253,6 +255,7 @@ impl Default for UiSettings {
language: None,
eraser_radius_mm: 3.0,
storage_dir: None,
math_assist: false,
}
}
}
@@ -350,6 +353,7 @@ mod tests {
language: Some(Language::English),
eraser_radius_mm: 6.0,
storage_dir: Some(PathBuf::from("/home/pia/Nextcloud/ink-notes")),
math_assist: true,
};
settings.save_to(&path).unwrap();
assert_eq!(UiSettings::load_from(&path), settings);