Skip to content

feat: add lightweight text editing from the preview - #218

Merged
nextestudios merged 2 commits into
mainfrom
feature/62-text-editing
Sep 27, 2026
Merged

nextestudios merged 2 commits into
mainfrom
feature/62-text-editing

Conversation

@nextestudios

Copy link
Copy Markdown
Owner

Summary

  • North in the text preview (files ≤ 1 MB shown in full) enters a line-based edit mode that reuses the on-screen keyboard: the focused line gets a highlighted band, Up/Down/LT/RT/LB/RB move it, South edits the line on the keyboard, North opens a line menu (insert below/above, delete, undo, save, leave editing), Start saves.
  • Only safe files: TextEditDocument (Core) loads the whole file and keeps each line's text and terminator, the encoding and BOM; it refuses binary, > 1 MB, > 10,000 lines and anything that would not be written back byte for byte (untouched lines never change). Read-only files are refused. Edited lines never gain line breaks.
  • Saving: confirmation dialog (changed lines, encoding, backup name) → AtomicFileWriter writes a .controlfs-edit-*.part in the same folder (registered in the temporaries journal before creation), WriteThrough + flush, then File.Replace (keeps attributes/ACLs) leaving the original as name.controlfs.bak. If size/date changed since editing started, an explicit "Substituir mesmo assim" is required. IO/permission errors keep the edits and show the reason.
  • Back without changes leaves editing; with changes asks before discarding, focus on "Continuar editando". In-session undo (100 steps).
  • Render harness: mt-text-edit capture. Docs: GUIDE (both), CHANGELOG (both), security-model, ui-redesign, TESTING.

Tested in CI

  • TextEditDocumentTests: BOM + mixed CRLF/LF + no final newline round-trip and single-line change; refusals (binary, oversized, non-round-trip UTF-8).
  • TextEditJourneyTests: edit via keyboard, insert below the last line (ending handling), delete + undo, nothing written before save, confirm + atomic save with backup and no leftover temp, preview reloaded; Back asks before discarding; changed-on-disk warning never overwrites silently; read-only refused.

Manual checks (docs/TESTING.md, "Edição de texto (#62)")

  • Real controller flow, Notepad round-trip for UTF-8 BOM/ANSI/UTF-16 files, external change warning, legibility of the focused-line band at TV/handheld sizes.

Closes #62

🤖 Generated with Claude Code

nextestudios and others added 2 commits September 27, 2026 20:03
North in the text preview enters a line-based edit mode that reuses the
on-screen keyboard. Only files that round-trip byte for byte are
editable; Start saves after confirmation through an atomic replace that
keeps encoding, BOM, line endings and a .controlfs.bak copy, warns when
the file changed on disk, and Back asks before discarding changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nextestudios
nextestudios force-pushed the feature/62-text-editing branch from e7c52cb to 35ae807 Compare September 27, 2026 23:04
@nextestudios
nextestudios merged commit a9f661e into main Sep 27, 2026
1 check passed
@nextestudios
nextestudios deleted the feature/62-text-editing branch September 27, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add lightweight text editing from preview

1 participant