From de8af6ed92e024bb45423021a1a21629deeb035d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Martin?= Date: Wed, 7 Oct 2026 15:39:45 +0200 Subject: [PATCH] Notes: edit a text file of any size (#47) The editor held the whole note in memory and stopped at 16 KB. It now keeps a window of the file around the cursor, and the rest on the card as a list of pieces (notes::NoteDocument). Memory with a note open is what it was. Up to 64 KB a save rewrites the file, as before. Above, the five-second save appends what changed to .edit, and the file is rewritten on leaving the note, with a progress bar. After a power cut, opening the note picks the edit up where it was saved; a rewrite cut short is finished or dropped, never half applied. Also: Ctrl with Fn+Up/Down go to the start and end of the note; the consoles' `key` command takes ctrl-, alt- and shift-; the Storage App's `e` no longer refuses a big file. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT --- README.md | 6 +- docs/milestones/F1.md | 59 +- lib/core/src/app_keys.h | 3 +- lib/notes/src/note_document.cpp | 622 ++++++++++++++++++ lib/notes/src/note_document.h | 130 ++++ lib/notes/src/note_text.cpp | 21 +- lib/notes/src/note_text.h | 16 +- site/content/dev/debug/commands.md | 4 +- site/content/dev/debug/drive-the-ui.md | 2 +- site/content/dev/milestones/f1.md | 59 +- site/content/faq.md | 2 +- site/content/guide/notes.md | 16 +- site/data/keys.toml | 3 +- src/apps/note_editor.cpp | 261 +++++--- src/apps/note_editor.h | 36 +- src/apps/notes_app.cpp | 11 +- src/apps/storage_app.cpp | 1 - src/main.cpp | 16 +- src/services/power_service.cpp | 1 + src/services/power_service.h | 2 + .../test_note_document/test_note_document.cpp | 521 +++++++++++++++ 21 files changed, 1681 insertions(+), 111 deletions(-) create mode 100644 lib/notes/src/note_document.cpp create mode 100644 lib/notes/src/note_document.h create mode 100644 test/test_note_document/test_note_document.cpp diff --git a/README.md b/README.md index 0db751c..6d3906b 100644 --- a/README.md +++ b/README.md @@ -150,11 +150,11 @@ At the top of the card the last row, **Maintenance** (also `m`), holds the card' The Notes App (docs/milestones/F1.md) keeps plain text notes in `/notes` on the SD card. The list shows each note's first line and its date, newest first; `s` switches to by file name. `n` starts a note, Enter opens one, `r` renames its file, `d` deletes it after asking. -In the editor, type. Enter starts a line, Del deletes backwards, Fn with the arrows moves the cursor through the wrapped text, Ctrl+A and Ctrl+E go to the start and the end of the line, Tab types two spaces, and the Compose Key gives accents as everywhere. **There's no save key:** the note is written five seconds after the last key, on Back, on leaving the App, when the screen turns off and before the device powers off. The top line says "typing" or "saved". Each save writes a temporary file and then puts it in the note's place, so a power cut costs a few seconds of typing and never the note; if a save was cut short, opening the note offers its copy back. +In the editor, type. Enter starts a line, Del deletes backwards, Fn with the arrows moves the cursor through the wrapped text, Ctrl+A and Ctrl+E go to the start and the end of the line, Ctrl with Fn+Up and Fn+Down to the start and the end of the note, Tab types two spaces, and the Compose Key gives accents as everywhere. **There's no save key:** the note is written five seconds after the last key, on Back, on leaving the App, when the screen turns off and before the device powers off. The top line says "typing" or "saved". Each save writes a temporary file and then puts it in the note's place, so a power cut costs a few seconds of typing and never the note; if a save was cut short, opening the note offers its copy back. A new note has no file until something is typed; its file is then named after its first line (`shopping-list.txt`), or `note--