mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 01:04:06 +08:00
opt xterm.js
This commit is contained in:
parent
8a55bd00c5
commit
9834321291
10
frame.js
10
frame.js
@ -514,6 +514,14 @@ Volcanos(chat.ONLAYOUT, {help: "页面布局", _init: function(can, target) { ta
|
|||||||
]}
|
]}
|
||||||
]}] }])
|
]}] }])
|
||||||
},
|
},
|
||||||
|
profile_auto: function(can, target) {
|
||||||
|
can.onlayout.profile(can, target)
|
||||||
|
can.page.ClassList.add(can, can.ui.project, ice.AUTO)
|
||||||
|
can.page.ClassList.add(can, can.ui.profile, ice.AUTO)
|
||||||
|
can.page.ClassList.add(can, can.ui.display, ice.AUTO)
|
||||||
|
can.onmotion.toggle(can, can.ui.profile, true)
|
||||||
|
can.onmotion.hidden(can, can.ui.project)
|
||||||
|
},
|
||||||
profile: function(can, target) { target = target||can._output
|
profile: function(can, target) { target = target||can._output
|
||||||
function toggle(view) { var show = view.style.display == html.NONE
|
function toggle(view) { var show = view.style.display == html.NONE
|
||||||
can.onmotion.toggle(can, view, show), view._toggle? view._toggle(event, show): can.onimport.layout && can.onimport.layout(can)
|
can.onmotion.toggle(can, view, show), view._toggle? view._toggle(event, show): can.onimport.layout && can.onimport.layout(can)
|
||||||
@ -599,7 +607,7 @@ Volcanos(chat.ONMOTION, {help: "动态特效", _init: function(can, target) {
|
|||||||
clear: function(can, target) { return can.page.Modify(can, target||can._output, ""), true },
|
clear: function(can, target) { return can.page.Modify(can, target||can._output, ""), true },
|
||||||
cache: function(can, next) { var list = can.base.Obj(can.core.List(arguments).slice(2), [can._output])
|
cache: function(can, next) { var list = can.base.Obj(can.core.List(arguments).slice(2), [can._output])
|
||||||
can.core.List(list, function(item) { item._cache_key && can.page.Cache(item._cache_key, item, item.scrollTop+1) })
|
can.core.List(list, function(item) { item._cache_key && can.page.Cache(item._cache_key, item, item.scrollTop+1) })
|
||||||
var key = next(can._cache_data = can._cache_data||{})
|
var key = next(can._cache_data = can._cache_data||{}); if (!key) { return }
|
||||||
return can.core.List(list, function(item) { var pos = can.page.Cache(item._cache_key = key, item)
|
return can.core.List(list, function(item) { var pos = can.page.Cache(item._cache_key = key, item)
|
||||||
if (pos) { item.scrollTo && item.scrollTo(0, pos-1); return item }
|
if (pos) { item.scrollTo && item.scrollTo(0, pos-1); return item }
|
||||||
}).length > 0
|
}).length > 0
|
||||||
|
@ -3,6 +3,7 @@ Volcanos("core", {help: "数据结构",
|
|||||||
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
|
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
|
||||||
switch (typeof v) {
|
switch (typeof v) {
|
||||||
case lang.OBJECT: for (var j = 0; j < v.length; j++) { list.push(v[j]) } break
|
case lang.OBJECT: for (var j = 0; j < v.length; j++) { list.push(v[j]) } break
|
||||||
|
case lang.NUMBER: list.push(v+""); break
|
||||||
case lang.FUNCTION: v = v()
|
case lang.FUNCTION: v = v()
|
||||||
default: v && list.push(v+"")
|
default: v && list.push(v+"")
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,8 @@ Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg
|
|||||||
})
|
})
|
||||||
return len
|
return len
|
||||||
},
|
},
|
||||||
Table: function(cb) { if (!msg.append || msg.append.length == 0) { return }
|
Table: function(cb) {
|
||||||
var max = "", len = 0; can.core.List(msg.append, function(key, index) {
|
return can.core.List(msg.Length(), function(value, index, array) { var one = {}, res
|
||||||
if (msg[key] && msg[key].length > len) { max = key, len = msg[key].length }
|
|
||||||
})
|
|
||||||
|
|
||||||
return can.core.List(msg[max], function(value, index, array) { var one = {}, res
|
|
||||||
can.core.List(msg.append, function(key) { one[key] = (msg[key]&&msg[key][index]||"") })
|
can.core.List(msg.append, function(key) { one[key] = (msg[key]&&msg[key][index]||"") })
|
||||||
return can.base.isFunc(cb) && (res = cb(one, index, array)) && res != undefined && res || one
|
return can.base.isFunc(cb) && (res = cb(one, index, array)) && res != undefined && res || one
|
||||||
})
|
})
|
||||||
|
@ -91,7 +91,9 @@ Volcanos("page", {help: "用户界面", ClassList: {
|
|||||||
case mdb.LIST: break
|
case mdb.LIST: break
|
||||||
case html.INNER: data.innerHTML = item.inner; break
|
case html.INNER: data.innerHTML = item.inner; break
|
||||||
case html.CLICK: data.onclick = item.click; break
|
case html.CLICK: data.onclick = item.click; break
|
||||||
default: data[key] = item[key]
|
default:
|
||||||
|
if (item[key] == undefined) { break }
|
||||||
|
data[key] = item[key]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
10
lib/user.js
10
lib/user.js
@ -86,6 +86,10 @@ Volcanos("user", {help: "用户操作", info: {}, agent: {
|
|||||||
"plugin": "插件",
|
"plugin": "插件",
|
||||||
"prev": "上一页", "next": "下一页",
|
"prev": "上一页", "next": "下一页",
|
||||||
|
|
||||||
|
"Close": "关闭",
|
||||||
|
"Close others": "关闭其它",
|
||||||
|
"Close all": "关闭所有",
|
||||||
|
|
||||||
"trash": "删除",
|
"trash": "删除",
|
||||||
"open": "打开", "close": "关闭",
|
"open": "打开", "close": "关闭",
|
||||||
"start": "启动", "stop": "停止",
|
"start": "启动", "stop": "停止",
|
||||||
@ -229,17 +233,17 @@ Volcanos("user", {help: "用户操作", info: {}, agent: {
|
|||||||
var ui = can.page.Append(can, document.body, [{view: chat.CARTE, style: {left: 0, top: 0}, onmouseleave: function(event) {
|
var ui = can.page.Append(can, document.body, [{view: chat.CARTE, style: {left: 0, top: 0}, onmouseleave: function(event) {
|
||||||
// can.page.Remove(can, ui._target)
|
// can.page.Remove(can, ui._target)
|
||||||
}, list: can.core.List(list, function(item, index) {
|
}, list: can.core.List(list, function(item, index) {
|
||||||
return can.base.isString(item)? {view: html.ITEM, list: [{text: can.user.trans(can, item), onclick: function(event) {
|
return can.base.isString(item)? item ==""? /* space */ {view: "space"}: /* string */ {view: html.ITEM, list: [{text: can.user.trans(can, item), onclick: function(event) {
|
||||||
can.user.isMobile && can.page.Remove(can, ui._target)
|
can.user.isMobile && can.page.Remove(can, ui._target)
|
||||||
can.base.isFunc(cb) && cb(event, item, meta, index)
|
can.base.isFunc(cb) && cb(event, item, meta, index)
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
}, onmouseenter: function(event) {
|
}, onmouseenter: function(event) {
|
||||||
carte._float && can.page.Remove(can, carte._float._target)
|
carte._float && can.page.Remove(can, carte._float._target)
|
||||||
} }] }: can.base.isArray(item)? {view: html.ITEM, list: [{text: can.user.trans(can, item[0])+" -> "}], onmouseenter: function(event) {
|
} }] }: can.base.isArray(item)? /* array */ {view: html.ITEM, list: [{text: can.user.trans(can, item[0])+" -> "}], onmouseenter: function(event) {
|
||||||
var sub = can.user.carte(event, can, meta, item.slice(1), cb, carte)
|
var sub = can.user.carte(event, can, meta, item.slice(1), cb, carte)
|
||||||
carte._float && can.page.Remove(can, carte._float._target), carte._float = sub
|
carte._float && can.page.Remove(can, carte._float._target), carte._float = sub
|
||||||
can.onlayout.figure(event, can, sub._target, true)
|
can.onlayout.figure(event, can, sub._target, true)
|
||||||
} }: {view: html.ITEM, list: [{text: can.user.trans(can, item.name), onclick: function(event) {
|
} }: /* object */ {view: html.ITEM, list: [{text: can.user.trans(can, item.name), onclick: function(event) {
|
||||||
can.user.isMobile && can.page.Remove(can, ui._target)
|
can.user.isMobile && can.page.Remove(can, ui._target)
|
||||||
can.base.isFunc(cb) && cb(event, item.name, meta, index)
|
can.base.isFunc(cb) && cb(event, item.name, meta, index)
|
||||||
}, onmouseenter: function(event) {
|
}, onmouseenter: function(event) {
|
||||||
|
@ -89,6 +89,7 @@ body>div.toast div.progress div.current { background-color:red; height:10px; }
|
|||||||
body>div.toast div.action { display:block; }
|
body>div.toast div.action { display:block; }
|
||||||
body>div.carte { padding:0; }
|
body>div.carte { padding:0; }
|
||||||
body>div.carte div.item { background-color:#0e3369b3; padding:3px 12px; }
|
body>div.carte div.item { background-color:#0e3369b3; padding:3px 12px; }
|
||||||
|
body>div.carte div.space { border-bottom:solid 1px gray; }
|
||||||
body>div.input div.content { overflow:auto; }
|
body>div.input div.content { overflow:auto; }
|
||||||
body>div.input td { padding:5px; }
|
body>div.input td { padding:5px; }
|
||||||
body>div.input select { width:181px; }
|
body>div.input select { width:181px; }
|
||||||
@ -114,6 +115,7 @@ input { font-size:1.1rem; height:31px; }
|
|||||||
table.content th, table.content td, div.zone>div.name, div.item, div.code, code.story, div.story[data-type=spark] { font-size:1.1rem; font-family:monospace; }
|
table.content th, table.content td, div.zone>div.name, div.item, div.code, code.story, div.story[data-type=spark] { font-size:1.1rem; font-family:monospace; }
|
||||||
div.status>div.item>label { font-size:0.6rem; font-family:monospace; }
|
div.status>div.item>label { font-size:0.6rem; font-family:monospace; }
|
||||||
div.status>div.item { padding:4px; height:22px; }
|
div.status>div.item { padding:4px; height:22px; }
|
||||||
|
div.action>div.tabs { padding:5px 10px; height:21px; }
|
||||||
svg { font-family:monospace; }
|
svg { font-family:monospace; }
|
||||||
|
|
||||||
/* display */
|
/* display */
|
||||||
@ -147,6 +149,7 @@ div.story[data-type=spark] span:hover { background-color:deepskyblue; box-shadow
|
|||||||
table.content tr.select, table.content tr:hover, h1:hover, h2:hover, h3:hover, div.item.select, div.item:hover, div.tabs.select, div.tabs:hover, .select { background-color:steelblue; }
|
table.content tr.select, table.content tr:hover, h1:hover, h2:hover, h3:hover, div.item.select, div.item:hover, div.tabs.select, div.tabs:hover, .select { background-color:steelblue; }
|
||||||
table.content th:hover, table.content td.select, table.content td:hover { background-color:cornflowerblue; }
|
table.content th:hover, table.content td.select, table.content td:hover { background-color:cornflowerblue; }
|
||||||
body>div.carte div.item:hover { background-color:cornflowerblue; }
|
body>div.carte div.item:hover { background-color:cornflowerblue; }
|
||||||
|
div.action>div.tabs:hover { background-color:steelblue; }
|
||||||
|
|
||||||
/* scrollbar */
|
/* scrollbar */
|
||||||
body { overflow:-moz-scrollbars-none; -ms-overflow-style:none; }
|
body { overflow:-moz-scrollbars-none; -ms-overflow-style:none; }
|
||||||
@ -329,3 +332,6 @@ div.profile.auto { position:absolute; right:0; z-index:10; }
|
|||||||
fieldset.plugin.location>div.action input[type=text] {
|
fieldset.plugin.location>div.action input[type=text] {
|
||||||
width:40px;
|
width:40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset.xterm div.action>div.tabs:hover { background-color:black; }
|
||||||
|
fieldset.xterm div.action>div.tabs.select { background-color:black; }
|
||||||
|
@ -208,7 +208,7 @@ Volcanos(chat.ONACTION, {help: "交互数据", _init: function(can, cb, target)
|
|||||||
can.user.carte(event, can, can.onaction, list, cb)
|
can.user.carte(event, can, can.onaction, list, cb)
|
||||||
},
|
},
|
||||||
share: function(event, can, args) {
|
share: function(event, can, args) {
|
||||||
can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE].concat(args||[], [chat.RIVER, can.Conf(chat.RIVER), chat.STORM, can.Conf(chat.STORM)]))
|
can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE].concat(args||[], [chat.RIVER, can.Conf(chat.RIVER)||"", chat.STORM, can.Conf(chat.STORM)||""]))
|
||||||
},
|
},
|
||||||
|
|
||||||
usernick: function(event, can) { if (can.user.mod.isPod || can.user.isExtension || can.user.isLocalFile) { return }
|
usernick: function(event, can) { if (can.user.mod.isPod || can.user.isExtension || can.user.isLocalFile) { return }
|
||||||
|
@ -1,81 +1,143 @@
|
|||||||
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) {
|
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) {
|
||||||
can.onmotion.clear(can), can.onlayout.profile(can), can.base.isFunc(cb) && cb(msg)
|
can.onmotion.clear(can), can.onlayout.profile_auto(can), can.base.isFunc(cb) && cb(msg)
|
||||||
can.page.style(can, can.ui.content, html.HEIGHT, can.ConfHeight(can.ConfHeight()+html.ACTION_HEIGHT), html.WIDTH, can.ConfWidth())
|
can.onimport.layout(can), can.onappend._status(can), can.term = {}
|
||||||
can.page.ClassList.add(can, can.ui.project, ice.AUTO)
|
|
||||||
can.page.ClassList.add(can, can.ui.profile, ice.AUTO)
|
|
||||||
can.onmotion.hidden(can, can.ui.project)
|
|
||||||
can.onmotion.hidden(can, can._status)
|
|
||||||
|
|
||||||
msg.Table(function(value) { can.onimport.item(can, value, function() {}, function(event) {
|
can.requireModules(["xterm/css/xterm.css", "xterm", "xterm-addon-fit", "xterm-addon-web-links"], function() {
|
||||||
can.user.carteRight(event, can, {
|
if (can.Option(mdb.HASH) != "") {
|
||||||
"select": function() {
|
var item = {hash: can.Option(mdb.HASH)}; msg.Table(function(value) { can.core.Value(item, value.key, value.value) })
|
||||||
can.runAction(can.request(event, value), "select", [])
|
return can.onmotion.delay(can, function() { can.onimport._connect(can, item).writeln() }, 1000)
|
||||||
},
|
}
|
||||||
"rename": function() {
|
|
||||||
can.user.input(event, can, [mdb.NAME], function(args) {
|
var hash = can.sup._hash||(location.hash||"#").slice(1)||true, list = msg.Table(function(value) {
|
||||||
can.runAction(can.request(event, value), mdb.MODIFY, args)
|
var item = can.onimport._item(can, value); value.hash == hash && (item.click(), hash = false)
|
||||||
})
|
});
|
||||||
},
|
hash && can.runAction({}, mdb.CREATE, [mdb.TYPE, "", mdb.NAME, "term"], function(msg) {
|
||||||
|
can.onimport._item(can, {hash: msg.Result(), name: msg.Option(mdb.NAME)}).click()
|
||||||
})
|
})
|
||||||
}) })
|
|
||||||
|
|
||||||
can.require(["/require/node_modules/xterm/lib/xterm.js", "/require/node_modules/xterm/css/xterm.css", "/require/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js"], function() { can.term = {}
|
|
||||||
can.runAction({}, mdb.CREATE, ["type", "xterm", "name", "some"], function(msg) { can.onimport._connect(can, msg.Result()) })
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_connect: function(can, hash, target) { var term = new Terminal({theme: {background: "#060101"}}); can.term[hash] = term
|
layout: function(can) {
|
||||||
target = target||can.ui.content, target._term = term, term._target = target
|
can.page.style(can, can.ui.content, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth())
|
||||||
var fitAddon = new FitAddon.FitAddon(); term.loadAddon(fitAddon)
|
},
|
||||||
term.open(target||can.ui.content), term.onResize(function(size) {
|
_size: function(can, item, size) {
|
||||||
can.runAction(can.request({}, {"hash": hash}, size), "resize", [], function() {})
|
can.runAction(can.request({}, size, item), "resize", [], function() {})
|
||||||
}), fitAddon.fit()
|
},
|
||||||
term.onData(function(val) {
|
_input: function(can, item, val) {
|
||||||
can.runAction(can.request({}, {"hash": hash}), "input", [val], function() {})
|
can.runAction(can.request({}, item), "input", [val], function() {})
|
||||||
|
},
|
||||||
|
_item: function(can, item) { item.extra = can.base.Obj(item.extra, {})
|
||||||
|
return can.onimport.item(can, item, function(event) { can.runAction(can.request(event, item), "select")
|
||||||
|
item._menu = shy(can.ondetail, can.ondetail.list, function(event, button, meta) { can.request(event, item), meta[button](event, can, button, item) })
|
||||||
|
item._tabs? item._tabs.click(): item._tabs = can.onimport.tabs(can, [item], function(event) {
|
||||||
|
can.onimport._connect(can, item)
|
||||||
|
})
|
||||||
|
}, function(event) {
|
||||||
|
can.user.carteRight(event, can, can.ondetail, can.ondetail.list, function(event, button) {
|
||||||
|
can.request(event, item, item.extra)
|
||||||
|
can.ondetail[button](event, can, button, item)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
_plug: function(can, item) {
|
||||||
|
can.onmotion.clear(can, can.ui.profile)
|
||||||
|
can.onimport.plug(can, item.extra, can.ui.profile, function() {
|
||||||
|
})
|
||||||
|
},
|
||||||
|
_connect: function(can, item, target) { target = target||can.ui.content
|
||||||
|
can.sup._hash = item.hash, can.isCmdMode() && (location.hash = item.hash)
|
||||||
|
if (can.onmotion.cache(can, function() { return item.hash }, target, can.ui.profile)) {
|
||||||
|
return can.onexport.term(can, item, can.term[item.hash])
|
||||||
|
}
|
||||||
|
|
||||||
|
var term = new Terminal({theme: item.extra, cursorBlink: true, tabStopWidth: 4})
|
||||||
|
var fitAddon = new FitAddon.FitAddon(); term.loadAddon(fitAddon)
|
||||||
|
term.loadAddon(new WebLinksAddon.WebLinksAddon())
|
||||||
|
|
||||||
|
term.open(target||can.ui.content)
|
||||||
|
term.onData(function(val) { can.onimport._input(can, item, val) })
|
||||||
|
term.onResize(function(size) { can.onimport._size(can, item, size) })
|
||||||
|
fitAddon.fit()
|
||||||
|
|
||||||
var submode = false
|
var submode = false
|
||||||
term.onTitleChange(function(title) {
|
term.onCursorMove(function(e) {
|
||||||
can.isCmdMode() && can.user.title(title)
|
can.misc.Debug(e)
|
||||||
can.misc.Debug("title", title)
|
|
||||||
})
|
})
|
||||||
term.onKey(function(e) { var event = e.domEvent
|
term.onKey(function(e) { var event = e.domEvent
|
||||||
if (submode) {
|
if (submode) { switch (event.key) {
|
||||||
switch (event.key) {
|
case "l": target.nextSibling && target.nextSibling._term && target.nextSibling._term.focus(); break
|
||||||
case "l":
|
case "h": target.previousSibling && target.previousSibling._term && target.previousSibling._term.focus(); break
|
||||||
target.nextSibling && target.nextSibling._term && target.nextSibling._term.focus()
|
} }
|
||||||
break
|
submode = event.ctrlKey && event.key == "g"
|
||||||
case "h":
|
can.onexport.term(can, item, term)
|
||||||
target.previousSibling && target.previousSibling._term && target.previousSibling._term.focus()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (event.ctrlKey && event.key == "g") {
|
|
||||||
submode = true
|
|
||||||
} else {
|
|
||||||
submode = false
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
})
|
||||||
|
term.onTitleChange(function(title) { can.isCmdMode() && can.user.title(title) })
|
||||||
|
|
||||||
|
can.term[item.hash] = target._term = term, term._target = target
|
||||||
|
can.runAction(can.request(event, item), "select")
|
||||||
|
can.onexport.term(can, item, term)
|
||||||
|
can.onimport._plug(can, item)
|
||||||
|
item._term = term
|
||||||
|
return term
|
||||||
},
|
},
|
||||||
grow: function(can, msg, str) { var data = can.base.Obj(str)
|
grow: function(can, msg, str) { var data = can.base.Obj(str), term = can.term[msg.Option(mdb.HASH)]
|
||||||
var term = can.term[msg.Option(mdb.HASH)]
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "data":
|
case "data": term.write(atob(data.text)); break
|
||||||
term.write(atob(data.text))
|
case "exit": can.onmotion.clear(can, term._target); break
|
||||||
break
|
|
||||||
case "exit":
|
|
||||||
can.onmotion.clear(can, term._target)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos(chat.ONACTION, {help: "操作数据", list: ["split"],
|
Volcanos(chat.ONACTION, {help: "操作数据", list: ["create", "split", "prunes"],
|
||||||
_trans: {split: "分屏"},
|
_trans: {split: "分屏", theme: "主题"},
|
||||||
split: function(event, can) { can.request(event, {m: 2, n: 2})
|
create: function(event, can) {
|
||||||
can.user.input(event, can, ["m", "n"], function(data) { can.onmotion.clear(can, can.ui.content)
|
can.user.input(event, can, [mdb.TYPE, mdb.NAME, "background", "index", "args"], function(args, data) {
|
||||||
can.core.List(parseInt(data.m), function() { var row = can.page.Append(can, can.ui.content, [{view: "row", style: {height: can.ConfHeight()/data.m}}]).first
|
can.runAction({}, mdb.CREATE, args, function(msg) { data.hash = msg.Result()
|
||||||
can.core.List(parseInt(data.n), function() { var div = can.page.Append(can, row, [{view: "col", style: {height: can.ConfHeight()/data.m, width: can.ConfWidth()/data.n-2}}]).first
|
can.onimport._item(can, {hash: msg.Result(), name: msg.Option(mdb.NAME)}).click()
|
||||||
can.runAction({}, mdb.CREATE, ["type", "xterm", "name", "some"], function(msg) { can.onimport._connect(can, msg.Result(), div) })
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
split: function(event, can) { can.request(event, {name: "term", nrow: 2, ncol: 2})
|
||||||
|
can.user.input(event, can, [mdb.TYPE, mdb.NAME, "nrow", "ncol"], function(data) {
|
||||||
|
can.onimport.tabs(can, [data], function(event) {
|
||||||
|
if (can.onmotion.cache(can, function() { return data.name }, can.ui.content)) { return }
|
||||||
|
can.core.List(parseInt(data.nrow), function(nrow) { var row = can.page.Append(can, can.ui.content, [{view: "row", style: {height: can.ConfHeight()/data.nrow}}]).first
|
||||||
|
can.core.List(parseInt(data.ncol), function(ncol) { var col = can.page.Append(can, row, [{view: "col", style: {height: can.ConfHeight()/data.nrow, width: can.ConfWidth()/data.ncol-2}}]).first
|
||||||
|
can.runAction({}, mdb.CREATE, [mdb.TYPE, data.type, mdb.NAME, can.core.Keys(data.name, nrow, ncol)], function(msg) { can.onimport._connect(can, {hash: msg.Result()}, col) })
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Volcanos(chat.ONDETAIL, {help: "操作数据", list: ["share", "plugin", "theme", "rename", "remove"],
|
||||||
|
share: function(event, can, button, item) { var msg = can.request(event); msg.Option("args", "")
|
||||||
|
can.onmotion.share(event, can, [{name: chat.TITLE, value: item.name}, {name: chat.TOPIC, values: [cli.WHITE, cli.BLACK]}], [
|
||||||
|
mdb.NAME, "web.code.xterm", mdb.TEXT, JSON.stringify([can.sup._hash]),
|
||||||
|
])
|
||||||
|
},
|
||||||
|
plugin: function(event, can, button, item) {
|
||||||
|
can.user.input(event, can, [ctx.INDEX, ctx.ARGS], function(args, data) {
|
||||||
|
can.runAction(event, mdb.MODIFY, args), can.base.Copy(item.extra, data), can.onimport._plug(can, item)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
theme: function(event, can, button, item) {
|
||||||
|
can.user.input(event, can, ["background", "selection", "cursor", "foreground"], function(args, data) {
|
||||||
|
item._term && item._term.setOption("theme", data), can.runAction(event, mdb.MODIFY, args)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
rename: function(event, can, button, item) {
|
||||||
|
can.user.input(event, can, [mdb.NAME], function(args) {
|
||||||
|
can.runAction(event, button, args)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
remove: function(event, can, button, item) {
|
||||||
|
can.runAction(event, button)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
Volcanos(chat.ONEXPORT, {help: "导出数据", list: ["type", "background", "rows", "cols", "cursorY", "cursorX", "index"],
|
||||||
|
term: function(can, item, term) {
|
||||||
|
can.core.List(can.onexport.list, function(key) {
|
||||||
|
can.Status(key, can.base.getValid(item[key], item.extra[key], term[key], term.buffer.active[key], ""))
|
||||||
|
})
|
||||||
|
return term
|
||||||
|
},
|
||||||
|
})
|
||||||
|
@ -95,13 +95,14 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
|||||||
function close(item) { var next = item.nextSibling||item.previousSibling; next && next.click()
|
function close(item) { var next = item.nextSibling||item.previousSibling; next && next.click()
|
||||||
if (next) { can.base.isFunc(cbs) && cbs(item._meta), can.page.Remove(can, item) }
|
if (next) { can.base.isFunc(cbs) && cbs(item._meta), can.page.Remove(can, item) }
|
||||||
}
|
}
|
||||||
|
var menu = tabs._menu||shy({}, [], function(event, button, meta) { (meta[button])(event, can, button) })
|
||||||
can.page.Modify(can, item, {draggable: true, _close: function() { close(item) }, _meta: tabs,
|
can.page.Modify(can, item, {draggable: true, _close: function() { close(item) }, _meta: tabs,
|
||||||
onmouseenter: function(event) { can.user.carte(event, can, kit.Dict(
|
onmouseenter: function(event) { can.user.carte(event, can, can.base.Copy(kit.Dict(
|
||||||
"close tab", function(event) { close(item) },
|
"Close", function(event) { close(item) },
|
||||||
"close other", function(event) { can.page.Select(can, action, html.DIV_TABS, function(_item) { _item == item || close(_item) }) },
|
"Close others", function(event) { can.page.Select(can, action, html.DIV_TABS, function(_item) { _item == item || close(_item) }) },
|
||||||
"close all", function(event) { can.page.Select(can, action, html.DIV_TABS, close) }
|
"Close all", function(event) { can.page.Select(can, action, html.DIV_TABS, close) },
|
||||||
), ["close tab", "close other", "close all"].concat(tabs._menu||[]), function(event, button, meta) {
|
), menu.meta), ["Close", "Close others", "Close all", ""].concat(menu.list), function(event, button, meta) {
|
||||||
(meta[button]||can.onaction[button])(event, can, button)
|
menu(event, button, meta)
|
||||||
}) },
|
}) },
|
||||||
ondragstart: function(event) { action._drop = function(before) { action.insertBefore(event.target, before) } },
|
ondragstart: function(event) { action._drop = function(before) { action.insertBefore(event.target, before) } },
|
||||||
ondragover: function(event) { event.preventDefault(), action._drop(event.target) },
|
ondragover: function(event) { event.preventDefault(), action._drop(event.target) },
|
||||||
@ -122,9 +123,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
|||||||
]}
|
]}
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
plug: function(can, meta, target, cb) { meta.type = "plug"
|
plug: function(can, meta, target, cb) { if (!meta || !meta.index) { return }
|
||||||
can.onappend.plugin(can, meta, function(sub) {
|
meta.type = "plug", can.onappend.plugin(can, meta, function(sub) {
|
||||||
sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, can.Option()), meta.index, cmds, cb) }
|
sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, can.Option()), meta.index, cmds, cb) }
|
||||||
|
sub.onaction.close = function() { can.onmotion.hidden(sub, sub._target) }
|
||||||
can.base.isFunc(cb) && cb(sub)
|
can.base.isFunc(cb) && cb(sub)
|
||||||
}, target)
|
}, target)
|
||||||
},
|
},
|
||||||
|
9
proto.js
9
proto.js
@ -314,6 +314,15 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", pack:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
requireModules: function(libs, cb, each) {
|
||||||
|
for (var i = 0; i < libs.length; i++) {
|
||||||
|
if (libs[i].indexOf("http") == 0) { continue }
|
||||||
|
if (libs[i].indexOf("/") == 0) { continue }
|
||||||
|
if (libs[i].indexOf(".css") == -1 && libs[i].indexOf(".js") == -1) { libs[i] = libs[i]+"/lib/"+libs[i]+".js" }
|
||||||
|
libs[i] = "/require/node_modules/"+libs[i]
|
||||||
|
}
|
||||||
|
can.require(libs, cb, each)
|
||||||
|
},
|
||||||
require: function(libs, cb, each) { if (!libs || libs.length == 0) {
|
require: function(libs, cb, each) { if (!libs || libs.length == 0) {
|
||||||
typeof cb == lang.FUNCTION && setTimeout(function() { cb(can) }, 10)
|
typeof cb == lang.FUNCTION && setTimeout(function() { cb(can) }, 10)
|
||||||
return // 加载完成
|
return // 加载完成
|
||||||
|
Loading…
x
Reference in New Issue
Block a user