Download Jar. Uses 3874K of libraries. Click here for Pure Java version (8870L/61K).
!7 static SingleComponentPanel scp; static int startIndex; concept Sentence { S text; S action; } p-substance { unswing { db(); indexConceptField(Sentence, "text"); L<S> sentences = toLinesFullTrim(loadSnippet(#1008606)); sentences = notStartingWith("\"", sentences); time { makeUniqueConcepts(Sentence, "text", sentences); } } showFrame(centerAndSouth(scp = new SingleComponentPanel, withTopMargin(20, jcenteredline( jbutton("Prev", r { makePanel(max(startIndex-10, 0)) }), jbutton("Next", r { if (startIndex+10 < countConcepts(Sentence)) makePanel(startIndex+10) }), jbutton("Random", r { makePanel(random(countConcepts(Sentence))/10*10) }))))); makePanel(0); } svoid makePanel(int startIndex) { main.startIndex = startIndex; JPanel panel = gridLayoutPanel_trackWidth_evenlySpacedCols(2); panel.add(jlabel("Sentence")); panel.add(jlabel("Action")); for (final Sentence s : takeFirst(10, dropFirst(startIndex, list(Sentence)))) { final JTextField tfText = jtextfield_caretLeft(s.text); panel.add(tfText); new Matches m; if (jmatch("subject=* (*/*)", s.action, m)) pcall { int from = parseInt($2), len = parseInt($3); tfText.select(from, from+len); } bool hasAction = nempty(s.action); final JTextField tf = jtextfield(or2(s.action, "screw it")); final new Var<JButton> reviseBtn, okBtn; okBtn.set(jbutton("OK", r { cset(s, action := getTextTrim(tf)); disableTextField(tf); replaceComponent(okBtn!, reviseBtn!); })); reviseBtn.set(jbutton("Revise", r { cset(s, action := null); enableTextField(tf); replaceComponent(reviseBtn!, okBtn!); })); if (hasAction) disableTextField(tf); panel.add(centerAndEast(tf, hasAction ? reviseBtn! : okBtn!)); onCaret(tfText, r { int i = trimIndexRight(s.text, tfText.getSelectionStart()); int j = trimIndexLeft(s.text, tfText.getSelectionEnd()); if (j > i && s.action == null) tf.setText("subject=" + quote(substring(s.text, i, j)) + " (" + i + "/" + (j-i) + ")"); }); } scp.setComponent(jscroll(panel)); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment