!7 sclass GeneralDefinitions extends DynModule { transient S term; transient JPanel stack; transient JTextField tfInput; transient JCheckBox cbInput; transient S listName = "General definitions (long list)"; JComponent visualize() { tfInput = jcenteredtextfield(); cbInput = jcheckbox(); stack = dynamicVStack2(); onChangeAndNow(cbInput, r { setEnabled(tfInput, isChecked(cbInput)); updateMe(); }); main.onChange(tfInput, r { if (isChecked(cbInput)) updateMe() }); ret northCenterAndSouth( westAndCenter(cbInput, tfInput), stack, withMargin(jcenteredbutton("Add definition...", r { fS t = term; inputText("Definition for: " + t, voidfunc(S def) { addToMechMap(listName, litmap(t, def)); infoBox("Definition added: " + t + " = " + def); updateMe(); }); }))); } void update { if (stack == null) ret; bool myInput = isChecked(cbInput); fS s = trim(myInput ? getText(tfInput) : dm_getInterestingString()); if (!myInput) setText(tfInput, s); term = s; S text = makeText(s); replaceAllComponents(stack, ll(fontSize(17, jCenteredMultiLineLabel(text)))); } S makeText(fS s) { S text = ""; if (empty(s)) ret text; MultiMap map = mechMultiMapCI(listName); L answers = map.get(s); MultiMap map2 = mechMultiMapCI("Unauthorized Appends | " + listName); L answers2 = map2.get(s); if (empty(answers) && empty(answers2)) ret "No definitions found for " + quote(s); ret lines(concatLists( map(answers, func(S a) -> S { s + " = " + a }), map(answers2, func(S a) -> S { s + " " + unicode_questionedEquals() + " " + a }) )); } }