From d7e011d898a6084fd0f716ee88cb87aeb8ae5be7 Mon Sep 17 00:00:00 2001 From: shy Date: Sat, 23 Jul 2022 00:03:33 +0800 Subject: [PATCH] add xterm.js --- plugin/local/code/xterm.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 plugin/local/code/xterm.js diff --git a/plugin/local/code/xterm.js b/plugin/local/code/xterm.js new file mode 100644 index 00000000..3fd6e829 --- /dev/null +++ b/plugin/local/code/xterm.js @@ -0,0 +1,15 @@ +Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) { + can.require(["/node_modules/xterm/lib/xterm.js", "/node_modules/xterm/css/xterm.css"], function() { + can.term = new Terminal(); + can.term.open(can._output) + can.term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ') + can.term.onData(function(val) { + can.runAction(can.request({}, {"channel": can.Conf("channel")}), "input", [val], function(msg) { + can.term.write(msg.Result()) + }) + }) + }) +}, grow: function(can, str) { + can.term.write(str.replaceAll("\n", "\r\n")) +} +})