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).

1  
!7
2  
3  
// TODO: capture all of System.out/System.err
4  
5  
cmodule SystemPrintLog {
6  
  int linesToShow = 100, interval = 250;
7  
  
8  
  transient Appendable log; // virtual NotifyingStringBuffer
9  
  transient JTextArea ta;
10  
  transient long changesSeen;
11  
  
12  
  start {
13  
    if (dm_getBounds() == null) {
14  
      print("Setting frame rect");
15  
      dm_setBounds(this, 0, max(0, getHeight(dm_desktopPane())-200), 400, 200);
16  
    }
17  
    log = getCreator('print_log);
18  
    doEvery(interval, r updateMe);
19  
  }
20  
  
21  
  visualize {
22  
    ret componentPopupMenuItems(jSection("SYSTEM LOG", ta = moveCaretToEnd(typeWriterTextArea_noUndo(str(log)))),
23  
      "Clear", r { clearStringBuffer_gen(log) },
24  
      "Copy to new window", r { showText("System Log", log) });
25  
  }
26  
  
27  
  void unvisualize() { ta = null; }
28  
  
29  
  void update {
30  
    if (ta == null) ret;
31  
    Long changes = cast getOpt(log, 'changes);
32  
    if (changes == null || neq(changes, changesSeen)) {
33  
      if (changes != null) changesSeen = changes;
34  
      setText(ta, extractLastNLinesOfString(linesToShow, str(log));
35  
    }
36  
  }
37  
}

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: 216 / 305
Referenced in: [show references]