feat: F4.6f2 the text editor on the document's Y.Text, files both ways while the simulation runs

Oracle TextEditorWindowRun uses Java's text editor window and its file
dialog as a person does. The open file's text is its Y.Text in the
document (plan 7.3): typed is in the file at once, for everyone and for
the running engine. Core openText/saveTextAs without Java's mistakes
(lost saves after save-as onto a file or a removed file, files named
'ordner/d.txt' or ''); doc files.ts (changeFiles, fileText, nodeFiles,
readFilesInto); the room takes a person's files into the engine at once
and writes the engine's files back at the tick they changed; the editor's
window, Java's dialog, the text area following others' changes with the
caret in place, its own undo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 17:50:27 +00:00
co-authored by Claude Opus 5.5
parent 3d6655e736
commit 2c7733b575
29 changed files with 3268 additions and 76 deletions
+30 -3
View File
@@ -16,7 +16,11 @@
// file system's rule), and one that changes only the case is done (Java
// finds the entry itself and refuses);
// - "save as" onto a folder's name, and an import onto it, is refused (Java
// throws);
// throws); "save as" with an empty name, or one with blanks at its ends,
// is refused (Java makes such a file), a name with "/" leads into a
// folder (Java makes a file whose name holds the separator);
// - "open" opens text files only (Java shows an image as its Base64 text)
// and keeps the open file when it finds none (Java forgets it);
// - a text file's size is its length in characters (as the command line's).
import type { VirtualFileContent, VirtualFileSystem } from '../../model/virtualFileSystem.js';
@@ -223,15 +227,38 @@ export function saveText(files: VirtualFileSystem, path: string, text: string):
/**
* The editor's "save as" (Dateisystem.speicherDatei): the text as a file of
* the folder, over one of that name in any case (its name kept as it is).
* The name may lead into a folder of the folder ("ordner/d.txt", as "open"
* takes it; Java makes a file with "/" in its name); a name the file system
* does not take (empty, or with blanks at its ends; Java makes such a file)
* is invalidName, one whose folder is not there folderMissing.
*/
export function saveTextAs(files: VirtualFileSystem, folder: string, name: string, text: string): 'saved' | 'folderMissing' | 'isFolder' {
export function saveTextAs(files: VirtualFileSystem, folder: string, name: string, text: string): 'saved' | 'folderMissing' | 'isFolder' | 'invalidName' {
if (name.split('/').some((part) => part.trim() !== part) || evaluatedPath(name) === '/') return 'invalidName';
const target = fileTarget(files, folder, name);
if (target === undefined) return 'folderMissing';
if (target.isFolder) return 'isFolder';
files.writeTextFile(target.path, text);
try {
files.writeTextFile(target.path, text);
} catch {
return 'folderMissing';
}
return 'saved';
}
/**
* The editor's "open" (holeDatei of the dialog's folder and name): the name
* taken as a path from the folder, in any case. Java opens whatever file it
* finds, an image as its Base64 text, and with none forgets the open file;
* here a file that is not text is notText, none notFound (the open file
* stays open).
*/
export function openText(files: VirtualFileSystem, folder: string, name: string): { readonly path: string; readonly text: string } | 'notFound' | 'notText' {
// No name is the folder itself: not found.
const entry = found(files, evaluatedPath(name.startsWith('/') ? name : `${folder}/${name}`));
if (entry === undefined || entry.content.kind === 'directory') return 'notFound';
return entry.content.kind === 'text' ? { path: entry.path, text: entry.content.text } : 'notText';
}
/** The image viewer's "open": an image file's bytes and media type; none for any other file. */
export function imageFile(files: VirtualFileSystem, path: string): { readonly data: Uint8Array; readonly mediaType: string } | undefined {
const entry = found(files, path);