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

43
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 (12390L/80K).

abstract sclass DynPrintLog extends DynModule {
  transient JFastLogView_noWrap printLogView;
  transient Lock updatePrintLog_lock = lock();
  transient StringBuffer actualPrintLog;
  transient int printLogUpdateInterval = 500;
  transient JComponent printLogPanel;
  
  visual makePrintLogPanel();
  
  JComponent makePrintLogPanel() {
    JComponent section = printLogPanel = 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  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, 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/38
Text MD5: 7b1c2aa07daf4de5a6f13192430c63c6
Transpilation MD5: 466b647c2d2624d4643942fde9d1b5dc
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-12 09:39:58
Source code size: 1348 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 655 / 3824
Version history: 37 change(s)
Referenced in: [show references]