1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-26 01:04:06 +08:00
This commit is contained in:
shylinux@163.com 2022-09-14 22:21:37 +08:00
parent cbc6ada341
commit 6893d781b3
6 changed files with 62 additions and 29 deletions

View File

@ -104,8 +104,8 @@ Volcanos(chat.ONENGINE, {help: "搜索引擎", _init: function(can, meta, list,
listen: shy("监听事件", function(can, name, cb) {
arguments.callee.meta[name] = (arguments.callee.meta[name]||[]).concat(cb)
}),
signal: shy("触发事件", function(can, name, msg) { msg = msg||can.request()
can.misc.Log(gdb.SIGNAL, name, (msg._cmds||[]), name == chat.ONREMOTE? msg.Option("_msg"): msg)
signal: shy("触发事件", function(can, name, msg) { msg = msg||can.request(); var _msg = name == chat.ONREMOTE? msg.Option("_msg"): msg
_msg.Option("log.disable") != ice.TRUE && can.misc.Log(gdb.SIGNAL, name, (msg._cmds||[]), _msg)
return can.core.List(can.onengine.listen.meta[name], function(cb) { can.core.CallFunc(cb, {event: msg._event, msg: msg}) }).length
}),
})

View File

@ -164,18 +164,16 @@ Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg
try { var data = JSON.parse(event.data) } catch (e) { var data = {detail: [event.data]} }
var msg = can.request(event); msg.Reply = function() { // 回复命令
var res = can.request({})
var res = can.request({}); res._source = (msg[ice.MSG_TARGET]||[]).reverse().slice(1)||[]
res.Option({_handle: ice.TRUE, _target: (msg[ice.MSG_SOURCE]||[]).reverse().join(ice.PT)})
res._source = (msg[ice.MSG_TARGET]||[]).reverse().slice(1)||[]
res.result = (msg.result||[]).concat(can.core.List(arguments)), can.misc.Log(html.WSS, ice.MSG_RESULT, msg.result, msg)
res.append = msg.append, can.core.List(msg.append, function(key) { res[key] = msg[key] })
res.Option("log.disable", msg.Option("log.disable"))
delete(msg._event), delete(msg._can)
res.result = (msg.result||[]).concat(can.core.List(arguments))
res.Option("log.disable", msg.Option("log.disable")) != ice.TRUE && can.misc.Log(html.WSS, ice.MSG_RESULT, msg.result||[], msg)
socket.send(JSON.stringify(res))
}, msg.detail = data.detail, msg.Copy(data)
try { // 执行命令
can.misc.Log(html.WSS, ice.MSG_DETAIL, msg.detail, msg)
msg.Option("log.disable") != ice.TRUE && can.misc.Log(html.WSS, ice.MSG_DETAIL, msg.detail, msg)
can.base.isFunc(cb) && cb(event, msg, msg.detail[0], msg.detail.slice(1))
} catch (e) { can.misc.Log(e), msg.Reply() }
}
@ -287,6 +285,8 @@ Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg
if (minute < 10) { minute = "0"+minute }
var second = now.getSeconds()
if (second < 10) { second = "0"+second }
return hour+":"+minute+":"+second+"."+now.getMilliseconds()
var mill = now.getMilliseconds()
if (mill < 10) { mill = "00"+mill } else if (mill < 100) { mill = "0"+mill }
return hour+":"+minute+":"+second+"."+mill
},
})

View File

@ -389,7 +389,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", list: ["keyword", "prefix", "line
case code.KEYWORD:
case code.CONSTANT:
case code.DATATYPE:
case code.FUNCTION: return wrap(item.type, text)
case code.FUNCTION: return wrap(type, text)
default:
var t = can.core.Item(p.regexp, function(reg, type) {
if ((new RegExp(reg)).test(text)) { return type }
@ -727,6 +727,49 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮",
"username": "constant",
},
},
js: {
split: {
operator: "{[(.,:;!|<*>)]}",
},
prefix: {
"// ": code.COMMENT,
},
regexp: {
// "can.*": code.FUNCTION,
},
keyword: {
"var": code.KEYWORD,
"if": code.KEYWORD,
"else": code.KEYWORD,
"switch": code.KEYWORD,
"case": code.KEYWORD,
"default": code.KEYWORD,
"return": code.KEYWORD,
"can": code.KEYWORD,
"sub": code.KEYWORD,
"sup": code.KEYWORD,
"msg": code.KEYWORD,
"res": code.KEYWORD,
"ice": code.KEYWORD,
"kit": code.KEYWORD,
"event": code.KEYWORD,
"target": code.KEYWORD,
"window": code.KEYWORD,
"location": code.KEYWORD,
"null": code.CONSTANT,
"function": code.FUNCTION,
"Volcanos": code.FUNCTION,
"shy": code.FUNCTION,
"cb": code.FUNCTION,
"cbs": code.FUNCTION,
},
},
css: {
keyword: {
"body": code.KEYWORD,

View File

@ -12,8 +12,8 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) { can.o
term.onTitleChange(function(title) { can.isCmdMode() && can.user.title(title) })
term.onResize(function(size) { can.onimport._resize(can, item, size) })
term.onCursorMove(function() { can.onexport.term(can) })
term.onData(function(val) { can.onimport._input(can, item, val) })
term.onCursorMove(function() { can.onexport.term(can) })
can._current = term, term._item = item
term.open(can._output), term.focus()
@ -22,24 +22,17 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) { can.o
can.runAction(can.request({}, size, item), "resize", function() { can.onexport.term(can) })
},
_input: function(can, item, val) {
can.runAction(can.request({}, item), "input", [btoa(val)], function() {})
can.runAction(can.request({}, item, {"log.disable": ice.TRUE}), "input", [btoa(val)], function() {})
},
layout: function(can) {
if (can.ConfHeight() == window.innerHeight) {
can.page.style(can, can._output, html.HEIGHT, can.ConfHeight()+10, html.WIDTH, can.ConfWidth()+20, html.MAX_WIDTH, "")
} else {
can.page.style(can, can._output, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth()+20, html.MAX_WIDTH, "")
}
can.page.style(can, can._output, html.HEIGHT, can.ConfHeight()+(can.ConfHeight() == window.innerHeight? 10: 0), html.WIDTH, can.ConfWidth()+20, html.MAX_WIDTH, "")
can._current && can._current._fit.fit()
},
grow: function(can, msg, type) {
switch (type) {
case ice.EXIT: can.onmotion.clear(can); break
default: can._current.write(msg.Option(mdb.TEXT)); break
}
grow: function(can, msg) {
can._current.write(msg.Option(mdb.TEXT))
},
})
Volcanos(chat.ONEXPORT, {help: "导出数据", list: [mdb.TYPE, html.BACKGROUND, "rows", "cols", "cursorY", "cursorX"],
Volcanos(chat.ONEXPORT, {help: "导出数据", list: [mdb.TYPE, "rows", "cols", "cursorY", "cursorX"],
term: function(can) { var term = can._current, item = term._item
can.core.List(can.onexport.list, function(key) {
can.Status(key, can.base.getValid(item[key], item.extra[key], can._current[key], can._current.buffer.active[key], ""))

View File

@ -1,11 +1,9 @@
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) {
can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, "", html.MAX_WIDTH, "")
can.user.isMobile && !can.user.isLandscape() && can.onmotion.hidden(can, can._action)
var cbs = can.onimport[can.Conf(ctx.STYLE)]; if (can.base.isFunc(cbs)) {
can.core.CallFunc(cbs, {can: can, msg: msg, target: target, list: msg.Table()})
can.page.ClassList.add(can, target, can._args[ctx.STYLE])
can.core.CallFunc(cbs, {
can: can, msg: msg, target: target,
list: msg.Table(),
})
return cbs(can, msg, target)
}
@ -140,4 +138,3 @@ Volcanos(chat.ONACTION, {help: "操作数据",
can.onimport.layout(can)
},
})

View File

@ -129,8 +129,8 @@ var code = {
COMMENT: "comment",
KEYWORD: "keyword",
CONSTANT: "constant",
FUNCTION: "function",
DATATYPE: "datatype",
FUNCTION: "function",
}
var wiki = {
TITLE: "title", BRIEF: "brief", REFER: "refer", SPARK: "spark",