mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Add a "Clear" button to clear the printer paper (#35)
Before, the printer "paper" would just keep accumulating changes. Now the `printer-modal` dialog has a "clear" button that will the paper.
This commit is contained in:
parent
fb1320b9de
commit
f991833d68
@ -348,6 +348,7 @@
|
|||||||
<div class="paper"></div>
|
<div class="paper"></div>
|
||||||
</main>
|
</main>
|
||||||
<footer class="modal__footer">
|
<footer class="modal__footer">
|
||||||
|
<button class="modal__btn" onclick="Apple2.clearPrinterPaper()" aria-label="Clear the paper">Clear</button>
|
||||||
<button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
|
<button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
@ -353,6 +353,7 @@
|
|||||||
<div class="paper"></div>
|
<div class="paper"></div>
|
||||||
</main>
|
</main>
|
||||||
<footer class="modal__footer">
|
<footer class="modal__footer">
|
||||||
|
<button class="modal__btn" onclick="Apple2.clearPrinterPaper()" aria-label="Clear the paper">Clear</button>
|
||||||
<button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
|
<button class="modal__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
@ -105,7 +105,7 @@ var disk2 = new DiskII(io, driveLights, sectors);
|
|||||||
var clock = new Thunderclock(io);
|
var clock = new Thunderclock(io);
|
||||||
var smartport = new SmartPort(io, cpu, { block: true });
|
var smartport = new SmartPort(io, cpu, { block: true });
|
||||||
|
|
||||||
initUI(apple2, disk2, smartport, false);
|
initUI(apple2, disk2, smartport, printer, false);
|
||||||
|
|
||||||
io.setSlot(0, lc);
|
io.setSlot(0, lc);
|
||||||
io.setSlot(1, parallel);
|
io.setSlot(1, parallel);
|
||||||
|
@ -86,7 +86,7 @@ var disk2 = new DiskII(io, driveLights);
|
|||||||
var clock = new Thunderclock(io);
|
var clock = new Thunderclock(io);
|
||||||
var smartport = new SmartPort(io, cpu);
|
var smartport = new SmartPort(io, cpu);
|
||||||
|
|
||||||
initUI(apple2, disk2, smartport, options.e);
|
initUI(apple2, disk2, smartport, printer, options.e);
|
||||||
|
|
||||||
io.setSlot(1, parallel);
|
io.setSlot(1, parallel);
|
||||||
io.setSlot(2, slinky);
|
io.setSlot(2, slinky);
|
||||||
|
@ -35,6 +35,7 @@ var vm;
|
|||||||
var tape;
|
var tape;
|
||||||
var _disk2;
|
var _disk2;
|
||||||
var _smartPort;
|
var _smartPort;
|
||||||
|
var _printer;
|
||||||
var audio;
|
var audio;
|
||||||
var keyboard;
|
var keyboard;
|
||||||
var io;
|
var io;
|
||||||
@ -769,7 +770,11 @@ export function openPrinterModal() {
|
|||||||
MicroModal.show('printer-modal');
|
MicroModal.show('printer-modal');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initUI(apple2, disk2, smartPort, e) {
|
export function clearPrinterPaper() {
|
||||||
|
_printer.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initUI(apple2, disk2, smartPort, printer, e) {
|
||||||
_apple2 = apple2;
|
_apple2 = apple2;
|
||||||
cpu = _apple2.getCPU();
|
cpu = _apple2.getCPU();
|
||||||
io = _apple2.getIO();
|
io = _apple2.getIO();
|
||||||
@ -778,6 +783,7 @@ export function initUI(apple2, disk2, smartPort, e) {
|
|||||||
tape = new Tape(io);
|
tape = new Tape(io);
|
||||||
_disk2 = disk2;
|
_disk2 = disk2;
|
||||||
_smartPort = smartPort;
|
_smartPort = smartPort;
|
||||||
|
_printer = printer;
|
||||||
|
|
||||||
keyboard = new KeyBoard(cpu, io, e);
|
keyboard = new KeyBoard(cpu, io, e);
|
||||||
keyboard.create('#keyboard');
|
keyboard.create('#keyboard');
|
||||||
|
@ -9,6 +9,20 @@
|
|||||||
* implied warranty.
|
* implied warranty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Printer UI. The "paper" is bound to the element selected by the input.
|
||||||
|
*
|
||||||
|
* Every line that is output to the printer is added as a <div> to the paper.
|
||||||
|
* The high bit of all characters is stripped and only visible characters are
|
||||||
|
* added to the output. The following characters receive special treatment:
|
||||||
|
*
|
||||||
|
* * `EOT` (ASCII 4): deletes last character
|
||||||
|
* * `HT` (ASCII 9): replaced with 8 spaces
|
||||||
|
* * `LF` (ASCII 10): silently removed
|
||||||
|
* * `CR` (ASCII 13): a newline and carriage return
|
||||||
|
*
|
||||||
|
* @param {string} el The selector of the element on which to bind the "paper".
|
||||||
|
*/
|
||||||
export default function Printer(el) {
|
export default function Printer(el) {
|
||||||
var paper = document.querySelector(el);
|
var paper = document.querySelector(el);
|
||||||
var _lineBuffer = '';
|
var _lineBuffer = '';
|
||||||
@ -46,7 +60,7 @@ export default function Printer(el) {
|
|||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
_lineBuffer = '';
|
_lineBuffer = '';
|
||||||
paper.empty();
|
paper.innerHTML = "";
|
||||||
newLine();
|
newLine();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user