Uses 911K of libraries. Click here for Pure Java version (12040L/66K).
!7 cmodule GeneralDefinitions { transient S term; transient JPanel stack; transient OptionalInputPanel inputPanel; transient S listName = generalDefinitions_listName(); transient int maxResults = 500; start { dm_useLocallyCopiedMechLists(); dm_onTopInput(rstUpdate()); } visualize { inputPanel = new OptionalInputPanel(this); onEnter(inputPanel.tfInput, r addADefinition); stack = dynamicVStack2(); ret northCenterAndSouth( inputPanel.panel, jscroll_trackWidth(stack), withMargin(jcenteredbuttons("Add definition...", r addADefinition, "All definitions", r { showText("All definitions", ai_renderDefinitions( values(mechMultiMapPairsCI(listName)), values(mechMultiMapPairsCI("Unauthorized Appends | " + listName)))) }))); } void update { if (stack == null) ret; replaceAllComponents(stack, ll(fontSize(17, jCenteredMultiLineLabel(makeText(term = inputPanel.input()))))); } S makeText(fS query) { if (empty(query)) ret ""; MultiMap<S, Pair<S>> map = mechMultiMapPairsCI(listName); L<Pair<S>> answers = definitions_dropInvalidatedFromPairs(map.get(query)); MultiMap<S, Pair<S>> map2 = mechMultiMapPairsCI("Unauthorized Appends | " + listName); L<Pair<S>> answers2 = definitions_dropInvalidatedFromPairs(map2.get(query)); S text = trim(ai_renderDefinitions(answers, answers2) + "\n" + prependIfNempty("Possibly related:\n", lines(concatLists( scoredSearch2(maxResults, query, map(func(Pair<S> p) -> S { ai_renderDefinition(p.a, p.b, false) }, listMinusSet(definitions_dropInvalidatedFromPairs(values(map)), answers))), scoredSearch2(maxResults, query, map(func(Pair<S> p) -> S { ai_renderDefinition(p.a, p.b, true) }, listMinusSet(definitions_dropInvalidatedFromPairs(values(map2)), answers2))))))); ret empty(text) ? "No definitions found for " + quote(query) : text; } void addADefinition { temp enter(); fS t = term; final JTextField tfWord = jtextfield(t), tfDefinition = jtextfield(); showFormTitled("Add Definition", "Word/Phrase:", tfWord, "Definition:", tfDefinition, rThread { S word = gtt(tfWord), def = gtt(tfDefinition); Pair<Bool, S> p = generalDefinitions_add(word, def); infoBox(p.b); if (p.a) updateMe(); }); requestFocus(tfDefinition); } }
Began life as a copy of #1016431
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016466 |
Snippet name: | General Definitions v3 [OK] |
Eternal ID of this version: | #1016466/45 |
Text MD5: | 9326a3e303c1bb59bf866d36e775c376 |
Transpilation MD5: | 2922a47448a243d503de9f722260adbe |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-16 16:21:21 |
Source code size: | 2503 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 556 / 6058 |
Version history: | 44 change(s) |
Referenced in: | -