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

37
LINES

< > BotCompany Repo | #1024213 // System Print Log, old version with JTextArea

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

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

!7

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

cmodule SystemPrintLog {
  int linesToShow = 100, interval = 250;
  
  transient Appendable log; // virtual NotifyingStringBuffer
  transient JTextArea ta;
  transient long changesSeen;
  
  start {
    if (dm_getBounds() == null) {
      print("Setting frame rect");
      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", ta = moveCaretToEnd(typeWriterTextArea_noUndo(str(log)))),
      "Clear", r { clearStringBuffer_gen(log) },
      "Copy to new window", r { showText("System Log", log) });
  }
  
  void unvisualize() { ta = null; }
  
  void update {
    if (ta == null) ret;
    Long changes = cast getOpt(log, 'changes);
    if (changes == null || neq(changes, changesSeen)) {
      if (changes != null) changesSeen = changes;
      setText(ta, extractLastNLinesOfString(linesToShow, str(log));
    }
  }
}

Author comment

Began life as a copy of #1018866

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024213
Snippet name: System Print Log, old version with JTextArea
Eternal ID of this version: #1024213/1
Text MD5: 6ab384ae1afafbf4bc4750e690667ba0
Transpilation MD5: 8db472f297c8c99f51d860b3d37d15c7
Author: stefan
Category: javax / gui
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-26 12:23:16
Source code size: 1079 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 148 / 215
Referenced in: [show references]