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

40
LINES

< > BotCompany Repo | #1016205 - DynPrintLog - show program's print log as visualization - new version with fast log view

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (10578L/74K).

abstract sclass DynPrintLog extends DynModule {
  transient JFastLogView_noWrap printLogView;
  transient Lock updatePrintLog_lock = lock();
  transient StringBuffer actualPrintLog;
  transient int printLogUpdateInterval = 500;
  
  visualize {
    JComponent section = jSection("Log",
      jscroll_copyBackground(printLogView = jFastLogView_noWrap(getPrintLog())));
    componentPopupMenuItem(section, "Clear", rEnter dm_clearModulePrintLog);
    ret awtEvery(section, printLogUpdateInterval, r updatePrintLog);
  }
  
  void updatePrintLog swing {
    // TODO: optimize
    lock updatePrintLog_lock;
    JFastLogView_noWrap _view = printLogView;
    if (_view == null) ret;
    if (_view.setText(getPrintLog())) {
      // Still trying to reliably scroll down
      scrollAllTheWayDown(_view);
      awtLater(100, r { scrollAllTheWayDown(_view) });
    }
  }
  
  JFastLogView_noWrap myPrintLogComponent() { ret printLogView; }
  
  void enableWordWrap { // TODO
  }
  
  S getPrintLog() {
    if (actualPrintLog == null) {
      if (printToModule())
        actualPrintLog = _printLog;
      else
        actualPrintLog = liveLocalPrintLog_realMC(this);
    }
    ret str(actualPrintLog);
  }
}

download  show line numbers  debug dex   

Travelled to 12 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, tslmcundralx, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1016205
Snippet name: DynPrintLog - show program's print log as visualization - new version with fast log view
Eternal ID of this version: #1016205/36
Text MD5: 0bc9a9fc374c5f84caa550ea098d1278
Transpilation MD5: 51cf54fa079324d394c07b8c9a5c9cb2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-02 15:51:16
Source code size: 1237 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 326 / 1600
Version history: 35 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1016205 & http://1016205.tinybrain.de