MCPcopy
hub / github.com/copy/v86 / SerialAdapterXtermJS

Function SerialAdapterXtermJS

src/browser/serial.js:219–249  ·  view source on GitHub ↗

* @constructor * @param {BusConnector} bus

(element, bus)

Source from the content-addressed store, hash-verified

217 * @param {BusConnector} bus
218 */
219function 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
251SerialAdapterXtermJS.prototype.show = function()
252{

Callers

nothing calls this directly

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected