Proper xtermjs integration (#172)
This commit is contained in:
parent
54d413304a
commit
7a0d213429
|
@ -16,7 +16,7 @@
|
|||
// jor1k stuff
|
||||
LIB_FILES += " jor1k.js 9p.js filesystem.js marshall.js utf8.js";
|
||||
|
||||
var BUILD_FILES = "capstone-x86.min.js libwabt.js xterm.js";
|
||||
var BUILD_FILES = "capstone-x86.min.js libwabt.js";
|
||||
|
||||
var to_load = [];
|
||||
|
||||
|
|
|
@ -146,6 +146,11 @@
|
|||
return;
|
||||
}
|
||||
|
||||
const script = document.createElement("script");
|
||||
script.src = "build/xterm.js";
|
||||
script.async = true;
|
||||
document.body.appendChild(script);
|
||||
|
||||
var settings = {};
|
||||
|
||||
$("start_emulation").onclick = function()
|
||||
|
@ -1247,7 +1252,7 @@
|
|||
"vga_memory_size": vga_memory_size,
|
||||
|
||||
"screen_container": $("screen_container"),
|
||||
"serial_container": $("serial"),
|
||||
"serial_container_xtermjs": $("terminal"),
|
||||
|
||||
"boot_order": settings.boot_order || parseInt($("boot_order").value, 16) || 0,
|
||||
|
||||
|
|
|
@ -216,13 +216,17 @@ function SerialRecordingAdapter(bus)
|
|||
*/
|
||||
function SerialAdapterXtermJS(element, bus)
|
||||
{
|
||||
const serial = this;
|
||||
this.element = element;
|
||||
|
||||
var term = new window["Terminal"]();
|
||||
term.open(document.getElementById("terminal"));
|
||||
if(!window["Terminal"])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var term = this.term = new window["Terminal"]();
|
||||
term["setOption"]("logLevel", "off");
|
||||
term.write("This is the serial console. Whatever you type or paste here will be sent to COM1");
|
||||
|
||||
element.style.display = "none";
|
||||
term["onData"](function(data) {
|
||||
bus.send("serial0-input", data.charCodeAt(0));
|
||||
});
|
||||
|
@ -232,3 +236,8 @@ function SerialAdapterXtermJS(element, bus)
|
|||
term.write(chr);
|
||||
}, this);
|
||||
}
|
||||
|
||||
SerialAdapterXtermJS.prototype.show = function()
|
||||
{
|
||||
this.term && this.term.open(this.element);
|
||||
};
|
||||
|
|
|
@ -255,11 +255,15 @@ V86Starter.prototype.continue_init = async function(emulator, options)
|
|||
|
||||
if(options["serial_container"])
|
||||
{
|
||||
//this.serial_adapter = new SerialAdapter(options["serial_container"], this.bus);
|
||||
this.serial_adapter = new SerialAdapterXtermJS(options["serial_container"], this.bus);
|
||||
this.serial_adapter = new SerialAdapter(options["serial_container"], this.bus);
|
||||
//this.recording_adapter = new SerialRecordingAdapter(this.bus);
|
||||
}
|
||||
|
||||
if(options["serial_container_xtermjs"])
|
||||
{
|
||||
this.serial_adapter = new SerialAdapterXtermJS(options["serial_container_xtermjs"], this.bus);
|
||||
}
|
||||
|
||||
// ugly, but required for closure compiler compilation
|
||||
function put_on_settings(name, buffer)
|
||||
{
|
||||
|
@ -569,6 +573,8 @@ V86Starter.prototype.continue_init = async function(emulator, options)
|
|||
|
||||
function finish()
|
||||
{
|
||||
this.serial_adapter && this.serial_adapter.show && this.serial_adapter.show();
|
||||
|
||||
this.bus.send("cpu-init", settings);
|
||||
|
||||
if(settings.initial_state)
|
||||
|
|
Loading…
Reference in a new issue