Warning: session_start(): open(/var/lib/php/sessions/sess_6jvck90culov6nl20of43u27fv, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
sclass TextArea extends DynModule {
S text;
S globalID = aGlobalID();
transient JTextArea ta;
transient EditRecorder recorder;
transient ReliableSingleThread rstPersistText = rstWithDelay(1000, r persistText);
// We have auto-save of deleted modules
//bool warnOnDelete() { ret nempty(text); }
File logFile() { ret javaxDataDir("Text Area Logs/" + globalID); }
JComponent visualize() {
ta = jenableUndoRedo(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 {
temp enter();
if (ta != null) {
Pair p = textAndCaretPosition(ta);
recorder.update(p.a);
recorder.updateCaret(p.b);
print("persistText " + now());
setField(text := getText(ta));
}
}
void unvisualize() {
persistText();
super.unvisualize();
}
void setText(S text) { main.setText(ta, text); }
S text() { ret or(main.getText(ta), text); }
S _structForDuplication() {
// TODO: could fail if more module is more complex
ret jreplace(dm_struct(this), "globalID=*", "globalID=" + quote(aGlobalID()));
}
}