1
0
mirror of https://github.com/pkimpel/retro-b5500.git synced 2026-02-13 03:34:29 +00:00

Implement off-line comments in Local mode for SPO prototype.

This commit is contained in:
paul
2012-12-21 20:54:55 +00:00
parent 9d6453522f
commit f6bfb2fe20

View File

@@ -7,8 +7,6 @@
<meta http-equiv="Content-Style-Type" content="text/css">
<link id=defaultStyleSheet rel=stylesheet type="text/css" href="B5500SPOUnit.css">
<script src="../emulator/B5500IOUnit.js"></script>
<script>
window.onload = function() {
@@ -33,6 +31,16 @@ window.onload = function() {
nextCharTime: 0,
finished: null};
var keyFilter = [ // Filter keyCode values to valid B5500 ones
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, // 00-0F
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, // 10-1F
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x3F,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, // 20-2F
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, // 30-3F
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, // 40-4F
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x3F,0x5D,0x3F,0x3F, // 50-5F
0x3F,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, // 60-6F
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x3F]; // 70-7F
var hasClass = function(e, name) {
/* returns true if element "e" has class "name" in its class list */
var classes = e.className;
@@ -63,8 +71,10 @@ window.onload = function() {
var addFrameStyles = function(frame) {
/* Appends the necessary styles for the <iframe> to its internal stylesheet */
frame.contentDocument.head.innerHTML += "<style>BODY {background-color: #FFE} " +
"PRE {margin: 0; font-size: 10pt; font-family: Lucida Sans Typewriter, Courier New, Courier, monospace}";
frame.contentDocument.head.innerHTML += "<style>" +
"BODY {background-color: #FFE} " +
"PRE {margin: 0; font-size: 10pt; font-family: Lucida Sans Typewriter, Courier New, Courier, monospace}" +
"</style>";
};
var appendEmptyLine = function(count) {
@@ -111,17 +121,21 @@ window.onload = function() {
}
};
var echoChar = function(index) {
/* Echos msgCtl.buffer[index] to the SPO printer. Used by keyboard input */
var echoChar = function(c) {
/* Echoes the character code "c" to the SPO printer. Used by keyboard input */
var body = $$("SPOUT").contentDocument.body;
var line = body.lastChild.lastChild;
var c = String.fromCharCode(msgCtl.buffer[index]);
msgCtl.index = index+1;
if (index < 71) {
line.nodeValue += c;
if (c == 8) {
if (line.nodeValue.length > 0) {
line.nodeValue = line.nodeValue.substring(-1);
}
} else if (c == 13) {
appendEmptyLine(1);
} else if (line.nodeValue.length < 72) {
line.nodeValue += String.fromCharCode(c);
} else {
line.nodeValue = line.nodeValue.substring(0,71) + c;
line.nodeValue = line.nodeValue.substring(0,71) + String.fromCharCode(c);
}
};
@@ -237,7 +251,7 @@ window.onload = function() {
if (spoState == spoRemote) {
accept();
} else if (spoState == spoOutput) {
inputRequested = True;
inputRequested = true;
}
};
@@ -295,7 +309,7 @@ window.onload = function() {
printText("*** B5500 SPO TEST ***");
printText(" ");
printText("WHAT HATH BARTON WROUGHT?");
printText("WHAT HATH PASADENA WROUGHT?");
printText("");
/*****
printText("123456789.123456789.123456789.123456789.123456789.123456789.123456789.1");
@@ -341,47 +355,70 @@ window.onload = function() {
window.onkeypress = function(ev) {
var c = ev.charCode;
var stamp = new Date().getTime();
var nextTime;
var index = msgCtl.length;
var nextTime;
var result = false;
var stamp = new Date().getTime();
if (msgCtl.nextCharTime > stamp) {
nextTime = msgCtl.nextCharTime + 100;
} else {
nextTime = stamp + 100;
}
msgCtl.nextCharTime = nextTime;
if (spoState == spoInput) {
if (c >= 32 && c <= 126) {
c = B5500IOUnit.BICtoANSI[B5500IOUnit.ANSItoBIC[c]];
msgCtl.buffer[index] = c.charCodeAt(0);
msgCtl.buffer[index] = c = keyFilter[c & 0x7F];
if (msgCtl.length < 72) {
msgCtl.col++;
msgCtl.length++;
msgCtl.index++;
}
if (msgCtl.nextCharTime > stamp) {
nextTime = msgCtl.nextCharTime + 100;
} else {
nextTime = stamp + 100;
}
msgCtl.nextCharTime = nextTime;
setTimeout(function() {echoChar(index)}, nextTime-stamp);
setTimeout(function() {echoChar(c)}, nextTime-stamp);
}
} else if (spoState == spoLocal) {
if (c >= 32 && c <= 126) {
c = keyFilter[c & 0x7F];
setTimeout(function() {echoChar(c)}, nextTime-stamp);
}
}
return result;
};
window.onkeydown = function(ev) {
var c = ev.keyCode;
var result = false;
if (spoState == spoRemote) {
if (ev.keyCode == 27) {
if (c == 27) {
initiateInput(ev);
}
} else if (spoState == spoInput) {
switch (ev.keyCode) {
case 27:
switch (c) {
case 27: // ESC
cancelInput(ev);
break;
case 8:
case 8: // Backspace
backspaceChar();
break;
case 13:
case 13: // Enter
case 126: // "~" (B5500 left arrow/group mark)
terminateInput(ev);
break;
default:
result = true;
}
} else if (spoState == spoLocal) {
switch (c) {
case 8: // Backspace
case 13: // Enter
echoChar(c);
break;
default:
result = true;
}
}
return result;
};
addFrameStyles($$("SPOUT"));