Cleaned up how components print messages and how the Computer component overrides their notice/print/println methods (in preparation for new Computer overrides)
This commit is contained in:
parent
6f9bfa1950
commit
d4d3448fd5
20 changed files with 954 additions and 910 deletions
|
|
@ -177,9 +177,11 @@ class Computer8080 extends Component {
|
|||
*/
|
||||
var iComponent, component;
|
||||
var aComponents = Component.getComponents(this.id);
|
||||
this.panel = /** @type {Panel8080} */ (Component.getComponentByType("Panel", this.id));
|
||||
|
||||
if (this.panel && this.panel.controlPrint) {
|
||||
this.panel = /** @type {Panel8080} */ (Component.getComponentByType("Panel", this.id));
|
||||
this.controlPrint = this.panel && this.panel.bindings['print'];
|
||||
|
||||
if (this.controlPrint) {
|
||||
for (iComponent = 0; iComponent < aComponents.length; iComponent++) {
|
||||
component = aComponents[iComponent];
|
||||
/*
|
||||
|
|
@ -188,8 +190,8 @@ class Computer8080 extends Component {
|
|||
* too darn convenient to slam those overrides into the components directly.
|
||||
*/
|
||||
component.notice = this.panel.notice;
|
||||
component.print = this.panel.print;
|
||||
component.println = this.panel.println;
|
||||
component.controlPrint = this.panel.controlPrint;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -277,6 +279,18 @@ class Computer8080 extends Component {
|
|||
if (!fSuspended && this.fAutoPower) this.wait(this.powerOn);
|
||||
}
|
||||
|
||||
/**
|
||||
* clearPanel()
|
||||
*
|
||||
* @this {Computer8080}
|
||||
*/
|
||||
clearPanel()
|
||||
{
|
||||
if (this.controlPrint) {
|
||||
this.controlPrint.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getMachineID()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -229,15 +229,6 @@ class CPU8080 extends Component {
|
|||
if (DEBUGGER && this.dbg) {
|
||||
this.dbg.init();
|
||||
} else {
|
||||
/*
|
||||
* The Computer (this.cmp) knows if there's a Control Panel (this.cmp.panel), and the Control Panel
|
||||
* knows if there's a "print" control (this.cmp.panel.controlPrint), and if there IS a "print" control
|
||||
* but no debugger, the machine is probably misconfigured (most likely, the page simply neglected to
|
||||
* load the Debugger component).
|
||||
*
|
||||
* However, we don't actually need to check all that; it's always safe use println(), regardless whether
|
||||
* a Control Panel with a "print" control is present or not.
|
||||
*/
|
||||
this.println("No debugger detected");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2566,10 +2566,7 @@ class Debugger8080 extends Debugger {
|
|||
*/
|
||||
doClear(sCmd)
|
||||
{
|
||||
/*
|
||||
* TODO: There should be a clear() component method that the Control Panel overrides to perform this function.
|
||||
*/
|
||||
if (this.controlPrint) this.controlPrint.value = "";
|
||||
this.cmp.clearPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -341,11 +341,7 @@ class RAM8080 extends Component {
|
|||
*/
|
||||
writeCPMString(s)
|
||||
{
|
||||
s = s.replace(/\r/g, '');
|
||||
if (this.controlPrint) {
|
||||
this.controlPrint.value += s;
|
||||
this.controlPrint.scrollTop = this.controlPrint.scrollHeight;
|
||||
}
|
||||
this.print(s.replace(/\r/g, ''));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue