!7 sclass SFAutoComplete extends DynObjectTable { transient WeakReference tc; int maxEntries = 100; start { dontPersist(); doEveryAndNow(1000, 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)); new LS list; if (nempty(word)) { list.addAll(containingIC(standardClassNames_sorted(), word)); list.addAll(containingIC(standardFunctionNames_sorted(), word)); list = takeFirst(maxEntries, list); } setData(list); }); } 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? } } }