From 825dcefeb2511f3e2d4bcc443e6b902f630fd941 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Sat, 23 Jul 2022 05:23:01 +0800 Subject: [PATCH] opt xterm --- plugin/local/code/xterm.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugin/local/code/xterm.js b/plugin/local/code/xterm.js index 3fd6e829..62dca8ad 100644 --- a/plugin/local/code/xterm.js +++ b/plugin/local/code/xterm.js @@ -1,15 +1,13 @@ 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()) + can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg) + can.page.style(can, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth()) + 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.onData(function(val) { + can.runAction(can.request({}, {"channel": can.Conf("channel")}), "input", [val], function() {}) }) }) - }) -}, grow: function(can, str) { - can.term.write(str.replaceAll("\n", "\r\n")) -} + }, + grow: function(can, str) { + can.term.write(atob(str)) + }, })