Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

46
LINES

< > BotCompany Repo | #1001790 // showBigText - simple code for showing regularly updated big text

JavaX fragment (include)

static ShowBigText showBigText(S title, fO function, final long delayMS) {
  if (headless()) {
    doEvery(toInt(delayMS), r {
      O data = callF(function);
      print(structureOrText(data));
    });
    null;
  }
  
  final new ShowBigText sbt;
  sbt.title = title;
  sbt.showText("...");
    
  // awt block is important
  installTimer(sbt.is, r {
    // This should work even when the function blocks forever (at least we're not calling it repeatedly in that case)
    
    new Thread("Updater") {
      boolean running;
      public void run() {
        if (!running) {
          running = true;
          S text = null;
          try {
            O data = callF(function);
            if (isString(data))
              text = (S) data;
            else if (data instanceof S[]) {
              S[] x = cast data;
              text = x[0];
              sbt.title = last(x);
            }
          } catch (Throwable e) {
            e.printStackTrace();
            text = exceptionToStringShort(e);
          } finally {
            running = false;
          }
          if (text != null)
            sbt.showText(text);
        }
      }
    }.start();
  }, delayMS, 0);
  ret sbt;
}

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: 658 / 896
Version history: 10 change(s)
Referenced in: [show references]