!7 sclass SFAutoComplete extends DynObjectTable { transient WeakReference tc; int maxEntries = 100; start { doEveryAndNow(2000, r { if (!isVisible()) ret; JTextComponent c = optCast(JTextComponent, getFocusOwner()); if (c == null) ret; tc = weakRef(c); int i = getCaretPosition(c); S word = tok_lastTokenIfNoSpaceAfter(takeFirst(getText(c), i)); setData(takeFirst(maxEntries, prefixSubSet(standardFunctionNames_sorted(), word)); }); } void onDoubleClick(S s) ctex { final JTextComponent c = getWeakRef(tc); if (c != null) { int i = getCaretPosition(c); Document doc = c.getDocument(); S word = tok_lastTokenIfNoSpaceAfter(takeFirst(getText(c), i)); if (swic(s, word)) doc.remove(i -= l(word), l(word)); doc.insertString(i, s, null); awt { focusComponent(c); } // TODO: doesn't work? } } }