!7 // 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); } } }