* @constructor * @param {BusConnector} bus
(element, bus)
| 217 | * @param {BusConnector} bus |
| 218 | */ |
| 219 | function SerialAdapterXtermJS(element, bus) |
| 220 | { |
| 221 | this.element = element; |
| 222 | |
| 223 | if(!window["Terminal"]) |
| 224 | { |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | var term = this.term = new window["Terminal"]({ |
| 229 | "logLevel": "off", |
| 230 | }); |
| 231 | term.write("This is the serial console. Whatever you type or paste here will be sent to COM1"); |
| 232 | |
| 233 | const on_data_disposable = term["onData"](function(data) { |
| 234 | for(let i = 0; i < data.length; i++) |
| 235 | { |
| 236 | bus.send("serial0-input", data.charCodeAt(i)); |
| 237 | } |
| 238 | }); |
| 239 | |
| 240 | bus.register("serial0-output-byte", function(byte) |
| 241 | { |
| 242 | term.write(Uint8Array.of(byte)); |
| 243 | }, this); |
| 244 | |
| 245 | this.destroy = function() { |
| 246 | on_data_disposable["dispose"](); |
| 247 | term["dispose"](); |
| 248 | }; |
| 249 | } |
| 250 | |
| 251 | SerialAdapterXtermJS.prototype.show = function() |
| 252 | { |