1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
harveyshao 2022-12-13 22:29:44 +08:00
parent e7491633f3
commit 73a1af3b46
2 changed files with 546 additions and 564 deletions

View File

@ -1,4 +1,90 @@
Volcanos(chat.ONIMPORT, {
Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) {
can.onmotion.clear(can), can.page.ClassList.add(can, can._fields, code.INNER), can.onlayout.profile(can)
can.onimport._profile(can, can.ui.profile), can.onimport._display(can, can.ui.display)
if (msg.Result() == "" && can.Option(nfs.LINE) == "1") { return }
can.page.styleWidth(can, can.ui.project, 240)
can.isCmdMode() && can.ConfHeight(can.ConfHeight()+2*html.ACTION_HEIGHT)
if (msg.Option(nfs.FILE)) {
msg.Option(nfs.PATH) && can.Option(nfs.PATH, msg.Option(nfs.PATH))
can.Option(nfs.FILE, msg.Option(nfs.FILE))
msg.Option(nfs.LINE) && can.Option(nfs.LINE, msg.Option(nfs.LINE))
}
can.onengine.plugin(can, can.onplugin)
var paths = can.core.Split(can.Option(nfs.PATH), ice.FS); can.Option(nfs.PATH, paths[0])
var files = can.core.Split(can.Option(nfs.FILE), ice.FS); can.Option(nfs.FILE, files[0])
can.core.List(paths.concat(msg.modules||[], can.sup.paths||[], can.core.Split(msg.Option("repos"))), function(p) { if (paths.indexOf(p) == -1 && p[0] != ice.PS) { paths.push(p) } })
can.sup.paths = paths
can.ui._content = can.ui.content, can.ui._profile_output = can.ui.profile_output
can.tabview = can.tabview||{}, can.history = can.history||[], can.toolkit = {}, can.extentions = {}
can.profile_size = {}, can.display_size = {}
if (can.user.isWebview) { var last = can.misc.localStorage(can, "web.code.inner:currentFile"); if (last) { var ls = can.core.Split(last, ice.DF) } }
switch (can.Mode()) {
case chat.SIMPLE: can.onmotion.hidden(can, can.ui.project); break
case chat.FLOAT: can.onmotion.hidden(can, can.ui.project); break
case chat.CMD: can.onimport._tabs(can), can.onmotion.hidden(can, can._status) // no break
case chat.FULL: // no break
default: can.onimport.project(can, paths)
can.onengine.listen(can, "tabview.view.init", function() { if (can.user.isMobile) { return } var p = can.onsyntax[can.parse]
can.Option(nfs.PATH).indexOf("src/") == 0 && p && p.render && can.onaction[ice.SHOW]({}, can); if (can.page.ClassList.has(can, can._fields, chat.PLUGIN)) {
p && p.engine && can.onaction[ice.EXEC]({}, can)
}
})
can.onimport._keydown(can), can.onimport._toolkit(can, can.ui.toolkit), can.onimport._session(can, msg, function() {
files.length > 1 && can.onmotion.delay(can, function() { can.core.Next(files.slice(1), function(file, next) {
can.onimport.tabview(can, can.Option(nfs.PATH), file, can.Option(nfs.LINE), next)
}, function() { can.onimport.tabview(can, paths[0], files[0], "") }) })
last && ls.length > 0 && can.onmotion.delay(can, function() { can.onimport.tabview(can, ls[0], ls[1], ls[2]) }, 500)
})
}
var hash = location.hash; can.tabview[can.onexport.keys(can)] = msg
can.onimport.tabview(can, can.Option(nfs.PATH), can.Option(nfs.FILE), can.Option(nfs.LINE), function() {
if (can.isCmdMode() && hash) { var args = can.core.Split(decodeURIComponent(hash).slice(1))
can.onmotion.delay(can, function() { can.onimport.tabview(can, args[args.length-3]||can.Option(nfs.PATH), args[args.length-2]||can.Option(nfs.FILE), args[args.length-1]) }, 500)
}
}), can.base.isFunc(cb) && cb(msg)
},
_profile: function(can, target) {
var ui = can.onimport._panel(can, target, kit.Dict(
mdb.LINK, function(event) {
if ([nfs.ZML, nfs.IML].indexOf(can.base.Ext(can.Option(nfs.FILE))) > -1) {
can.user.open(can.misc.MergePodCmd(can, {website: can.base.trimPrefix(can.base.Path(can.Option(nfs.PATH), can.Option(nfs.FILE)), "src/website/")}))
} else {
can.user.open(can.misc.MergePodCmd(can, {cmd: can.base.Path(can.Option(nfs.PATH), can.Option(nfs.FILE))}))
}
},
html.WIDTH, function(event) {
can.user.input(event, can, [{name: html.WIDTH, value: can.profile_size[can.onexport.keys(can)]*100/can.ConfWidth()||50}], function(list) {
can.profile_size[can.onexport.keys(can)] = can.ConfWidth()*parseInt(list[0])/100, can.onaction[ice.SHOW](event, can)
})
},
)); can.ui.profile_output = ui.output
},
_display: function(can, target) {
},
_toolkit: function(can, target) {
can.ui.toolkit = can.onappend.field(can, "toolkit", {}, can._output)
},
_keydown: function(can) { if (!can.isCmdMode()) { return }
can.onkeymap._build(can), can._root.onengine.listen(can, chat.ONKEYDOWN, function(event) {
if (event.ctrlKey && event.key >= "0" && event.key <= "9") {
return can.page.Select(can, can.ui._tabs, "div.tabs", function(target, index) { index+1 == event.key && target.click() })
}
can._key_list = can.onkeymap._parse(event, can, mdb.PLUGIN, can._key_list, can.ui.content)
})
},
_session: function(can, msg, cb) {
can.onimport.sess(can, "", function() { can.onimport.sess(can, {
exts: can.core.Split(msg.SearchOrOption("exts")).reverse(),
plug: can.core.Split(msg.SearchOrOption("plug")).reverse(),
tabs: can.core.Split(msg.SearchOrOption("tabs")),
}, cb) })
},
_tabs: function(can) {
can.ui._tabs = can.page.insertBefore(can, ["tabs"], can.ui._content), can.ui._path = can.page.insertBefore(can, ["path"], can.ui._content)
can.page.Append(can, can.ui._tabs, [{view: [["time", "select"]], style: {"float": html.RIGHT}, _init: function(target) {
@ -7,7 +93,13 @@ Volcanos(chat.ONIMPORT, {
target.onmouseenter = target.click
}}])
},
_tabInputs: function(can, ps, key, value, cb) {
can.core.List(can.core.Split(value, ps), function(value, index, array) {
can.page.Append(can, can.ui._path, [{text: [value, html.SPAN, html.ITEM], onclick: function(event) {
can.onimport.tabInputs(event, can, ps, key, array.slice(0, index).join(ps)+ps, cb)
}}, index < array.length-1? {text: ps}: null])
})
},
tabInputs: function(event, can, ps, key, pre, cb, parent) {
var core = ["usr/icebergs/core/", "usr/volcanos/plugin/local/"]
can.runAction(event, mdb.INPUTS, [key, pre], function(msg) { var _trans = {}
@ -22,19 +114,6 @@ Volcanos(chat.ONIMPORT, {
function remove(p) { if (p && p._sub) { remove(p._sub), can.page.Remove(can, p._sub), delete(p._sub) } } if (parent) { remove(parent), parent._sub = carte }
})
},
_tabInputs: function(can, ps, key, value, cb) {
can.core.List(can.core.Split(value, ps), function(value, index, array) {
can.page.Append(can, can.ui._path, [{text: [value, html.SPAN, html.ITEM], onclick: function(event) {
can.onimport.tabInputs(event, can, ps, key, array.slice(0, index).join(ps)+ps, cb)
}}, index < array.length-1? {text: ps}: null])
})
},
project: function(can, path) {
can.onimport.zone(can, can.core.Item(can.onfigure, function(name, cb) {
if (can.base.isFunc(cb)) { return {name: name, _init: function(target, zone) { return cb(can, target, zone, path) }} }
}), can.ui.project), can.user.isMobile && !can.user.isLandscape() && can.onmotion.hidden(can, can.ui.project)
},
tabview: function(can, path, file, line, cb) { var key = can.onexport.keys(can, path, file)
function isCommand() { return path == ctx.COMMAND || line == ctx.INDEX || line == code.XTERM }
function isDream() { return line == web.DREAM }
@ -94,6 +173,129 @@ Volcanos(chat.ONIMPORT, {
can.base.Eq(record, can.history[can.history.length-1]) || can.history.push(record)
return can.Status("跳转数", can.history.length), record
},
project: function(can, path) {
can.onimport.zone(can, can.core.Item(can.onfigure, function(name, cb) {
if (can.base.isFunc(cb)) { return {name: name, _init: function(target, zone) { return cb(can, target, zone, path) }} }
}), can.ui.project), can.user.isMobile && !can.user.isLandscape() && can.onmotion.hidden(can, can.ui.project)
},
profile: function(can, msg) { var sup = can.tabview[can.onexport.keys(can)]
if (msg.Result().indexOf("<iframe") > -1) { if (sup._profile_output != can.ui._profile_output) { can.page.Remove(can, sup._profile_output) }
can.ui.profile_output = sup._profile_output = can.page.Append(can, can.ui._profile_output.parentNode, [{view: html.OUTPUT, inner: msg.Result()}]).output
var width = can.profile_size[can.onexport.keys(can)]||(can.ConfWidth()-can.ui.project.offsetWidth)/4*3; can.profile_size[can.onexport.keys(can)] = width
} else {
can.ui.profile_output = sup._profile_output = can.ui._profile_output
var width = can.profile_size[can.onexport.keys(can)]||(can.ConfWidth()-can.ui.project.offsetWidth)/2
can.onimport.process(can, msg, can.ui._profile_output, can.ui.profile.offsetHeight, width)
can.onappend._status(can, msg.Option(ice.MSG_STATUS), can.page.Append(can, can.ui._profile_output, [html.STATUS])._target)
can.page.Select(can, can.ui._profile_output, html.TABLE, function(target) { can.onmotion.delay(can, function() {
if (target.offsetWidth < can.ui._profile_output.offsetWidth) { can.profile_size[can.onexport.keys(can)] = target.offsetWidth, can.onimport.layout(can) }
}) })
}
can.onmotion.toggle(can, can.ui.profile_output, true)
can.onmotion.toggle(can, can.ui.profile, true), can.onimport.layout(can)
},
display: function(can, msg) { var target = can.ui.display
var height = can.display_size[can.onexport.keys(can)]||can.ConfHeight()/2
can.onimport.process(can, msg, can.ui.display, height, can.ui.display.offsetWidth, function(sub) {
can.page.style(can, sub._output, html.HEIGHT, "", html.MAX_HEIGHT, ""), can.onmotion.delay(can, function() {
can.display_size[can.onexport.keys(can)] = can.base.Max(sub._output.offsetHeight, can.ConfHeight()/2)+html.ACTION_HEIGHT+sub.onexport.statusHeight(sub)
can.page.style(can, sub._output, html.MAX_HEIGHT, can.display_size[can.onexport.keys(can)]-html.ACTION_HEIGHT-sub.onexport.statusHeight(sub))
can.onimport.layout(can)
}), sub.onaction.close = function() { can.onmotion.hidden(can, can.ui.display), can.onimport.layout(can) }
})
can.onmotion.toggle(can, can.ui.display, true), can.onimport.layout(can)
if (msg.Option(ice.MSG_PROCESS) != "_field") {
can.onmotion.delay(can, function() { can.page.style(can, target, html.HEIGHT, "", html.MAX_HEIGHT, "")
can.display_size[can.onexport.keys(can)] = can.base.Max(target.offsetHeight, can.ConfHeight()/2)
can.page.style(can, target, html.MAX_HEIGHT, can.display_size[can.onexport.keys(can)])
can.onimport.layout(can)
})
}
},
process: function(can, msg, target, height, width, cb) { can.onmotion.clear(can, target), can.user.toastSuccess(can)
if (msg.Option(ice.MSG_PROCESS) == "_field") {
msg.Table(function(item) { item.display = msg.Option(ice.MSG_DISPLAY), item.height = height-3*html.ACTION_HEIGHT
can.onimport.plug(can, item, function(sub) {
sub.onaction._output = function(_sub, _msg) { can.base.isFunc(cb) && cb(_sub, _msg) }
sub.onaction.close = function() { can.onmotion.hidden(can, target.parentNode), can.onimport.layout(can) }
height && sub.ConfHeight(height-3*html.ACTION_HEIGHT), width && sub.ConfWidth(width), sub.Focus()
}, target)
})
} else if (msg.Option(ice.MSG_DISPLAY) != "") {
can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY), target, false, function(msg) { can.onmotion.delay(can, function() { can.onimport.layout(can) }) })
} else if (msg.Length() > 0 || msg.Result() != "") {
can.onappend.table(can, msg, function(value, key, index, line, array) {
return {text: [value, html.TD], onclick: function(event) { if (line.line || line.file) {
can.onimport.tabview(can, line.path||can.Option(nfs.PATH), line.file||can.Option(nfs.FILE), line.line||can.Option(nfs.LINE), function() {
can.current.scroll(can.current.scroll()-9)
})
} }}
}, target), can.onappend.board(can, msg, target)
can.onappend._status(can, msg.Option(ice.MSG_STATUS), can.page.Append(can, target, ["status"])._target)
} else {
can.onmotion.hidden(can, target.parentNode)
}
},
toolkit: function(can, meta, cb) { meta.msg = true
can.onimport.plug(can, meta, function(sub) {
sub.onexport.record = function(sub, line) { if (!line.file && !line.line) { return }
can.onimport.tabview(can, line.path||can.Option(nfs.PATH), can.base.trimPrefix(line.file, nfs.PWD)||can.Option(nfs.FILE), parseInt(line.line)), can.current.scroll(can.current.scroll()-4)
}
sub.onimport.size(sub, can.ConfHeight()/2, can.ConfWidth() - can.ui.profile.offsetWidth, true)
can._status.appendChild(sub._legend), sub._legend.onclick = function(event) {
if (can.page.Select(can, can._status, ice.PT+html.SELECT)[0] == event.target) {
can.page.ClassList.del(can, event.target, html.SELECT)
can.page.ClassList.del(can, sub._target, html.SELECT)
return
}
can.onmotion.select(can, can.ui.toolkit.output, html.FIELDSET, sub._target), sub.Focus()
can.onmotion.select(can, can._status, html.LEGEND, event.target)
if (meta.msg == true) { meta.msg = false, sub.Update() }
}, sub._legend.onmouseenter = null
sub.onaction.close = sub.select = function() { return sub._legend.click(), sub }
can.base.isFunc(cb) && cb(sub)
}, can.ui.toolkit.output)
},
layout: function(can) {
if (can.isSimpleMode()) { return can.page.style(can, can.ui.content, html.WIDTH, can.ConfWidth()) }
if (can.isCmdMode()) { can.ConfHeight(can.page.height()), can.ConfWidth(can.page.width()) }
can.isFloatMode() && can.onmotion.hidden(can, can.ui.profile)
var width = can.ConfWidth()+(can.user.isMobile && can.isCmdMode() && can.user.isLandscape()? 16: 0)-(can.user.isWindows && !can.isCmdMode()? 20: 0)
var project_width = can.ui.project.style.display == html.NONE? 0: (can.ui.project.offsetWidth||240)
var profile_width = can.ui.profile.style.display == html.NONE? 0: can.profile_size[can.onexport.keys(can)]||(width-project_width)/2
var content_width = width-project_width-profile_width
can.page.styleWidth(can, can.ui.content, content_width)
can.page.styleWidth(can, can.ui.profile_output, profile_width)
can.page.styleWidth(can, can.ui.display, width-project_width)
var height = can.user.isMobile && can.isFloatMode()? can.page.height()-2*html.ACTION_HEIGHT: can.base.Min(can.ConfHeight(), 320)-1
can.user.isMobile && can.isCmdMode() && can.page.style(can, can._output, html.MAX_HEIGHT, height)
var display_height = can.ui.display.style.display == html.NONE? 0: (can.display_size[can.onexport.keys(can)]||html.ACTION_HEIGHT)
var content_height = height-display_height; if (can.isCmdMode()) { content_height -= can.ui._tabs.offsetHeight + can.ui._path.offsetHeight + 4 }
var profile_height = height-html.ACTION_HEIGHT-display_height
can.page.styleHeight(can, can.ui.profile_output, profile_height)
can.page.styleHeight(can, can.ui.display, display_height)
can.page.styleHeight(can, can.ui.content, content_height-(can.ui.content != can.ui._content? 4: 0))
can.page.styleHeight(can, can.ui.project, height)
var sub = can.ui.content._plugin; sub && sub.onimport.size(sub, content_height-2*html.ACTION_HEIGHT, content_width, true)
can.page.Select(can, can.ui.profile, html.IFRAME, function(iframe) { can.page.Modify(can, iframe, {height: profile_height-html.ACTION_HEIGHT-4, width: profile_width}) })
},
exts: function(can, url, cb) {
can.require([url], function() {}, function(can, name, sub) { sub._init(can, sub, function(sub) {
can.extentions[url.split("?")[0]] = sub, can.base.isFunc(cb)? cb(sub): sub.select()
}) })
},
sess: function(can, sess, cb) { sess = sess||can.base.Obj(can.misc.localStorage(can, "web.code.inner.sess"), {})
can.core.Next(sess.plug, function(item, next) { can.onimport.toolkit(can, {index: item}, function(sub) { can.toolkit[item] = sub, next() }) }, function() {
can.core.Next(sess.exts, function(item, next) { can.onimport.exts(can, item, next) }, function() {
var path = can.Option(nfs.PATH), file = can.Option(nfs.FILE), line = can.Option(nfs.LINE)
can.base.getValid(sess.tabs)? can.core.Next(sess.tabs, function(item, next) { var ls = item.split(ice.DF); can.onimport.tabview(can, ls[0], ls[1], ls[2], next) },
function() { can.onimport.tabview(can, path, file, line, cb) }): can.base.isFunc(cb) && cb()
})
})
},
}, [""])
Volcanos(chat.ONFIGURE, {
source: function(can, target, zone, path) { var total = 0
@ -186,10 +388,7 @@ Volcanos(chat.ONSYNTAX, {_init: function(can, msg, cb) {
return line
},
})
Volcanos(chat.ONENGINE, {
listen: shy("监听事件", function(can, key, cb) { arguments.callee.meta[key] = (arguments.callee.meta[key]||[]).concat(cb) }),
})
Volcanos(chat.ONACTION, {
Volcanos(chat.ONACTION, {_trans: {link: "链接", width: "宽度", height: "高度"},
appendLine: function(can, value) {
var ui = can.page.Append(can, can.ui._content, [{type: html.TR, list: [
{view: ["line unselectable", html.TD, ++can.max], onclick: function(event) {
@ -241,283 +440,6 @@ Volcanos(chat.ONACTION, {
], function() { can.user.toastSuccess(can) })
})
},
back: function(can) { can.history.pop(); var last = can.history.pop(); last && can.onimport.tabview(can, last.path, last.file, last.line) },
})
Volcanos(chat.ONEXPORT, {list: ["文件数", "解析器", "文件名", "当前行", "跳转数"],
hash: function(can) { if (!can.isCmdMode()) { return }
var list = []; if (can.Option(nfs.PATH) != can.misc.Search(can, nfs.PATH)) { list.push(can.Option(nfs.PATH)) }
if (list.length > 0 || can.Option(nfs.FILE) != can.misc.Search(can, nfs.FILE)) { list.push(can.Option(nfs.FILE)) }
if (list.length > 0 || can.Option(nfs.LINE) != can.misc.Search(can, nfs.LINE)) { list.push(can.Option(nfs.LINE)) }
location.hash = list.join(ice.FS)
},
keys: function(can, path, file) { return [path||can.Option(nfs.PATH), file||can.Option(nfs.FILE)].join(ice.FS) },
content: function(can) { return can.page.Select(can, can.ui.content, "td.text", function(item) { return item.innerText }).join(ice.NL) },
position: function(can, index, total) { total = total||can.max; return (parseInt(index))+ice.PS+parseInt(total)+" = "+parseInt((index)*100/total)+"%" },
text: function(can, line) { return can.core.Value(can.page.Select(can, line, "td.text")[0], "innerText") },
line: function(can, line) { return parseInt(can.core.Value(can.page.Select(can, line, "td.line")[0], "innerText")) },
})
Volcanos(chat.ONIMPORT, {
_profile: function(can, target) {
var ui = can.onimport._panel(can, target, kit.Dict(
mdb.LINK, function(event) {
if ([nfs.ZML, nfs.IML].indexOf(can.base.Ext(can.Option(nfs.FILE))) > -1) {
can.user.open(can.misc.MergePodCmd(can, {website: can.base.trimPrefix(can.base.Path(can.Option(nfs.PATH), can.Option(nfs.FILE)), "src/website/")}))
} else {
can.user.open(can.misc.MergePodCmd(can, {cmd: can.base.Path(can.Option(nfs.PATH), can.Option(nfs.FILE))}))
}
},
html.WIDTH, function(event) {
can.user.input(event, can, [{name: html.WIDTH, value: can.profile_size[can.onexport.keys(can)]*100/can.ConfWidth()||50}], function(list) {
can.profile_size[can.onexport.keys(can)] = can.ConfWidth()*parseInt(list[0])/100, can.onaction[ice.SHOW](event, can)
})
},
)); can.ui.profile_output = ui.output
},
_display: function(can, target) {
},
profile: function(can, msg) { var sup = can.tabview[can.onexport.keys(can)]
if (msg.Result().indexOf("<iframe") > -1) { if (sup._profile_output != can.ui._profile_output) { can.page.Remove(can, sup._profile_output) }
can.ui.profile_output = sup._profile_output = can.page.Append(can, can.ui._profile_output.parentNode, [{view: html.OUTPUT, inner: msg.Result()}]).output
var width = can.profile_size[can.onexport.keys(can)]||(can.ConfWidth()-can.ui.project.offsetWidth)/4*3; can.profile_size[can.onexport.keys(can)] = width
} else {
can.ui.profile_output = sup._profile_output = can.ui._profile_output
var width = can.profile_size[can.onexport.keys(can)]||(can.ConfWidth()-can.ui.project.offsetWidth)/2
can.onimport.process(can, msg, can.ui._profile_output, can.ui.profile.offsetHeight, width)
can.onappend._status(can, msg.Option(ice.MSG_STATUS), can.page.Append(can, can.ui._profile_output, [html.STATUS])._target)
can.page.Select(can, can.ui._profile_output, html.TABLE, function(target) { can.onmotion.delay(can, function() {
if (target.offsetWidth < can.ui._profile_output.offsetWidth) { can.profile_size[can.onexport.keys(can)] = target.offsetWidth, can.onimport.layout(can) }
}) })
}
can.onmotion.toggle(can, can.ui.profile_output, true)
can.onmotion.toggle(can, can.ui.profile, true), can.onimport.layout(can)
},
display: function(can, msg) { var target = can.ui.display
var height = can.display_size[can.onexport.keys(can)]||can.ConfHeight()/2
can.onimport.process(can, msg, can.ui.display, height, can.ui.display.offsetWidth, function(sub) {
can.page.style(can, sub._output, html.HEIGHT, "", html.MAX_HEIGHT, ""), can.onmotion.delay(can, function() {
can.display_size[can.onexport.keys(can)] = can.base.Max(sub._output.offsetHeight, can.ConfHeight()/2)+html.ACTION_HEIGHT+sub.onexport.statusHeight(sub)
can.page.style(can, sub._output, html.MAX_HEIGHT, can.display_size[can.onexport.keys(can)]-html.ACTION_HEIGHT-sub.onexport.statusHeight(sub))
can.onimport.layout(can)
}), sub.onaction.close = function() { can.onmotion.hidden(can, can.ui.display), can.onimport.layout(can) }
})
can.onmotion.toggle(can, can.ui.display, true), can.onimport.layout(can)
if (msg.Option(ice.MSG_PROCESS) != "_field") {
can.onmotion.delay(can, function() { can.page.style(can, target, html.HEIGHT, "", html.MAX_HEIGHT, "")
can.display_size[can.onexport.keys(can)] = can.base.Max(target.offsetHeight, can.ConfHeight()/2)
can.page.style(can, target, html.MAX_HEIGHT, can.display_size[can.onexport.keys(can)])
can.onimport.layout(can)
})
}
},
process: function(can, msg, target, height, width, cb) { can.onmotion.clear(can, target), can.user.toastSuccess(can)
if (msg.Option(ice.MSG_PROCESS) == "_field") {
msg.Table(function(item) { item.display = msg.Option(ice.MSG_DISPLAY), item.height = height-3*html.ACTION_HEIGHT
can.onimport.plug(can, item, function(sub) {
sub.onaction._output = function(_sub, _msg) { can.base.isFunc(cb) && cb(_sub, _msg) }
sub.onaction.close = function() { can.onmotion.hidden(can, target.parentNode), can.onimport.layout(can) }
height && sub.ConfHeight(height-3*html.ACTION_HEIGHT), width && sub.ConfWidth(width), sub.Focus()
}, target)
})
} else if (msg.Option(ice.MSG_DISPLAY) != "") {
can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY), target, false, function(msg) { can.onmotion.delay(can, function() { can.onimport.layout(can) }) })
} else if (msg.Length() > 0 || msg.Result() != "") {
can.onappend.table(can, msg, function(value, key, index, line, array) {
return {text: [value, html.TD], onclick: function(event) { if (line.line || line.file) {
can.onimport.tabview(can, line.path||can.Option(nfs.PATH), line.file||can.Option(nfs.FILE), line.line||can.Option(nfs.LINE), function() {
can.current.scroll(can.current.scroll()-9)
})
} }}
}, target), can.onappend.board(can, msg, target)
can.onappend._status(can, msg.Option(ice.MSG_STATUS), can.page.Append(can, target, ["status"])._target)
} else {
can.onmotion.hidden(can, target.parentNode)
}
},
}, [""])
Volcanos(chat.ONACTION, {_trans: {link: "链接", width: "宽度", height: "高度"},
"搜索": function(event, can) {
can.user.input(event, can, [mdb.NAME, [ctx.ACTION, nfs.TAGS, cli.MAKE, nfs.GREP]], function(data) {
can.ui.search.Update({}, [ctx.ACTION, data.action, data.name])
})
},
"打开": function(event, can) {
can.page.style(can, can.user.input(can.request(event, {paths: can.sup.paths.join(ice.FS)}), can, [{name: nfs.FILE, style: {width: can.ui.content.offsetWidth/2}}], function(list) {
var ls = can.core.Split(list[0], ice.DF, ice.DF); switch (ls[0]) {
case "_open": return can.runAction(event, "_open", ls[1])
case ctx.INDEX:
case web.DREAM: return can.onimport.tabview(can, can.Option(nfs.PATH), ls[1], ls[0])
case nfs.LINE: return can.onaction.selectLine(can, parseInt(ls[1])), can.current.scroll(can.current.scroll()-4)
default: can.core.List(can.sup.paths, function(path) { if (list[0].indexOf(path) == 0) { can.onimport.tabview(can, path, list[0].slice(path.length)) } })
}
})._target, html.LEFT, can.ui.project.offsetWidth+can.ui.content.offsetWidth/4-34, html.TOP, can.ui.content.offsetHeight/4, html.RIGHT, "")
},
show: function(event, can) {
if (can.base.Ext(can.Option(nfs.FILE)) == nfs.JS) { delete(Volcanos.meta.cache[can.base.Path("/require/", can.Option(nfs.PATH), can.Option(nfs.FILE))]) }
can.runAction(can.request(event, {_toast: "渲染中..."}), mdb.RENDER, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) { can.onimport.profile(can, msg) })
},
exec: function(event, can) {
can.runAction(can.request(event, {_toast: "执行中..."}), mdb.ENGINE, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) { can.onimport.display(can, msg) })
},
clear: function(event, can) {
if (can.page.Select(can, can._root._target, ".input.float", function(item) { return can.page.Remove(can, item) }).length > 0) { return }
if (can.page.Select(can, can._status, "legend.select", function(item) { return item.click(), item }).length > 0) { return }
if (can.ui.display.style.display == "") { return can.onmotion.hidden(can, can.ui.display), can.onimport.layout(can) }
if (can.ui.profile.style.display == "") { return can.onmotion.hidden(can, can.ui.profile), can.onimport.layout(can) }
if (can.page.Select(can, can._root._target, "div.vimer.find.float", function(item) { return can.page.Remove(can, item) }).length > 0) { return }
can.onmotion.toggle(can, can.ui.project), can.onimport.layout(can)
},
})
Volcanos(chat.ONIMPORT, {
_keydown: function(can) { if (!can.isCmdMode()) { return }
can.onkeymap._build(can), can._root.onengine.listen(can, chat.ONKEYDOWN, function(event) {
if (event.ctrlKey && event.key >= "0" && event.key <= "9") {
return can.page.Select(can, can.ui._tabs, "div.tabs", function(target, index) { index+1 == event.key && target.click() })
}
can._key_list = can.onkeymap._parse(event, can, mdb.PLUGIN, can._key_list, can.ui.content)
})
},
})
Volcanos(chat.ONKEYMAP, {
_mode: {
plugin: {
Escape: shy("切换模式", function(event, can) { can.onaction.clear(event, can) }),
v: shy("渲染界面", function(event, can) { can.onaction[ice.SHOW](event, can) }),
r: shy("执行命令", function(event, can) { can.onaction[ice.EXEC](event, can) }),
f: shy("打开文件", function(event, can) { can.onaction["打开"](event, can) }),
x: shy("关闭标签", function(can) { can._tab._close() }),
h: shy("打开左边标签", function(can) { var next = can._tab.previousSibling; next && next.click() }),
l: shy("打开右边标签", function(can) { var next = can._tab.nextSibling; next && next.click() }),
},
}, _engine: {},
})
Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) {
can.onmotion.clear(can), can.page.ClassList.add(can, can._fields, code.INNER), can.onlayout.profile(can)
can.onimport._profile(can, can.ui.profile), can.onimport._display(can, can.ui.display)
if (msg.Result() == "" && can.Option(nfs.LINE) == "1") { return }
can.page.styleWidth(can, can.ui.project, 240)
can.isCmdMode() && can.ConfHeight(can.ConfHeight()+2*html.ACTION_HEIGHT)
if (msg.Option(nfs.FILE)) {
msg.Option(nfs.PATH) && can.Option(nfs.PATH, msg.Option(nfs.PATH))
can.Option(nfs.FILE, msg.Option(nfs.FILE))
msg.Option(nfs.LINE) && can.Option(nfs.LINE, msg.Option(nfs.LINE))
}
can.onengine.plugin(can, can.onplugin)
var paths = can.core.Split(can.Option(nfs.PATH), ice.FS); can.Option(nfs.PATH, paths[0])
var files = can.core.Split(can.Option(nfs.FILE), ice.FS); can.Option(nfs.FILE, files[0])
can.core.List(paths.concat(msg.modules||[], can.sup.paths||[], can.core.Split(msg.Option("repos"))), function(p) { if (paths.indexOf(p) == -1 && p[0] != ice.PS) { paths.push(p) } })
can.sup.paths = paths
can.ui._content = can.ui.content, can.ui._profile_output = can.ui.profile_output
can.tabview = can.tabview||{}, can.history = can.history||[], can.toolkit = {}, can.extentions = {}
can.profile_size = {}, can.display_size = {}
if (can.user.isWebview) { var last = can.misc.localStorage(can, "web.code.inner:currentFile"); if (last) { var ls = can.core.Split(last, ice.DF) } }
switch (can.Mode()) {
case chat.SIMPLE: can.onmotion.hidden(can, can.ui.project); break
case chat.FLOAT: can.onmotion.hidden(can, can.ui.project); break
case chat.CMD: can.onimport._tabs(can), can.onmotion.hidden(can, can._status) // no break
case chat.FULL: // no break
default: can.onimport.project(can, paths)
can.onengine.listen(can, "tabview.view.init", function() { if (can.user.isMobile) { return } var p = can.onsyntax[can.parse]
can.Option(nfs.PATH).indexOf("src/") == 0 && p && p.render && can.onaction[ice.SHOW]({}, can); if (can.page.ClassList.has(can, can._fields, chat.PLUGIN)) {
p && p.engine && can.onaction[ice.EXEC]({}, can)
}
})
can.onimport._keydown(can), can.onimport._toolkit(can, can.ui.toolkit), can.onimport._session(can, msg, function() {
files.length > 1 && can.onmotion.delay(can, function() { can.core.Next(files.slice(1), function(file, next) {
can.onimport.tabview(can, can.Option(nfs.PATH), file, can.Option(nfs.LINE), next)
}, function() { can.onimport.tabview(can, paths[0], files[0], "") }) })
last && ls.length > 0 && can.onmotion.delay(can, function() { can.onimport.tabview(can, ls[0], ls[1], ls[2]) }, 500)
})
}
var hash = location.hash; can.tabview[can.onexport.keys(can)] = msg
can.onimport.tabview(can, can.Option(nfs.PATH), can.Option(nfs.FILE), can.Option(nfs.LINE), function() {
if (can.isCmdMode() && hash) { var args = can.core.Split(decodeURIComponent(hash).slice(1))
can.onmotion.delay(can, function() { can.onimport.tabview(can, args[args.length-3]||can.Option(nfs.PATH), args[args.length-2]||can.Option(nfs.FILE), args[args.length-1]) }, 500)
}
}), can.base.isFunc(cb) && cb(msg)
},
_toolkit: function(can, target) {
can.ui.toolkit = can.onappend.field(can, "toolkit", {}, can._output)
},
_session: function(can, msg, cb) {
can.onimport.sess(can, "", function() { can.onimport.sess(can, {
exts: can.core.Split(msg.SearchOrOption("exts")).reverse(),
plug: can.core.Split(msg.SearchOrOption("plug")).reverse(),
tabs: can.core.Split(msg.SearchOrOption("tabs")),
}, cb) })
},
layout: function(can) {
if (can.isSimpleMode()) { return can.page.style(can, can.ui.content, html.WIDTH, can.ConfWidth()) }
if (can.isCmdMode()) { can.ConfHeight(can.page.height()), can.ConfWidth(can.page.width()) }
can.isFloatMode() && can.onmotion.hidden(can, can.ui.profile)
var width = can.ConfWidth()+(can.user.isMobile && can.isCmdMode() && can.user.isLandscape()? 16: 0)-(can.user.isWindows && !can.isCmdMode()? 20: 0)
var project_width = can.ui.project.style.display == html.NONE? 0: (can.ui.project.offsetWidth||240)
var profile_width = can.ui.profile.style.display == html.NONE? 0: can.profile_size[can.onexport.keys(can)]||(width-project_width)/2
var content_width = width-project_width-profile_width
can.page.styleWidth(can, can.ui.content, content_width)
can.page.styleWidth(can, can.ui.profile_output, profile_width)
can.page.styleWidth(can, can.ui.display, width-project_width)
var height = can.user.isMobile && can.isFloatMode()? can.page.height()-2*html.ACTION_HEIGHT: can.base.Min(can.ConfHeight(), 320)-1
can.user.isMobile && can.isCmdMode() && can.page.style(can, can._output, html.MAX_HEIGHT, height)
var display_height = can.ui.display.style.display == html.NONE? 0: (can.display_size[can.onexport.keys(can)]||html.ACTION_HEIGHT)
var content_height = height-display_height; if (can.isCmdMode()) { content_height -= can.ui._tabs.offsetHeight + can.ui._path.offsetHeight + 4 }
var profile_height = height-html.ACTION_HEIGHT-display_height
can.page.styleHeight(can, can.ui.profile_output, profile_height)
can.page.styleHeight(can, can.ui.display, display_height)
can.page.styleHeight(can, can.ui.content, content_height-(can.ui.content != can.ui._content? 4: 0))
can.page.styleHeight(can, can.ui.project, height)
var sub = can.ui.content._plugin; sub && sub.onimport.size(sub, content_height-2*html.ACTION_HEIGHT, content_width, true)
can.page.Select(can, can.ui.profile, html.IFRAME, function(iframe) { can.page.Modify(can, iframe, {height: profile_height-html.ACTION_HEIGHT-4, width: profile_width}) })
},
toolkit: function(can, meta, cb) { meta.msg = true
can.onimport.plug(can, meta, function(sub) {
sub.onexport.record = function(sub, line) { if (!line.file && !line.line) { return }
can.onimport.tabview(can, line.path||can.Option(nfs.PATH), can.base.trimPrefix(line.file, nfs.PWD)||can.Option(nfs.FILE), parseInt(line.line)), can.current.scroll(can.current.scroll()-4)
}
sub.onimport.size(sub, can.ConfHeight()/2, can.ConfWidth() - can.ui.profile.offsetWidth, true)
can._status.appendChild(sub._legend), sub._legend.onclick = function(event) {
if (can.page.Select(can, can._status, ice.PT+html.SELECT)[0] == event.target) {
can.page.ClassList.del(can, event.target, html.SELECT)
can.page.ClassList.del(can, sub._target, html.SELECT)
return
}
can.onmotion.select(can, can.ui.toolkit.output, html.FIELDSET, sub._target), sub.Focus()
can.onmotion.select(can, can._status, html.LEGEND, event.target)
if (meta.msg == true) { meta.msg = false, sub.Update() }
}, sub._legend.onmouseenter = null
sub.onaction.close = sub.select = function() { return sub._legend.click(), sub }
can.base.isFunc(cb) && cb(sub)
}, can.ui.toolkit.output)
},
exts: function(can, url, cb) {
can.require([url], function() {}, function(can, name, sub) { sub._init(can, sub, function(sub) {
can.extentions[url.split("?")[0]] = sub, can.base.isFunc(cb)? cb(sub): sub.select()
}) })
},
sess: function(can, sess, cb) { sess = sess||can.base.Obj(can.misc.localStorage(can, "web.code.inner.sess"), {})
can.core.Next(sess.plug, function(item, next) { can.onimport.toolkit(can, {index: item}, function(sub) { can.toolkit[item] = sub, next() }) }, function() {
can.core.Next(sess.exts, function(item, next) { can.onimport.exts(can, item, next) }, function() {
var path = can.Option(nfs.PATH), file = can.Option(nfs.FILE), line = can.Option(nfs.LINE)
can.base.getValid(sess.tabs)? can.core.Next(sess.tabs, function(item, next) { var ls = item.split(ice.DF); can.onimport.tabview(can, ls[0], ls[1], ls[2], next) },
function() { can.onimport.tabview(can, path, file, line, cb) }): can.base.isFunc(cb) && cb()
})
})
},
}, [""])
Volcanos(chat.ONACTION, {list: [],
sess: function(event, can) { can.onexport.sess(can), can.user.toastSuccess(can) },
listTags: function(event, can, button) { var list = []
can.core.Item(can.request(event), function(key, value) { if (key.indexOf("_") == 0) { return }
list.push({zone: "msg", type: typeof value, name: key, text: can.base.isObject(value)? "": (value+"").split(ice.NL)[0],
@ -534,10 +456,71 @@ Volcanos(chat.ONACTION, {list: [],
})
can.runAction(can.request(event, {text: can.base.Format(list)}), button)
},
sess: function(event, can) { can.onexport.sess(can), can.user.toastSuccess(can) },
back: function(can) { can.history.pop(); var last = can.history.pop(); last && can.onimport.tabview(can, last.path, last.file, last.line) },
show: function(event, can) {
if (can.base.Ext(can.Option(nfs.FILE)) == nfs.JS) { delete(Volcanos.meta.cache[can.base.Path("/require/", can.Option(nfs.PATH), can.Option(nfs.FILE))]) }
can.runAction(can.request(event, {_toast: "渲染中..."}), mdb.RENDER, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) { can.onimport.profile(can, msg) })
},
exec: function(event, can) {
can.runAction(can.request(event, {_toast: "执行中..."}), mdb.ENGINE, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) { can.onimport.display(can, msg) })
},
clear: function(event, can) {
if (can.page.Select(can, can._root._target, ".input.float", function(item) { return can.page.Remove(can, item) }).length > 0) { return }
if (can.page.Select(can, can._status, "legend.select", function(item) { return item.click(), item }).length > 0) { return }
if (can.ui.display.style.display == "") { return can.onmotion.hidden(can, can.ui.display), can.onimport.layout(can) }
if (can.ui.profile.style.display == "") { return can.onmotion.hidden(can, can.ui.profile), can.onimport.layout(can) }
if (can.page.Select(can, can._root._target, "div.vimer.find.float", function(item) { return can.page.Remove(can, item) }).length > 0) { return }
can.onmotion.toggle(can, can.ui.project), can.onimport.layout(can)
},
"搜索": function(event, can) {
can.user.input(event, can, [mdb.NAME, [ctx.ACTION, nfs.TAGS, cli.MAKE, nfs.GREP]], function(data) {
can.ui.search.Update({}, [ctx.ACTION, data.action, data.name])
})
},
"打开": function(event, can) {
can.page.style(can, can.user.input(can.request(event, {paths: can.sup.paths.join(ice.FS)}), can, [{name: nfs.FILE, style: {width: can.ui.content.offsetWidth/2}}], function(list) {
var ls = can.core.Split(list[0], ice.DF, ice.DF); switch (ls[0]) {
case "_open": return can.runAction(event, "_open", ls[1])
case ctx.INDEX:
case web.DREAM: return can.onimport.tabview(can, can.Option(nfs.PATH), ls[1], ls[0])
case nfs.LINE: return can.onaction.selectLine(can, parseInt(ls[1])), can.current.scroll(can.current.scroll()-4)
default: can.core.List(can.sup.paths, function(path) { if (list[0].indexOf(path) == 0) { can.onimport.tabview(can, path, list[0].slice(path.length)) } })
}
})._target, html.LEFT, can.ui.project.offsetWidth+can.ui.content.offsetWidth/4-34, html.TOP, can.ui.content.offsetHeight/4, html.RIGHT, "")
},
})
Volcanos(chat.ONEXPORT, {
Volcanos(chat.ONEXPORT, {list: ["文件数", "解析器", "文件名", "当前行", "跳转数"],
hash: function(can) { if (!can.isCmdMode()) { return }
var list = []; if (can.Option(nfs.PATH) != can.misc.Search(can, nfs.PATH)) { list.push(can.Option(nfs.PATH)) }
if (list.length > 0 || can.Option(nfs.FILE) != can.misc.Search(can, nfs.FILE)) { list.push(can.Option(nfs.FILE)) }
if (list.length > 0 || can.Option(nfs.LINE) != can.misc.Search(can, nfs.LINE)) { list.push(can.Option(nfs.LINE)) }
location.hash = list.join(ice.FS)
},
keys: function(can, path, file) { return [path||can.Option(nfs.PATH), file||can.Option(nfs.FILE)].join(ice.FS) },
content: function(can) { return can.page.Select(can, can.ui.content, "td.text", function(item) { return item.innerText }).join(ice.NL) },
position: function(can, index, total) { total = total||can.max; return (parseInt(index))+ice.PS+parseInt(total)+" = "+parseInt((index)*100/total)+"%" },
text: function(can, line) { return can.core.Value(can.page.Select(can, line, "td.text")[0], "innerText") },
line: function(can, line) { return parseInt(can.core.Value(can.page.Select(can, line, "td.line")[0], "innerText")) },
sess: function(can) { can.misc.localStorage(can, "web.code.inner.sess", {"plug": can.onexport.plug(can), "exts": can.onexport.exts(can), "tabs": can.onexport.tabs(can)}) },
tabs: function(can) { return can.core.Item(can.tabview, function(key, msg) { return key+ice.DF+can.Option(nfs.LINE) }) },
plug: function(can) { return can.core.Item(can.toolkit) },
exts: function(can) { return can.core.Item(can.plugins) },
})
Volcanos(chat.ONENGINE, {
listen: shy("监听事件", function(can, key, cb) { arguments.callee.meta[key] = (arguments.callee.meta[key]||[]).concat(cb) }),
})
Volcanos(chat.ONKEYMAP, {
_mode: {
plugin: {
Escape: shy("切换模式", function(event, can) { can.onaction.clear(event, can) }),
v: shy("渲染界面", function(event, can) { can.onaction[ice.SHOW](event, can) }),
r: shy("执行命令", function(event, can) { can.onaction[ice.EXEC](event, can) }),
f: shy("打开文件", function(event, can) { can.onaction["打开"](event, can) }),
x: shy("关闭标签", function(can) { can._tab._close() }),
h: shy("打开左边标签", function(can) { var next = can._tab.previousSibling; next && next.click() }),
l: shy("打开右边标签", function(can) { var next = can._tab.nextSibling; next && next.click() }),
},
}, _engine: {},
})

View File

@ -28,7 +28,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) {
Volcanos(chat.ONFIGURE, {
create: function(can, target, zone, path) {
can.isCmdMode()? can.onappend._action(can, can.base.Obj(can._msg.Option(ice.MSG_ACTION)).concat(
["favor", "git", "首页", "官网" , "文档" , "百度"], window.webview? ["浏览器", "录屏", "日志", "编辑器"]: [],
["favor", "git", "首页", "官网" , "文档" , "百度"], window.webview? ["录屏", "日志", "编辑器", "浏览器"]: [],
), target): can.onmotion.hidden(can, target.parentNode)
},
recent: function(can, target, zone, path) { var total = 0
@ -116,6 +116,271 @@ Volcanos(chat.ONFIGURE, {
})
},
})
Volcanos(chat.ONACTION, {
_daemon: function(event, can, arg) {
switch (arg[0]) {
case web.DREAM:
can.runAction({}, arg[0], arg.slice(1), function(msg) {
can.onimport.tabview(can, can.Option(nfs.PATH), can.core.Keys(can.misc.Search(can, ice.POD), msg.Option(mdb.NAME)), web.DREAM)
})
break
case code.XTERM:
can.runAction({}, arg[0], arg.slice(1), function(msg) {
can.onimport.tabview(can, ctx.COMMAND, code.XTERM, msg.Result())
})
break
default:
can.runAction({}, arg[0], arg.slice(1), function(msg) {
can.onimport.tabview(can, msg.Option(nfs.PATH)||can.Option(nfs.PATH), msg.Option(nfs.FILE)), can.ui.source.refresh()
})
}
},
_run: function(event, can, button, args, cb) {
can.runAction(event, button, args, cb||function(msg) {
can.onimport.tabview(can, msg.Option(nfs.PATH)||can.Option(nfs.PATH), msg.Option(nfs.FILE))
can.ui.source.refresh(), can.user.toastSuccess(can, button)
})
},
_runs: function(event, can, button, cb) { var meta = can.Conf(); can.request(event, {action: button})
can.user.input(event, can, meta.feature[button], function(args) { can.onaction._run(event, can, button, args, cb) })
},
autogen: function(event, can, button) { can.onaction._runs(can.request(event, {path: "src/"}), can, button, function(msg) {
can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(cli.MAIN), "", function() {
can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(nfs.FILE), "", function() {
can.ui.source.refresh(), can.user.toastSuccess(can)
})
}, true)
}) },
script: function(event, can, button) {
can.onaction._runs(can.request(event, {path: "src/", file: can.base.trimSuffix(can.Option(nfs.FILE), can.base.Ext(can.Option(nfs.FILE)))+nfs.JS}), can, button)
},
dream: function(event, can, button) {
can.onaction._runs(can.request(event, {name: can.base.trimSuffix(can.Option(nfs.FILE).split(ice.PS).pop(), ice.PT+can.base.Ext(can.Option(nfs.FILE)))}), can, button, function(msg) {
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Option(mdb.NAME), web.DREAM)
can.ui.dream.refresh(), can.user.toastSuccess(can)
})
},
website: function(event, can, button) {
can.onaction._runs(can.request(event, {path: "src/website/", file: (can.base.trimSuffix(can.Option(nfs.FILE), can.base.Ext(can.Option(nfs.FILE)))+nfs.ZML).split(ice.PS).pop()}), can, button)
},
save: function(event, can, button) { can.request(event, {file: can.Option(nfs.FILE), content: can.onexport.content(can)})
can.onaction._run(event, can, button, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function() { can.user.toastSuccess(can, button, can.Option(nfs.PATH)+can.Option(nfs.FILE)) })
},
compile: function(event, can, button) { var _toast = can.user.toastProcess(can, "编译中...")
can.runAction(can.request(event), button, [], function(msg) { _toast.close()
if (msg.Length() > 0 || msg.Result()) {
return can.onimport.exts(can, "inner/search.js", function() {
can.onmotion.delay(can, function() { can.ui.search._show(msg) }, 300)
})
} else {
can.ui.search && can.onmotion.hidden(can, can.ui.search._target)
}
var toast = can.user.toastProcess(can, "重启中...")
can.onmotion.delay(can, function() { toast.close(), can.user.toastSuccess(can) }, 3000)
})
},
favor: function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.favor", ctx.INDEX) },
git: function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.git.status", ctx.INDEX) },
"查找": function(event, can) {
var ui = can.page.Append(can, can._output, [{view: "vimer find float", list: [html.ACTION, html.OUTPUT],
style: {position: "absolute", left: can.ui.project.offsetWidth+can.ui.content.offsetWidth/2, top: can.base.Max(can.base.Min(can.current.line.offsetTop-can.ui.content.scrollTop, 100), can.ConfHeight()/2)+57+28}}])
can.onmotion.delay(can, function() { can.page.style(can, ui._target, html.LEFT, can.ui.project.offsetWidth+can.ui.content.offsetWidth/2-ui._target.offsetWidth/2) }, 10)
can.onmotion.move(can, ui._target)
var last = can.onaction._getLineno(can, can.current.line)
function find(begin, text) { if (parseInt(text) > 0) { return can.onaction.selectLine(can, parseInt(text)) && meta.close() }
for (begin; begin <= can.max; begin++) {
if (can.onexport.text(can, can.onaction._getLine(can, begin)).indexOf(text) > -1) {
return last = begin, can.onaction.selectLine(can, begin), can.current.scroll(can.current.scroll()-5)
}
} last = 0, can.user.toast(can, "已经到最后一行")
}
function complete(target, button) {
can.onappend.figure(can, {action: "key", mode: chat.SIMPLE, _enter: function(event) {
if (event.ctrlKey) { meta.grep() } else {
meta[button](), can.onmotion.delay(can, function() { target.focus() })
}
return true
}, run: function(event, cmds, cb) {
var msg = can.request(event); can.core.List(can.core.Split(can.current.text(), "\t \n{[(:=,)]}", {detail: true}), function(value) {
if (can.base.isObject(value)) { if (value.type == html.SPACE) { return }
value.type == lang.STRING && msg.Push(mdb.VALUE, value.left+value.text+value.right)
msg.Push(mdb.VALUE, value.text)
} else {
msg.Push(mdb.VALUE, value)
}
}), cb(msg)
}}, target)
}
var from, to
var meta = can.onappend._action(can, [
{type: html.TEXT, name: "from", style: {width: 200}, _init: function(target) { from = target, complete(target, "find"), can.onmotion.delay(can, function() { target.focus() }) }},
"find", "grep",
{type: html.TEXT, name: "to", _init: function(target) { to = target, complete(target, "replace") }},
"replace",
"close",
], ui.action, {
find: function() { find(last+1, from.value) },
grep: function() {
can.onimport.exts(can, "inner/search.js", function(sub) { meta.close()
sub.runAction(event, nfs.GREP, [from.value])
})
},
replace: function() {
var text = can.current.text(), line = can.onaction._getLineno(can, can.current.line)
can.undo.push(function() { can.onaction.selectLine(can, line), can.onaction.modifyLine(can, line, text) })
can.current.text(text.replace(from.value, to.value))
can.current.text().indexOf(from.value) == -1 && meta.find() },
close: function() { can.page.Remove(can, ui._target) },
})
},
"收藏": function(event, can) { can.onaction._open(can, location.protocol+"//"+location.host+"/chat/cmd/web.chat.favor") },
"首页": function(event, can) { can.onaction._open(can, location.protocol+"//"+location.host) },
"官网": function(event, can) { can.onaction._open(can, "https://shylinux.com/") },
"文档": function(event, can) { can.onaction._open(can, "https://developer.mozilla.org/") },
"百度": function(event, can) { can.onaction._open(can, "https://baidu.com") },
xterm: function(event, can, button) {
can.onaction._runs(can.request(event, can.Option()), can, button, function(msg) {
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Result(), code.XTERM)
can.ui.xterm.refresh(), can.user.toastSuccess(can)
})
},
status: function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.git.status", ctx.INDEX) },
plan: function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.team.plan", ctx.INDEX) },
vim: function(event, can) {
can.onaction._run(can.request(event, can.Option()), can, code.XTERM, [mdb.TYPE, "vim +"+can.Option(nfs.LINE)+" "+can.Option(nfs.PATH)+can.Option(nfs.FILE)], function(msg) {
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Result(), code.XTERM)
can.ui.xterm.refresh(), can.user.toastSuccess(can)
})
},
"命令": function(event, can) {
can.user.input(event, can, [ctx.INDEX], function(list) {
can.onimport.tabview(can, can.Option(nfs.PATH), list[0], ctx.INDEX)
})
},
"插件": function(event, can) {
can.user.input(event, can, [ctx.INDEX], function(list) {
var sub = can.toolkit[list[0]]; if (sub) { sub.select(); return }
can.onimport.toolkit(can, {index: list[0]}, function(sub) { can.toolkit[list[0]] = sub.select() })
})
},
"扩展": function(event, can) { can.request(event, {action: "extension"})
can.user.input(event, can, ["url"], function(list) {
var sub = can.extentions[list[0]]; if (sub) { sub.select(); return }
can.onimport.exts(can, list[0])
})
},
"录屏": function(event, can) { window.openapp("QuickTime Player") },
"日志": function(event, can) { window.opencmd("cd ~/contexts; tail -f var/log/bench.log") },
"编辑器": function(event, can) { window.opencmd("cd ~/contexts; vim +"+can.Option(nfs.LINE)+" "+can.Option(nfs.PATH)+can.Option(nfs.FILE)) },
"浏览器": function(event, can) { window.openurl(location.href) },
_open: function(can, url) { can.user.isWebview? window.openurl(url): window.open(url) },
_complete: function(event, can, target) { target = target||can.ui.complete
if (event == undefined) { return }
var pre = can.ui.current.value.slice(0, can.ui.current.selectionStart)
var end = can.ui.current.value.slice(can.ui.current.selectionStart)
const PRE = "pre"
var type = can.core.Split(pre).pop()||""
var name = can.core.Split(type, "", ice.PT).pop()||""
type = can.base.trimSuffix(type, name)
type = can.base.trimSuffix(type, ice.PT)
function update() { target._pre = pre, target._index = -1
can.current.line.appendChild(target), can.page.style(can, target, html.LEFT, can.ui.current.offsetLeft-1, html.MARGIN_TOP, can.ui.current.offsetHeight+4)
can.runAction(can.request(event, {text: pre}, can.Option()), code.COMPLETE, [], function(msg) {
can.page.Appends(can, target, [{view: [PRE, html.DIV, pre]}])
can.onappend.table(can, msg, function(value, key, index) { return {text: [value, html.TD], onclick: function(event) {
var left = can.ui.current.value.slice(0, can.ui.current.selectionStart)+value
can.current.text(can.ui.current.value = left+can.ui.current.value.slice(can.ui.current.selectionEnd))
can.ui.current.focus(), can.ui.content.scrollLeft -= 10000, can.ui.current.setSelectionRange(left.length, left.length)
}} }, target)
})
}
function filter() {
return can.page.Select(can, target, [html.TBODY, html.TR], function(tr) {
if (!can.page.ClassList.set(can, tr, html.HIDE, can.page.Select(can, tr, html.TD, function(td) {
if (td.innerText.toLowerCase().indexOf(can.base.trimSuffix((name == ice.PT? type: name).toLowerCase(), "(")) == 0) { return td }
}).length == 0)) { return tr }
}).length > (name == ice.PT? 1: 0)
}
function select(index, total) { index = (index+(total+1))%(total+1)
if (index == total) { can.current.text(can.ui.current.value = target._pre) }
can.page.Select(can, target, [html.TBODY, "tr:not(.hide)"], function(tr, i) { if (can.page.ClassList.set(can, tr, html.SELECT, i == index)) {
can.current.text(can.ui.current.value = target._pre+can.page.Select(can, tr, html.TD)[0].innerText)
} }); return index
}
if (event.ctrlKey) { if (event.type == "keyup") {
var total = can.page.Select(can, target, [html.TBODY, "tr:not(.hide)"]).length
switch (event.key) {
case "n": target._index = select(target._index+1, total); break
case "p": target._index = select(target._index-1, total); break
default: return false
}
return can.onkeymap.prevent(event)
} return }
switch (pre.slice(-1)) {
case "\t":
case " ":
case ".":
case "(":
case "{":
update()
break
case "":
default:
filter()
}
},
_selectLine: function(can) { if (!can.current) { return }
can.page.Select(can, can.current.line, "td.text", function(td) { var target = can.ui.current; target.value = td.innerText
can.current.line.appendChild(target), can.page.style(can, target, html.LEFT, td.offsetLeft-1, html.WIDTH, can.base.Min(td.offsetWidth, can.ui._content.offsetWidth))
var scroll = can.ui.content.scrollLeft
if (event && event.type == "click") {
can.onkeymap._insert(event, can, 0, (event.offsetX)/12-1)
} else {
target.focus(), can.onkeymap.cursorMove(can.ui.current, 0, 0)
} can.ui.content.scrollLeft = scroll
})
can.misc.localStorage(can, "web.code.inner:currentFile", can.Option(nfs.PATH)+ice.DF+can.Option(nfs.FILE)+ice.DF+can.onaction._getLineno(can, can.current.line))
can.misc.localStorage(can, "web.code.vimer:selectLine:"+can.Option(nfs.PATH)+can.Option(nfs.FILE), can.onaction._getLineno(can, can.current.line))
},
_getLine: function(can, line) {
return can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return td.parentNode } })[0]
},
_getLineno: function(can, line) {
return can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return index+1 } })[0]
},
rerankLine: function(can, value) {
can.max = can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { return td.innerText = index+1 }).length
},
insertLine: function(can, value, before) { var line = can.onaction.appendLine(can, value)
before && can.ui.content.insertBefore(line, can.onaction._getLine(can, before))
return can.onaction.rerankLine(can), can.onaction._getLineno(can, line)
},
deleteLine: function(can, line) { line = can.onaction._getLine(can, line)
var next = line.nextSibling||line.previousSibling
return can.page.Remove(can, line), can.onaction.rerankLine(can), next
},
modifyLine: function(can, line, value) {
can.page.Select(can, can.onaction._getLine(can, line), "td.text", function(td) {
td.innerHTML = can.onsyntax._parse(can, value)
})
},
cursorUp: function(can, target) { var p = can.onkeymap.cursorMove(target)
can.onaction.selectLine(can, can.current.prev()), can.onkeymap.cursorMove(target, 0, p)
},
cursorDown: function(can, target) { var p = can.onkeymap.cursorMove(target)
can.onaction.selectLine(can, can.current.next()), can.onkeymap.cursorMove(target, 0, p)
},
})
Volcanos(chat.ONEXPORT, {list: ["文件数", "模式", "按键", "解析器", "文件名", "当前行", "跳转数"]})
Volcanos(chat.ONKEYMAP, {
_model: function(can, value) { can.Status("模式", can.mode = value)
can.page.styleClass(can, can.ui.current, ["current", can.mode]), value
@ -255,272 +520,6 @@ Volcanos(chat.ONKEYMAP, {
},
}, _engine: {},
})
Volcanos(chat.ONACTION, {
_daemon: function(event, can, arg) {
switch (arg[0]) {
case web.DREAM:
can.runAction({}, arg[0], arg.slice(1), function(msg) {
can.onimport.tabview(can, can.Option(nfs.PATH), can.core.Keys(can.misc.Search(can, ice.POD), msg.Option(mdb.NAME)), web.DREAM)
})
break
case code.XTERM:
can.runAction({}, arg[0], arg.slice(1), function(msg) {
can.onimport.tabview(can, ctx.COMMAND, code.XTERM, msg.Result())
})
break
default:
can.runAction({}, arg[0], arg.slice(1), function(msg) {
can.onimport.tabview(can, msg.Option(nfs.PATH)||can.Option(nfs.PATH), msg.Option(nfs.FILE)), can.ui.source.refresh()
})
}
},
_run: function(event, can, button, args, cb) {
can.runAction(event, button, args, cb||function(msg) {
can.onimport.tabview(can, msg.Option(nfs.PATH)||can.Option(nfs.PATH), msg.Option(nfs.FILE))
can.ui.source.refresh(), can.user.toastSuccess(can, button)
})
},
_runs: function(event, can, button, cb) { var meta = can.Conf(); can.request(event, {action: button})
can.user.input(event, can, meta.feature[button], function(args) { can.onaction._run(event, can, button, args, cb) })
},
save: function(event, can, button) { can.request(event, {file: can.Option(nfs.FILE), content: can.onexport.content(can)})
can.onaction._run(event, can, button, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function() { can.user.toastSuccess(can, button, can.Option(nfs.PATH)+can.Option(nfs.FILE)) })
},
compile: function(event, can, button) { var _toast = can.user.toastProcess(can, "编译中...")
can.runAction(can.request(event), button, [], function(msg) { _toast.close()
if (msg.Length() > 0 || msg.Result()) {
return can.onimport.exts(can, "inner/search.js", function() {
can.onmotion.delay(can, function() { can.ui.search._show(msg) }, 300)
})
} else {
can.ui.search && can.onmotion.hidden(can, can.ui.search._target)
}
var toast = can.user.toastProcess(can, "重启中...")
can.onmotion.delay(can, function() { toast.close(), can.user.toastSuccess(can) }, 3000)
})
},
autogen: function(event, can, button) { can.onaction._runs(can.request(event, {path: "src/"}), can, button, function(msg) {
can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(cli.MAIN), "", function() {
can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(nfs.FILE), "", function() {
can.ui.source.refresh(), can.user.toastSuccess(can)
})
}, true)
}) },
script: function(event, can, button) {
can.onaction._runs(can.request(event, {path: "src/", file: can.base.trimSuffix(can.Option(nfs.FILE), can.base.Ext(can.Option(nfs.FILE)))+nfs.JS}), can, button)
},
website: function(event, can, button) {
can.onaction._runs(can.request(event, {path: "src/website/", file: (can.base.trimSuffix(can.Option(nfs.FILE), can.base.Ext(can.Option(nfs.FILE)))+nfs.ZML).split(ice.PS).pop()}), can, button)
},
dream: function(event, can, button) {
can.onaction._runs(can.request(event, {name: can.base.trimSuffix(can.Option(nfs.FILE).split(ice.PS).pop(), ice.PT+can.base.Ext(can.Option(nfs.FILE)))}), can, button, function(msg) {
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Option(mdb.NAME), web.DREAM)
can.ui.dream.refresh(), can.user.toastSuccess(can)
})
},
xterm: function(event, can, button) {
can.onaction._runs(can.request(event, can.Option()), can, button, function(msg) {
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Result(), code.XTERM)
can.ui.xterm.refresh(), can.user.toastSuccess(can)
})
},
status: function(event, can, button) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.git.status", ctx.INDEX) },
favor: function(event, can, button) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.favor", ctx.INDEX) },
"命令": function(event, can) {
can.user.input(event, can, [ctx.INDEX], function(list) {
can.onimport.tabview(can, can.Option(nfs.PATH), list[0], ctx.INDEX)
})
},
"插件": function(event, can) {
can.user.input(event, can, [ctx.INDEX], function(list) {
var sub = can.toolkit[list[0]]; if (sub) { sub.select(); return }
can.onimport.toolkit(can, {index: list[0]}, function(sub) { can.toolkit[list[0]] = sub.select() })
})
},
"扩展": function(event, can) { can.request(event, {action: "extension"})
can.user.input(event, can, ["url"], function(list) {
var sub = can.extentions[list[0]]; if (sub) { sub.select(); return }
can.onimport.exts(can, list[0])
})
},
"favor": function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.chat.favor", ctx.INDEX) },
"plan": function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.team.plan", ctx.INDEX) },
"git": function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.git.status", ctx.INDEX) },
"vim": function(event, can) {
can.onaction._run(can.request(event, can.Option()), can, code.XTERM, [mdb.TYPE, "vim +"+can.Option(nfs.LINE)+" "+can.Option(nfs.PATH)+can.Option(nfs.FILE)], function(msg) {
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Result(), code.XTERM)
can.ui.xterm.refresh(), can.user.toastSuccess(can)
})
},
"录屏": function(event, can) { window.openapp("QuickTime Player") },
"日志": function(event, can) { window.opencmd("cd ~/contexts; tail -f var/log/bench.log") },
"编辑器": function(event, can) { window.opencmd("cd ~/contexts; vim +"+can.Option(nfs.LINE)+" "+can.Option(nfs.PATH)+can.Option(nfs.FILE)) },
"浏览器": function(event, can) { window.openurl(location.href) },
_open: function(can, url) { can.user.isWebview? window.openurl(url): window.open(url) },
"收藏": function(event, can) { can.onaction._open(can, location.protocol+"//"+location.host+"/chat/cmd/web.chat.favor") },
"首页": function(event, can) { can.onaction._open(can, location.protocol+"//"+location.host) },
"百度": function(event, can) { can.onaction._open(can, "https://baidu.com") },
"文档": function(event, can) { can.onaction._open(can, "https://developer.mozilla.org/") },
"官网": function(event, can) { can.onaction._open(can, "https://shylinux.com/") },
"查找": function(event, can) {
var ui = can.page.Append(can, can._output, [{view: "vimer find float", list: [html.ACTION, html.OUTPUT],
style: {position: "absolute", left: can.ui.project.offsetWidth+can.ui.content.offsetWidth/2, top: can.base.Max(can.base.Min(can.current.line.offsetTop-can.ui.content.scrollTop, 100), can.ConfHeight()/2)+57+28}}])
can.onmotion.delay(can, function() { can.page.style(can, ui._target, html.LEFT, can.ui.project.offsetWidth+can.ui.content.offsetWidth/2-ui._target.offsetWidth/2) }, 10)
can.onmotion.move(can, ui._target)
var last = can.onaction._getLineno(can, can.current.line)
function find(begin, text) { if (parseInt(text) > 0) { return can.onaction.selectLine(can, parseInt(text)) && meta.close() }
for (begin; begin <= can.max; begin++) {
if (can.onexport.text(can, can.onaction._getLine(can, begin)).indexOf(text) > -1) {
return last = begin, can.onaction.selectLine(can, begin), can.current.scroll(can.current.scroll()-5)
}
} last = 0, can.user.toast(can, "已经到最后一行")
}
function complete(target, button) {
can.onappend.figure(can, {action: "key", mode: chat.SIMPLE, _enter: function(event) {
if (event.ctrlKey) { meta.grep() } else {
meta[button](), can.onmotion.delay(can, function() { target.focus() })
}
return true
}, run: function(event, cmds, cb) {
var msg = can.request(event); can.core.List(can.core.Split(can.current.text(), "\t \n{[(:=,)]}", {detail: true}), function(value) {
if (can.base.isObject(value)) { if (value.type == html.SPACE) { return }
value.type == lang.STRING && msg.Push(mdb.VALUE, value.left+value.text+value.right)
msg.Push(mdb.VALUE, value.text)
} else {
msg.Push(mdb.VALUE, value)
}
}), cb(msg)
}}, target)
}
var from, to
var meta = can.onappend._action(can, [
{type: html.TEXT, name: "from", style: {width: 200}, _init: function(target) { from = target, complete(target, "find"), can.onmotion.delay(can, function() { target.focus() }) }},
"find", "grep",
{type: html.TEXT, name: "to", _init: function(target) { to = target, complete(target, "replace") }},
"replace",
"close",
], ui.action, {
find: function() { find(last+1, from.value) },
grep: function() {
can.onimport.exts(can, "inner/search.js", function(sub) { meta.close()
sub.runAction(event, nfs.GREP, [from.value])
})
},
replace: function() {
var text = can.current.text(), line = can.onaction._getLineno(can, can.current.line)
can.undo.push(function() { can.onaction.selectLine(can, line), can.onaction.modifyLine(can, line, text) })
can.current.text(text.replace(from.value, to.value))
can.current.text().indexOf(from.value) == -1 && meta.find() },
close: function() { can.page.Remove(can, ui._target) },
})
},
_complete: function(event, can, target) { target = target||can.ui.complete
if (event == undefined) { return }
var pre = can.ui.current.value.slice(0, can.ui.current.selectionStart)
var end = can.ui.current.value.slice(can.ui.current.selectionStart)
const PRE = "pre"
var type = can.core.Split(pre).pop()||""
var name = can.core.Split(type, "", ice.PT).pop()||""
type = can.base.trimSuffix(type, name)
type = can.base.trimSuffix(type, ice.PT)
function update() { target._pre = pre, target._index = -1
can.current.line.appendChild(target), can.page.style(can, target, html.LEFT, can.ui.current.offsetLeft-1, html.MARGIN_TOP, can.ui.current.offsetHeight+4)
can.runAction(can.request(event, {text: pre}, can.Option()), code.COMPLETE, [], function(msg) {
can.page.Appends(can, target, [{view: [PRE, html.DIV, pre]}])
can.onappend.table(can, msg, function(value, key, index) { return {text: [value, html.TD], onclick: function(event) {
var left = can.ui.current.value.slice(0, can.ui.current.selectionStart)+value
can.current.text(can.ui.current.value = left+can.ui.current.value.slice(can.ui.current.selectionEnd))
can.ui.current.focus(), can.ui.content.scrollLeft -= 10000, can.ui.current.setSelectionRange(left.length, left.length)
}} }, target)
})
}
function filter() {
return can.page.Select(can, target, [html.TBODY, html.TR], function(tr) {
if (!can.page.ClassList.set(can, tr, html.HIDE, can.page.Select(can, tr, html.TD, function(td) {
if (td.innerText.toLowerCase().indexOf(can.base.trimSuffix((name == ice.PT? type: name).toLowerCase(), "(")) == 0) { return td }
}).length == 0)) { return tr }
}).length > (name == ice.PT? 1: 0)
}
function select(index, total) { index = (index+(total+1))%(total+1)
if (index == total) { can.current.text(can.ui.current.value = target._pre) }
can.page.Select(can, target, [html.TBODY, "tr:not(.hide)"], function(tr, i) { if (can.page.ClassList.set(can, tr, html.SELECT, i == index)) {
can.current.text(can.ui.current.value = target._pre+can.page.Select(can, tr, html.TD)[0].innerText)
} }); return index
}
if (event.ctrlKey) { if (event.type == "keyup") {
var total = can.page.Select(can, target, [html.TBODY, "tr:not(.hide)"]).length
switch (event.key) {
case "n": target._index = select(target._index+1, total); break
case "p": target._index = select(target._index-1, total); break
default: return false
}
return can.onkeymap.prevent(event)
} return }
switch (pre.slice(-1)) {
case "\t":
case " ":
case ".":
case "(":
case "{":
update()
break
case "":
default:
filter()
}
},
_selectLine: function(can) { if (!can.current) { return }
can.page.Select(can, can.current.line, "td.text", function(td) { var target = can.ui.current; target.value = td.innerText
can.current.line.appendChild(target), can.page.style(can, target, html.LEFT, td.offsetLeft-1, html.WIDTH, can.base.Min(td.offsetWidth, can.ui._content.offsetWidth))
var scroll = can.ui.content.scrollLeft
if (event && event.type == "click") {
can.onkeymap._insert(event, can, 0, (event.offsetX)/12-1)
} else {
target.focus(), can.onkeymap.cursorMove(can.ui.current, 0, 0)
} can.ui.content.scrollLeft = scroll
})
can.misc.localStorage(can, "web.code.inner:currentFile", can.Option(nfs.PATH)+ice.DF+can.Option(nfs.FILE)+ice.DF+can.onaction._getLineno(can, can.current.line))
can.misc.localStorage(can, "web.code.vimer:selectLine:"+can.Option(nfs.PATH)+can.Option(nfs.FILE), can.onaction._getLineno(can, can.current.line))
},
_getLine: function(can, line) {
return can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return td.parentNode } })[0]
},
_getLineno: function(can, line) {
return can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return index+1 } })[0]
},
rerankLine: function(can, value) {
can.max = can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { return td.innerText = index+1 }).length
},
insertLine: function(can, value, before) { var line = can.onaction.appendLine(can, value)
before && can.ui.content.insertBefore(line, can.onaction._getLine(can, before))
return can.onaction.rerankLine(can), can.onaction._getLineno(can, line)
},
deleteLine: function(can, line) { line = can.onaction._getLine(can, line)
var next = line.nextSibling||line.previousSibling
return can.page.Remove(can, line), can.onaction.rerankLine(can), next
},
modifyLine: function(can, line, value) {
can.page.Select(can, can.onaction._getLine(can, line), "td.text", function(td) {
td.innerHTML = can.onsyntax._parse(can, value)
})
},
cursorUp: function(can, target) { var p = can.onkeymap.cursorMove(target)
can.onaction.selectLine(can, can.current.prev()), can.onkeymap.cursorMove(target, 0, p)
},
cursorDown: function(can, target) { var p = can.onkeymap.cursorMove(target)
can.onaction.selectLine(can, can.current.next()), can.onkeymap.cursorMove(target, 0, p)
},
})
Volcanos(chat.ONEXPORT, {list: ["文件数", "模式", "按键", "解析器", "文件名", "当前行", "跳转数"]})
Volcanos(chat.ONPLUGIN, {
"code.vimer.keymap": shy("按键", {}, ["mode", "key", ice.LIST, ice.BACK], function(can, msg, cmds) {
can.core.Item(can.onkeymap._mode, function(mode, value) {