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

40
LINES

< > BotCompany Repo | #1018866 // System Print Log [LIVE]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (8972L/47K).

!7

set flag standardTitlePopupMenu_noProgramFunctions.
svoid restart() {} // help out transpiler who should honor ifndefs better
svoid duplicateThisProgram() {}

// TODO: capture all of System.out/System.err

cmodule SystemPrintLog {
  int linesToShow = 100, interval = 250;
  
  transient Appendable log; // virtual NotifyingStringBuffer
  transient JFastLogView_noWrap view;
  transient long changesSeen;
  
  start {
    if (dm_getBounds() == null)
      dm_setBounds(this, 0, max(0, getHeight(dm_desktopPane())-200), 400, 200);
    log = getCreator('print_log);
    doEvery(interval, r updateMe);
  }
  
  visualize {
    ret componentPopupMenuItems(jSection("SYSTEM LOG",
      jscroll_copyBackground(view = jFastLogView_noWrap(str(log)))),
      "Clear", r { clearStringBuffer_gen(log) },
      "Copy to new window", r {  scrollAllTheWayDown(maximizeFrame(showText_fast_noWrap("System Log", log))) });
  }
  
  void update {
    JFastLogView_noWrap _view = view;
    if (_view == null) ret;
    Long changes = cast getOpt(log, 'changes);
    if (changes == null || neq(changes, changesSeen)) {
      if (changes != null) changesSeen = changes;
      _view.setText(extractLastNLinesOfString(linesToShow, str(log)));
      scrollAllTheWayDown(_view);
    }
  }
}

Author comment

Began life as a copy of #1016189

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, qmtsvidgarql, tvejysmllsmz, unoaxrwscvea, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1018866
Snippet name: System Print Log [LIVE]
Eternal ID of this version: #1018866/20
Text MD5: 0f8d10a65331090bfb4f1addfd4535df
Transpilation MD5: 33113bc226891045f131515e87b74c32
Author: stefan
Category: javax / gui
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-20 16:36:33
Source code size: 1308 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 478 / 580465
Version history: 19 change(s)
Referenced in: [show references]