Warning: session_start(): open(/var/lib/php/sessions/sess_nofq1vg0oit2t3bofvdbds658o, 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 EditRecorder {
Session session;
// editor state
S text = "";
int caret;
bool verbose = true;
// update the text
void update(S newText) {
S a = text, b = newText;
int i = lCommonPrefix(a, b);
a = substring(a, i);
b = substring(b, i);
int j = lCommonSuffix(a, b);
a = substring(a, 0, l(a)-j);
b = substring(b, 0, l(b)-j);
// Now differing part remains in a and b;
// i and j give length of unchanged beginning+end
if (empty(a) && empty(b)) {
if (verbose) print("no change");
ret;
}
EChange change = cnew(EChange, +session,
startIndex := i, endIndex := i+l(a), text := b);
if (verbose) print("change: " + renderConcept(change));
// Verify the change we made
assertEquals(newText, replayEdit(change, text));
text = newText;
}
void updateCaret(int pos) {
if (pos != caret) {
cnew(ECaret, +session, +pos);
caret = pos;
}
}
}
static Session session;
static JTextArea ta;
static EditRecorder er;
p-substance {
conceptsAndBot(); // persistence
session = new Session;
ta = showText("");
er = nu(EditRecorder, +session);
onUpdate(ta, r { er.update(ta.getText()) });
onCaret(ta, r { er.updateCaret(ta.getCaretPosition()) });
}