mirror of
https://github.com/whscullin/apple1js.git
synced 2024-11-29 20:49:21 +00:00
Copy and paste
This commit is contained in:
parent
69707cb184
commit
ea6bb2c115
13
js/apple1.js
13
js/apple1.js
@ -153,7 +153,7 @@ export function toggleSpeed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setKeyBuffer(text) {
|
export function setKeyBuffer(text) {
|
||||||
io.setKeyBuffer(text);
|
io.paste(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setTurboTape(val) {
|
export function setTurboTape(val) {
|
||||||
@ -395,6 +395,17 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
window.addEventListener('keydown', _keydown);
|
window.addEventListener('keydown', _keydown);
|
||||||
window.addEventListener('keyup', _keyup);
|
window.addEventListener('keyup', _keyup);
|
||||||
|
|
||||||
|
window.addEventListener('paste', (event) => {
|
||||||
|
var paste = (event.clipboardData || window.clipboardData).getData('text');
|
||||||
|
setKeyBuffer(paste);
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('copy', (event) => {
|
||||||
|
event.clipboardData.setData('text/plain', text.getText());
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
document.querySelector('.overscan').addEventListener('paste', function(event) {
|
document.querySelector('.overscan').addEventListener('paste', function(event) {
|
||||||
io.paste(event.originalEvent.clipboardData().getData('text/plain'));
|
io.paste(event.originalEvent.clipboardData().getData('text/plain'));
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -181,6 +181,31 @@ export function TextPage()
|
|||||||
_page.data[idx] = 0xff;
|
_page.data[idx] = 0xff;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getText: function() {
|
||||||
|
function mapCharCode(charCode) {
|
||||||
|
charCode &= 0x7F;
|
||||||
|
if (charCode < 0x20) {
|
||||||
|
charCode += 0x40;
|
||||||
|
}
|
||||||
|
if (charCode >= 0x60) {
|
||||||
|
charCode -= 0x40;
|
||||||
|
}
|
||||||
|
return charCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
var buffer = '', line, charCode;
|
||||||
|
var row, col;
|
||||||
|
for (row = 0; row < 24; row++) {
|
||||||
|
line = '';
|
||||||
|
for (col = 0; col < 40; col++) {
|
||||||
|
charCode = mapCharCode(_buffer[row][col]);
|
||||||
|
line += String.fromCharCode(charCode);
|
||||||
|
}
|
||||||
|
line = line.trimRight();
|
||||||
|
buffer += line + '\n';
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
},
|
||||||
clear: function canvas_clearScreen() {
|
clear: function canvas_clearScreen() {
|
||||||
for (var row = 0; row < 24; row++) {
|
for (var row = 0; row < 24; row++) {
|
||||||
for (var col = 0; col < 40; col++) {
|
for (var col = 0; col < 40; col++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user