Rework bell hook
This commit is contained in:
parent
4d46a4317d
commit
d9e72db5cc
19
index.js
19
index.js
|
@ -5,12 +5,6 @@ window.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|
||||||
$('#lb_files').selectedIndex = 0;
|
$('#lb_files').selectedIndex = 0;
|
||||||
|
|
||||||
var bell = (function () {
|
|
||||||
var b = new Bell(/^.*\/|/.exec(window.location)[0]);
|
|
||||||
return function () { b.play(); };
|
|
||||||
} ());
|
|
||||||
|
|
||||||
|
|
||||||
var frame = $('#frame');
|
var frame = $('#frame');
|
||||||
|
|
||||||
var keyboard = frame;
|
var keyboard = frame;
|
||||||
|
@ -26,7 +20,18 @@ window.addEventListener('DOMContentLoaded', function () {
|
||||||
frame.parentNode.insertBefore(keyboard, frame);
|
frame.parentNode.insertBefore(keyboard, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
var tty = new TTY($('#screen'), keyboard, bell);
|
var tty = new TTY($('#screen'), keyboard);
|
||||||
|
(function() {
|
||||||
|
// Install output hook for bell
|
||||||
|
var b = new Bell(/^.*\/|/.exec(window.location)[0]);
|
||||||
|
var orig = tty.writeChar;
|
||||||
|
tty.writeChar = function index_writeChar(c) {
|
||||||
|
if (c.charCodeAt(0) === 7)
|
||||||
|
b.play();
|
||||||
|
else
|
||||||
|
orig(c);
|
||||||
|
};
|
||||||
|
}());
|
||||||
var dos = new DOS(tty);
|
var dos = new DOS(tty);
|
||||||
|
|
||||||
var lores = new LoRes($('#lores'), 40, 48);
|
var lores = new LoRes($('#lores'), 40, 48);
|
||||||
|
|
11
tty.js
11
tty.js
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// tty = new TTY( screen_element, keyboard_element, bell );
|
// tty = new TTY( screen_element, keyboard_element );
|
||||||
// tty.clearScreen()
|
// tty.clearScreen()
|
||||||
// tty.clearEOL()
|
// tty.clearEOL()
|
||||||
// tty.clearEOS()
|
// tty.clearEOS()
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
// tty.TEXT_STYLE_INVERSE = 1
|
// tty.TEXT_STYLE_INVERSE = 1
|
||||||
// tty.TEXT_STYLE_FLASH = 2
|
// tty.TEXT_STYLE_FLASH = 2
|
||||||
|
|
||||||
function TTY(screenElement, keyboardElement, bell) {
|
function TTY(screenElement, keyboardElement) {
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|
||||||
|
@ -348,15 +348,10 @@ function TTY(screenElement, keyboardElement, bell) {
|
||||||
case 4: // DOS hook takes care of CHR$(4)
|
case 4: // DOS hook takes care of CHR$(4)
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
|
case 7: // (BEL) bell - handled by index hook
|
||||||
// no-op
|
// no-op
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: // (BEL) bell
|
|
||||||
if (bell) {
|
|
||||||
bell();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8: // (BS) backspace
|
case 8: // (BS) backspace
|
||||||
self.cursorLeft();
|
self.cursorLeft();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue