!7 cmodule TextAssist > DynPrintLogAndEnabled { int moduleID = 576; // editor ID, XXX S lastText; start { doEvery(1.0, r check); } void check { S text = cast dm_rcall getText(moduleID); pcall { compareTexts(lastText, text); } setField(lastText := text); } void compareTexts(S lastText, S text) { LS linesA = lines(lastText); LS linesB = lines(text); // need same number of lines if (l(linesA) != l(linesB)) ret with print("Line count changed, exiting"); L indices = differingIndices(linesA, linesB); if (l(indices) != 1) ret with print("# changed lines: " + l(indices) + ", exiting"); int i = first(indices); S oldLine = linesA.get(i), newLine = linesB.get(i); // Make a TextEdit to see what is changed in line TextEdit edit = createTextEdit(oldLine, newLine); if (edit == null) ret with print("Line not changed? Weird."); print("Have text edit in line " + i + ": " + edit); } }