!747 !awt { m { static JTextArea textArea; static S textLogged; static L actions = new LoggingStringList("actions.log"); !include #1001455 // LoggingStringList p { textArea = makeTextArea(); addAction("new"); makeAndroid3("Smart Editor."); } static void addAction(S s) { actions.add(now() + " " + s); } static JTextArea makeTextArea() { new JTextArea textArea; makeFrame("Smart Editor", new JScrollPane(textArea)); return textArea; } static void logText() { S text = getText(); if (!eq(text, textLogged)) { textLogged = text; addAction(format3("text is *", text)); } } static synchronized S answer(S s, L history) { addAction("? " + s); try { S a = answer_impl(s, history); addAction("! " + a); ret a; } catch (Throwable e) { addAction("!!! " + getStackTrace(e)); ret "Error. " + e.toString(); } } static synchronized S answer_impl(S s, L history) { new Matches m; if (match3("load *", s, m)) { addAction(s); S what = unquote(m.m[0]); S text = null; if (isURL(what)) text = loadPage(what); else text = loadTextFile(what); if (text != null) setText(text); else { addAction("huh?"); ret "huh?"; } logText(); ret format3("OK, loaded *", what); } if (match3("drop first line", s)) setText(fromLines(dropFirst(1, toLines(getText())))); if (match3("save", s)) { logText(); ret "OK."; } !include #1001452 // Apply Translator ret null; } static S getText() { return textArea.getText(); } static void setText(final S s) { awt { // let's be clear here... textArea.setText(s); } } }