Added more directory listings

This commit is contained in:
Jeff Parsons 2016-02-01 15:50:32 -08:00
commit a7f9985785
8 changed files with 337 additions and 21 deletions

View file

@ -48,6 +48,11 @@ if (NODE) {
*
* adapter: 1 (for port 0x3F8) or 2 (for port 0x2F8); 0 if not defined
*
* binding: name of a control (based on its "binding" attribute) to bind to this port's I/O
*
* tabSize: set to a non-zero number to convert tabs to spaces (applies only to output to
* the above binding); default is 0 (no conversion)
*
* WARNING: Since the XSL file defines 'adapter' as a number, not a string, there's no need to
* use parseInt(), and as an added benefit, we don't need to worry about whether a hex or decimal
* format was used.
@ -96,6 +101,14 @@ function SerialPort(parmsSerial) {
*/
this.controlIOBuffer = null;
/*
* If controlIOBuffer is being used AND 'tabSize' is set, then we make an attempt to monitor the characters
* being echoed via echoByte(), maintain a logical column position, and convert any tabs into the appropriate
* number of spaces.
*/
this.tabSize = parmsSerial['tabSize'];
this.iLogicalCol = 0;
Component.call(this, "SerialPort", parmsSerial, SerialPort, Messages.SERIAL);
var sBinding = parmsSerial['binding'];
@ -805,13 +818,27 @@ SerialPort.prototype.updateIRR = function()
SerialPort.prototype.echoByte = function(b)
{
if (this.controlIOBuffer) {
if (b != 0x0D) {
if (b == 0x08) {
this.controlIOBuffer.value = this.controlIOBuffer.value.slice(0, -1);
} else {
this.controlIOBuffer.value += String.fromCharCode(b);
this.controlIOBuffer.scrollTop = this.controlIOBuffer.scrollHeight;
if (b == 0x0D) {
this.iLogicalCol = 0;
}
else if (b == 0x08) {
this.controlIOBuffer.value = this.controlIOBuffer.value.slice(0, -1);
/*
* TODO: Back up the correct number of columns if the character erased was a tab.
*/
if (this.iLogicalCol > 0) this.iLogicalCol--;
}
else {
var s = String.fromCharCode(b);
var nChars = (b >= 0x20? 1 : 0);
if (b == 0x09) {
var tabSize = this.tabSize || 8;
nChars = tabSize - (this.iLogicalCol % tabSize);
if (this.tabSize) s = str.pad("", nChars);
}
this.controlIOBuffer.value += s;
this.controlIOBuffer.scrollTop = this.controlIOBuffer.scrollHeight;
this.iLogicalCol += nChars;
}
return true;
}

View file

@ -714,10 +714,16 @@
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="tabSize">
<xsl:choose>
<xsl:when test="@tabsize"><xsl:value-of select="@tabsize"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="component">
<xsl:with-param name="machine" select="$machine"/>
<xsl:with-param name="class">serial</xsl:with-param>
<xsl:with-param name="parms">,adapter:<xsl:value-of select="$adapter"/>,binding:'<xsl:value-of select="$binding"/>'</xsl:with-param>
<xsl:with-param name="parms">,adapter:<xsl:value-of select="$adapter"/>,binding:'<xsl:value-of select="$binding"/>',tabSize:<xsl:value-of select="$tabSize"/></xsl:with-param>
</xsl:call-template>
</xsl:template>