1 | static ShowBigText showBigText(S title, fO function, final long delayMS) { |
2 | if (headless()) { |
3 | doEvery(toInt(delayMS), r { |
4 | O data = callF(function); |
5 | print(structureOrText(data)); |
6 | }); |
7 | null; |
8 | } |
9 | |
10 | final new ShowBigText sbt; |
11 | sbt.title = title; |
12 | sbt.showText("..."); |
13 | |
14 | // awt block is important |
15 | installTimer(sbt.is, r { |
16 | // This should work even when the function blocks forever (at least we're not calling it repeatedly in that case) |
17 | |
18 | new Thread("Updater") { |
19 | boolean running; |
20 | public void run() { |
21 | if (!running) { |
22 | running = true; |
23 | S text = null; |
24 | try { |
25 | O data = callF(function); |
26 | if (isString(data)) |
27 | text = (S) data; |
28 | else if (data instanceof S[]) { |
29 | S[] x = cast data; |
30 | text = x[0]; |
31 | sbt.title = last(x); |
32 | } |
33 | } catch (Throwable e) { |
34 | e.printStackTrace(); |
35 | text = exceptionToStringShort(e); |
36 | } finally { |
37 | running = false; |
38 | } |
39 | if (text != null) |
40 | sbt.showText(text); |
41 | } |
42 | } |
43 | }.start(); |
44 | }, delayMS, 0); |
45 | ret sbt; |
46 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001790 |
Snippet name: | showBigText - simple code for showing regularly updated big text |
Eternal ID of this version: | #1001790/11 |
Text MD5: | 6d22f4225558866a57aca0d4925970ca |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-12-18 23:51:29 |
Source code size: | 1242 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 718 / 961 |
Version history: | 10 change(s) |
Referenced in: | [show references] |