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

+3 -3
View File
@@ -942,11 +942,11 @@ fn layout(elements: &[Element], line_height: f32) -> String {
}
#[cfg(test)]
mod tests {
pub(crate) mod tests {
use super::*;
/// Deterministic pseudo-random numbers in [-1, 1]
struct Jitter(u64);
pub(crate) struct Jitter(pub u64);
impl Jitter {
fn next(&mut self) -> f32 {
@@ -1050,7 +1050,7 @@ mod tests {
}
/// Writes the symbols of `text` from left to right; `^` raises the next symbol
fn write_line(text: &str, jitter: &mut Jitter) -> Vec<Vec<Vec2>> {
pub(crate) fn write_line(text: &str, jitter: &mut Jitter) -> Vec<Vec<Vec2>> {
let mut strokes = Vec::new();
let mut x = 0.0;
let mut raised = false;