!7 sclass TextArea extends DynModule { S text; S globalID = aGlobalID(); transient EditRecorder recorder; transient JTextArea ta; transient ReliableSingleThread rstPersistText = rstWithDelay(1000, r persistText); bool warnOnDelete() { ret nempty(text); } File logFile() { ret javaxDataDir("Text Area Logs/" + globalID); } JComponent visualize() { ta = typeWriterTextArea(text); logQuoted(logFile(), "text: " + text); recorder = new EditRecorder(voidfunc(EREvent e) { logStructure(logFile(), e); }); recorder.text = text; main.onChange(ta, rstPersistText); ret jscroll(setOpaqueBackground(Color.white, withMargin(ta))); } void persistText { if (ta != null) { Pair p = swing(func -> Pair { pair(getText(ta), getCaretPosition(ta)) }); recorder.update(p.a); recorder.updateCaret(p.b); print("persistText " + now()); setField(text := getText(ta)); } } void unvisualize() { persistText(); ta = null; } void setText(S text) { main.setText(ta, text); } }