Download Jar. Uses 6678K of libraries. Click here for Pure Java version (11005L/79K).
1 | !7 |
2 | |
3 | sS snippetID; |
4 | sS savedText, remoteText; |
5 | static EditorFrame e; |
6 | |
7 | import org.fife.ui.autocomplete.*; |
8 | |
9 | p-substance {
|
10 | autoRestart(); |
11 | load('savedText);
|
12 | |
13 | e = new EditorFrame; |
14 | print("Input map: " + className(e.getTextArea().getInputMap());
|
15 | e._setFont(deriveFont(e._getFont(), 16)); |
16 | thread { installAutoComplete(); }
|
17 | |
18 | e.setText(savedText); |
19 | showFrame(e); |
20 | frameIcon(e, #1101185 /*#1004655*/); |
21 | |
22 | addMenu(e, "New", "New text", f newText); |
23 | |
24 | addMenu(e, "Load", "Load snippet...", r {
|
25 | selectSnippetID(vf1(f _loadSnippet)); |
26 | }); |
27 | |
28 | addMenu(e, "Save", "Save snippet", r { saveSnippetThen(null) });
|
29 | |
30 | addMenu(e, "Transpile", |
31 | "Save & Quick Transpile", r { transpile(false) },
|
32 | "Save & Medium Transpile", r { transpile(true) });
|
33 | addMenu(e, "Activate", "Butter-Reload", f _butterReload); |
34 | |
35 | S snippetID = cast readPersistentVar('snippetID);
|
36 | if (snippetID != null) _loadSnippet(snippetID); |
37 | |
38 | hideConsole(); |
39 | |
40 | awtCalcEvery(e, 1000, f update); |
41 | onFrameDeactivated(e, f fullUpdate); |
42 | } |
43 | |
44 | svoid update { update(windowActive(e)); }
|
45 | svoid fullUpdate { update(true); }
|
46 | svoid update(bool full) {
|
47 | S text = e.getText(); |
48 | setAndSaveIfChanged(savedText := text); |
49 | |
50 | if (!full) ret; |
51 | |
52 | Pair<Int, S> p = testBracketHygieneExt(text); |
53 | S status = ""; |
54 | if (remoteText != null && neq(remoteText, text)) |
55 | status = "Changes. "; |
56 | if (p == null) |
57 | status += "Hygienic"; |
58 | else {
|
59 | status += p.b; |
60 | //setCaretPosition(ta, p.a); |
61 | } |
62 | silentStatus(trim(status)); |
63 | } |
64 | |
65 | svoid status(S s) {
|
66 | silentStatus(infoBoxAndReturn(s)); |
67 | } |
68 | |
69 | svoid silentStatus(S s) {
|
70 | e.setStatus(s); |
71 | } |
72 | |
73 | svoid saveSnippetThen(final Runnable next) {
|
74 | if (empty(snippetID)) ret; |
75 | fS text = getText(e.textArea); |
76 | status("Saving...");
|
77 | thread {
|
78 | fS page = editSnippet(snippetID, text); |
79 | remoteText = text; // TODO: check save result |
80 | status("Saved snippet: " + page);
|
81 | awtCallF(next); |
82 | } |
83 | } |
84 | |
85 | svoid _butterReload() {
|
86 | time { butterReload(snippetID); }
|
87 | infoBox("Reloaded in " + lastTiming_format100ms());
|
88 | } |
89 | |
90 | svoid transpile(final bool medium) {
|
91 | saveSnippetThen(r { _transpile(medium) });
|
92 | } |
93 | |
94 | svoid _transpile(final bool medium) {
|
95 | status("Transpiling...");
|
96 | //jdisable(btnEleuReload); |
97 | |
98 | thread "Transpiling" {
|
99 | try {
|
100 | final Pair<Bool, S> p = transpileOnServer(snippetID, medium ? "medium" : "quick"); |
101 | awt {
|
102 | if (p.a) |
103 | status("Transpiled OK!");
|
104 | else {
|
105 | status("Transpilation error. " + p.b);
|
106 | showText("Transpilation Error", p.b);
|
107 | } |
108 | } |
109 | } catch print e {
|
110 | status("Transpilation problem. " + e);
|
111 | } |
112 | //jenable(btnEleuReload); |
113 | } |
114 | } |
115 | |
116 | svoid _loadSnippet(S snippetID) {
|
117 | e.textArea.setText(remoteText = loadSnippet(snippetID)); |
118 | setAndSave('snippetID, snippetID);
|
119 | frameTitle(e, snippetID + " - " + snippetTitle(snippetID)); |
120 | } |
121 | |
122 | svoid newText {
|
123 | setAndSave(snippetID := null); |
124 | remoteText = null; |
125 | S lastText = e.getText(); |
126 | if (nempty(lastText)) logQuotedWithDate("saved-texts.log", lastText);
|
127 | e.setText("");
|
128 | frameTitle(e, programTitle()); |
129 | } |
130 | |
131 | svoid cleanMeUp {
|
132 | setAndSaveIfChanged(savedText := e.getText()); |
133 | } |
134 | |
135 | svoid installAutoComplete {
|
136 | final new DefaultCompletionProvider provider; |
137 | loading "Loading AutoComplete data" {
|
138 | for (S s : concatLists( |
139 | allJavaKeywords(), standardFunctionNames())) |
140 | provider.addCompletion(new BasicCompletion(provider, s)); |
141 | } |
142 | |
143 | swing {
|
144 | new AutoCompletion(provider).install(e.textArea); |
145 | } |
146 | } |
Began life as a copy of #1004353
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
| Snippet ID: | #1014780 |
| Snippet name: | Snippet Editor v1 [too slow, shouldn't use] |
| Eternal ID of this version: | #1014780/53 |
| Text MD5: | e3b15be5c08be3c747dc4b9f3a42b976 |
| Transpilation MD5: | 6120569c2098f46730bca4f4bd47b141 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX source code (desktop) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-05-17 13:04:46 |
| Source code size: | 3601 bytes / 146 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 897 / 33745 |
| Version history: | 52 change(s) |
| Referenced in: | [show references] |