The Component printBuffer should only be used by Component static functions
This commit is contained in:
parent
9f99649a87
commit
061c839a33
27 changed files with 344 additions and 265 deletions
|
|
@ -79,7 +79,7 @@ l.toString=function(){return this.name?this.name:this.id||this.type};
|
|||
l.Cb=function(a,b,c){switch(b){case "clear":return this.na[b]||(this.na[b]=c,c.onclick=function(a){return function(){a.na.print&&(a.na.print.value="")}}(this)),!0;case "print":return this.na[b]||(this.na[b]=c,this.Ca=function(a){this.O(a,this.type);return!0},c.value="",this.print=function(a){return function(b){wb(a,b)}}(c),this.O=function(a,b){return function(a,c){a||(a="");c!=Lb.Ce||"..."!=a.slice(-3)?(c&&(a=c+": "+a),wb(b,a+"\n")):xb(b,a,a+".")}}(this,c)),!0;default:return!1}};l.log=function(){};
|
||||
l.print=function(){};l.O=function(){};l.status=function(a){this.O(this.type+": "+a)};l.Ca=function(a,b,c){if(!b){var d=zb("Computer",this.id);if(d&&d.ca.Tf)return console.log("ignoring notice during unload: "+a),!1}c=c||this.type;b||lb((c?c+": ":"")+a);return!0};function Mb(a,b){a.ca.error=!0;a.Ca(b)}function Nb(a,b){b&&(a.ca.ready?b():a.rg=b);return a.ca.ready}function Ob(a,b){a.ca.error||(a.ca.ready=!1!==b,a.ca.ready&&(b=a.rg,a.rg=null,b&&b()))}
|
||||
function Pb(a,b){a.ca.qf&&(b?a.ca.eh=!0:void 0===b&&a.O(a.toString()+" busy"));return a.ca.qf}function Qb(a,b){if(a.ca.eh)return a.ca.qf=!1,a.ca.eh=!1;if(a.ca.error)return a.O(a.toString()+" error"),!1;a.ca.qf=b;return a.ca.qf}l.Xb=function(){return this.ca.dc=!0};l.Wb=function(a,b){b&&(this.ca.dc=!1);return!0};function t(a,b){if(a.ba){a===a.ba?b|=0:b=b||a.ic;var c=a.ba.ic&b;return!!b&&c===b||!!(c&a.ba.zl)}return!1}function Rb(a,b,c,d){a.ba&&(!0===c||t(a,c|0))&&a.ba.message(b,d)}
|
||||
function w(a,b,c,d,e,f,g){a.ba&&(!0===g?g=0:null==g&&(g=a.ic),Sb(a.ba,a,b,c,d,e,f,g))}var Lb={Vp:"notice",gq:"warning",ERROR:"error",Ce:"progress"};window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
|
||||
function w(a,b,c,d,e,f,g){a.ba&&(!0===g?g=0:null==g&&(g=a.ic),Sb(a.ba,a,b,c,d,e,f,g))}var Lb={ERROR:"error",Vp:"notice",Ce:"progress",SCRIPT:"script",gq:"warning"};window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
|
||||
var ub=window?window.PCjs.Machines:{},rb=window?window.PCjs.Components:[],Gb=window?window.PCjs.Commands:{},Ib=["hold","sleep","wait"],Jb={alert:function(a){lb(a);return!0},sleep:function(a,b){setTimeout(a,+b);return!1}},Kb={select:function(a,b,c){var d=!1;if(a=a.bindings[b])for(b=0;b<a.options.length;b++)if(a.options[b].textContent==c){a.selectedIndex!=b&&(a.selectedIndex=b);d=!0;break}return d}};
|
||||
Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){b=b||0;for(var c=this.length;b<c;b++)if(this[b]===a)return b;return-1});Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)});
|
||||
Function.prototype.bind||(Function.prototype.bind=function(a){function b(){return e.apply(this instanceof c&&a?this:a,d.concat(Array.prototype.slice.call(arguments)))}function c(){}if("function"!=typeof this)throw new TypeError("Function.prototype.bind: non-callable object");var d=Array.prototype.slice.call(arguments,1),e=this;c.prototype=this.prototype;b.prototype=new c;return b});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1178,7 +1178,7 @@ class Str {
|
|||
}
|
||||
|
||||
/**
|
||||
* replace(sFind, sReplace, s)
|
||||
* replace(sSearch, sReplace, s)
|
||||
*
|
||||
* The JavaScript replace() function ALWAYS interprets "$" specially in replacement strings, even when
|
||||
* the search string is NOT a RegExp; specifically:
|
||||
|
|
@ -1193,36 +1193,36 @@ class Str {
|
|||
* So, if a replacement string containing dollar signs passes through a series of replace() calls, untold
|
||||
* problems could result. Hence, this function, which simply uses the replacement string as-is.
|
||||
*
|
||||
* Similar to the JavaScript replace() method, this replaces only one occurrence (ie, the FIRST occurrence);
|
||||
* it might be nice to add options to replace the LAST occurrence and/or ALL occurrences, but we'll revisit
|
||||
* that later.
|
||||
* Similar to the JavaScript replace() method (when sSearch is a string), this replaces only ONE occurrence
|
||||
* (ie, the FIRST occurrence); it might be nice to add options to replace the LAST occurrence and/or ALL
|
||||
* occurrences, but we'll revisit that later.
|
||||
*
|
||||
* @param {string} sFind
|
||||
* @param {string} sSearch
|
||||
* @param {string} sReplace
|
||||
* @param {string} s
|
||||
* @return {string}
|
||||
*/
|
||||
static replace(sFind, sReplace, s)
|
||||
static replace(sSearch, sReplace, s)
|
||||
{
|
||||
var i = s.indexOf(sFind);
|
||||
var i = s.indexOf(sSearch);
|
||||
if (i >= 0) {
|
||||
s = s.substr(0, i) + sReplace + s.substr(i + sFind.length);
|
||||
s = s.substr(0, i) + sReplace + s.substr(i + sSearch.length);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* replaceAll(sFind, sReplace, s)
|
||||
* replaceAll(sSearch, sReplace, s)
|
||||
*
|
||||
* @param {string} sFind
|
||||
* @param {string} sSearch
|
||||
* @param {string} sReplace
|
||||
* @param {string} s
|
||||
* @return {string}
|
||||
*/
|
||||
static replaceAll(sFind, sReplace, s)
|
||||
static replaceAll(sSearch, sReplace, s)
|
||||
{
|
||||
var a = {};
|
||||
a[sFind] = sReplace;
|
||||
a[sSearch] = sReplace;
|
||||
return Str.replaceArray(a, s);
|
||||
}
|
||||
|
||||
|
|
@ -2920,14 +2920,34 @@ class Component {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Component.print(s)
|
||||
*
|
||||
* Components that inherit from this class should use this.print(), rather than Component.print(), because
|
||||
* if a Control Panel is loaded, it will override only the instance method, not the class method (overriding the
|
||||
* class method would improperly affect any other machines loaded on the same page).
|
||||
*
|
||||
* @this {Component}
|
||||
* @param {string} s
|
||||
*/
|
||||
static print(s)
|
||||
{
|
||||
if (!COMPILED) {
|
||||
var i = s.lastIndexOf('\n');
|
||||
if (i >= 0) {
|
||||
Component.println(s.substr(0, i));
|
||||
s = s.substr(i + 1);
|
||||
}
|
||||
Component.printBuffer += s;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Component.println(s, type, id)
|
||||
*
|
||||
* For non-diagnostic messages, which components may override to control the destination/appearance of their output.
|
||||
*
|
||||
* Components that inherit from this class should use the instance method, this.println(), rather than Component.println(),
|
||||
* because if a Control Panel is loaded, it will override only the instance method, not the class method (overriding the class
|
||||
* method would improperly affect any other machines loaded on the same page).
|
||||
* Components that inherit from this class should use this.println(), rather than Component.println(), because
|
||||
* if a Control Panel is loaded, it will override only the instance method, not the class method (overriding the
|
||||
* class method would improperly affect any other machines loaded on the same page).
|
||||
*
|
||||
* @param {string} [s] is the message text
|
||||
* @param {string} [type] is the message type
|
||||
|
|
@ -2936,7 +2956,9 @@ class Component {
|
|||
static println(s, type, id)
|
||||
{
|
||||
if (!COMPILED) {
|
||||
s = Component.printBuffer + (s || "");
|
||||
Component.log((id? (id + ": ") : "") + (s? ("\"" + s + "\"") : ""), type);
|
||||
Component.printBuffer = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3058,9 +3080,6 @@ class Component {
|
|||
*/
|
||||
static replaceControl(control, sSearch, sReplace)
|
||||
{
|
||||
/*
|
||||
* Prevent the <textarea> from getting too large; otherwise, printing becomes slower and slower.
|
||||
*/
|
||||
var sText = control.value;
|
||||
var i = sText.lastIndexOf(sSearch);
|
||||
if (i < 0) {
|
||||
|
|
@ -3068,6 +3087,9 @@ class Component {
|
|||
} else {
|
||||
sText = sText.substr(0, i) + sReplace + sText.substr(i + sSearch.length);
|
||||
}
|
||||
/*
|
||||
* Prevent the <textarea> from getting too large; otherwise, printing becomes slower and slower.
|
||||
*/
|
||||
if (COMPILED && sText.length > 8192) sText = sText.substr(sText.length - 4096);
|
||||
control.value = sText;
|
||||
control.scrollTop = control.scrollHeight;
|
||||
|
|
@ -3332,7 +3354,7 @@ class Component {
|
|||
* ^J ^M ^K ^I ^H ^L
|
||||
*
|
||||
* To support any other non-printable 8-bit character, such as ESC, you should use \xXX, where XX
|
||||
* is the ASCII code in hex. For ESC, that would \x1B.
|
||||
* is the ASCII code in hex. For ESC, that would be \x1B.
|
||||
*
|
||||
* @param {string} sScript
|
||||
* @return {Array}
|
||||
|
|
@ -3430,7 +3452,7 @@ class Component {
|
|||
* instead, but it's a bit too confusing mingling script output in a window that
|
||||
* already mingles Debugger and machine output.
|
||||
*/
|
||||
Component.println('script: ' + aTokens.join(' '));
|
||||
Component.println(aTokens.join(' '), Component.TYPE.SCRIPT);
|
||||
|
||||
var fnCallReady = null;
|
||||
if (Component.asyncCommands.indexOf(sCommand) >= 0) {
|
||||
|
|
@ -3712,8 +3734,6 @@ class Component {
|
|||
/**
|
||||
* print(s)
|
||||
*
|
||||
* For non-diagnostic messages, which components may override to control the destination/appearance of their output.
|
||||
*
|
||||
* Components using this.print() should wait until after their constructor has run to display any messages, because
|
||||
* if a Control Panel has been loaded, its override will not take effect until its own constructor has run.
|
||||
*
|
||||
|
|
@ -3722,19 +3742,12 @@ class Component {
|
|||
*/
|
||||
print(s)
|
||||
{
|
||||
var i = s.lastIndexOf('\n');
|
||||
if (i >= 0) {
|
||||
Component.println(s.substr(0, i));
|
||||
s = s.substr(i + 1);
|
||||
}
|
||||
Component.printBuffer += s;
|
||||
Component.print(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* println(s, type, id)
|
||||
*
|
||||
* For non-diagnostic messages, which components may override to control the destination/appearance of their output.
|
||||
*
|
||||
* Components using this.println() should wait until after their constructor has run to display any messages, because
|
||||
* if a Control Panel has been loaded, its override will not take effect until its own constructor has run.
|
||||
*
|
||||
|
|
@ -3745,8 +3758,7 @@ class Component {
|
|||
*/
|
||||
println(s, type, id)
|
||||
{
|
||||
Component.println(Component.printBuffer + s, type, id || this.id);
|
||||
Component.printBuffer = "";
|
||||
Component.println(s, type, id || this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -4024,15 +4036,16 @@ class Component {
|
|||
}
|
||||
|
||||
/*
|
||||
* These are the standard TYPE values you can pass as the second argument to println(); in reality,
|
||||
* you can pass anything you want, because they are just tacked onto the message as a prefix, with the
|
||||
* exception of PROGRESS, which will suppress the message unless we're in DEBUG or INIT mode.
|
||||
* These are the standard TYPE values you can pass as an optional argument to println(); in reality,
|
||||
* you can pass anything you want, because they are simply prepended to the message, although PROGRESS
|
||||
* messages may also be merged with earlier similar messages to keep the output buffer under control.
|
||||
*/
|
||||
Component.TYPE = {
|
||||
NOTICE: "notice",
|
||||
WARNING: "warning",
|
||||
ERROR: "error",
|
||||
PROGRESS: "progress"
|
||||
NOTICE: "notice",
|
||||
PROGRESS: "progress",
|
||||
SCRIPT: "script",
|
||||
WARNING: "warning"
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ function lb(a){for(var b=!0,c=mb[a];c&&c.length;){var d=c.splice(0,1)[0],e=d[0],
|
|||
l.toString=function(){return this.name?this.name:this.id||this.type};
|
||||
l.yb=function(a,b,c){switch(b){case "clear":return this.ja[b]||(this.ja[b]=c,c.onclick=function(a){return function(){a.ja.print&&(a.ja.print.value="")}}(this)),!0;case "print":return this.ja[b]||(this.ja[b]=c,this.ua=function(a){this.ub(a,this.type);return!0},c.value="",this.print=function(a){return function(b){cb(a,b)}}(c),this.ub=function(a,b){return function(a,c){a||(a="");c!=qb.$d||"..."!=a.slice(-3)?(c&&(a=c+": "+a),cb(b,a+"\n")):db(b,a,a+".")}}(this,c)),!0;default:return!1}};l.log=function(){};
|
||||
l.print=function(){};l.ub=function(){};l.status=function(a){this.ub(this.type+": "+a)};l.ua=function(a,b,c){if(!b){var d=fb("Computer",this.id);if(d&&d.Z.jf)return console.log("ignoring notice during unload: "+a),!1}c=c||this.type;b||r((c?c+": ":"")+a);return!0};function rb(a,b){a.Z.error=!0;a.ua(b)}function sb(a,b){b&&(a.Z.ready?b():a.Hf=b);return a.Z.ready}function tb(a,b){a.Z.error||(a.Z.ready=!1!==b,a.Z.ready&&(b=a.Hf,a.Hf=null,b&&b()))}
|
||||
function ub(a,b){if(a.Z.pg)return a.Z.zf=!1,a.Z.pg=!1;if(a.Z.error)return a.ub(a.toString()+" error"),!1;a.Z.zf=b;return a.Z.zf}l.Pb=function(){return this.Z.Zb=!0};l.Ob=function(a,b){b&&(this.Z.Zb=!1);return!0};var qb={xo:"notice",Io:"warning",ERROR:"error",$d:"progress"};window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
|
||||
function ub(a,b){if(a.Z.pg)return a.Z.zf=!1,a.Z.pg=!1;if(a.Z.error)return a.ub(a.toString()+" error"),!1;a.Z.zf=b;return a.Z.zf}l.Pb=function(){return this.Z.Zb=!0};l.Ob=function(a,b){b&&(this.Z.Zb=!1);return!0};var qb={ERROR:"error",xo:"notice",$d:"progress",SCRIPT:"script",Io:"warning"};window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
|
||||
var ab=window?window.PCjs.Machines:{},Za=window?window.PCjs.Components:[],mb=window?window.PCjs.Commands:{},nb=["hold","sleep","wait"],ob={alert:function(a){r(a);return!0},sleep:function(a,b){setTimeout(a,+b);return!1}},pb={select:function(a,b,c){var d=!1;if(a=a.bindings[b])for(b=0;b<a.options.length;b++)if(a.options[b].textContent==c){a.selectedIndex!=b&&(a.selectedIndex=b);d=!0;break}return d}};
|
||||
Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){b=b||0;for(var c=this.length;b<c;b++)if(this[b]===a)return b;return-1});Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)});
|
||||
Function.prototype.bind||(Function.prototype.bind=function(a){function b(){return e.apply(this instanceof c&&a?this:a,d.concat(Array.prototype.slice.call(arguments)))}function c(){}if("function"!=typeof this)throw new TypeError("Function.prototype.bind: non-callable object");var d=Array.prototype.slice.call(arguments,1),e=this;c.prototype=this.prototype;b.prototype=new c;return b});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue