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-10-20 20:27:37 +08:00
parent 43824fddb3
commit 636f535588
3 changed files with 25 additions and 36 deletions

View File

@ -16,10 +16,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据",
function show(skip) { if (can.isCmdMode()) { can.onimport._title(can, path+file) }
can._msg && can._msg.Option(nfs.LINE, can.Option(nfs.LINE)), can._msg = can.tabview[key]
can.Option(can.onimport.history(can, {path: path, file: file, line: line||
can.user.localStorage(can, "web.code.vimer.selectLine:"+path+file)||
can._msg.Option(nfs.LINE)||
1}))
can.Option(can.onimport.history(can, {path: path, file: file, line: line||can.user.localStorage(can, "web.code.vimer.selectLine:"+path+file)||can._msg.Option(nfs.LINE)|| 1}))
can.onsyntax._init(can, can._msg, function(content) { var msg = can._msg
can.onexport.hash(can), msg._tab && can.onmotion.select(can, msg._tab.parentNode, html.DIV_TABS, msg._tab)
can.ui._path && (can.ui._path.innerHTML = isDream()? can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: can.Option(nfs.FILE)})):
@ -27,10 +24,12 @@ Volcanos(chat.ONIMPORT, {help: "导入数据",
can.ui.current && can.onmotion.toggle(can, can.ui.current, !isCommand() && !isDream())
can.page.Select(can, can.ui._content.parentNode, can.page.Keys(html.DIV_CONTENT, html.IFRAME), function(item) {
if (item.parentNode != can.ui._content.parentNode) { return }
if (can.onmotion.toggle(can, item, item == msg._content)) { can.ui.content = msg._content }
}), can.ui.content._plugin = msg._plugin, msg._plugin && can.onmotion.delay(can, function() { msg._plugin.Focus() })
can.page.Select(can, can.ui._profile_output.parentNode, can.page.Keys(html.DIV_OUTPUT, html.IFRAME), function(item) {
if (item.parentNode != can.ui._profile_output.parentNode) { return }
if (can.onmotion.toggle(can, item, item == msg._profile_output)) { can.ui.profile_output = msg._profile_output }
})
@ -400,7 +399,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
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]) }, 300)
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)
},
@ -435,7 +434,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
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-3*html.ACTION_HEIGHT+sub.onexport.statusHeight(sub), content_width, true)
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

View File

@ -1,5 +1,5 @@
Volcanos(chat.ONPLUGIN, {help: "导入数据", _init: function(can, sub, cb) { const SEARCH = "can.code.inner.search"; var history = []
function show(msg, word) { if (!msg) { return } history.push(msg); var sub = msg._can
function show(msg, word) { if (!msg) { return } history.push(msg); var sub = can.ui.search
sub.onimport.size(sub, can.ConfHeight()/4, can.ConfWidth()-can.ui.project.offsetWidth, true)
sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) {
return {text: ["", html.TD], list: [{text: [can.base.trimPrefix(value, nfs.PWD), html.DIV]}], onclick: function(event) { if (!line.line) { return }
@ -9,9 +9,9 @@ Volcanos(chat.ONPLUGIN, {help: "导入数据", _init: function(can, sub, cb) { c
!sub.page.ClassList.has(sub, sub._legend, html.SELECT) && sub.select(), sub.Focus(), sub.Option("word", word||msg._word||"")
}
can.onengine.plugin(can, SEARCH, shy("搜索", {}, ["word=main", "filter", "grep:button", "make", "history", "last"], function(can, msg, cmds, cb) { can.misc.runAction(can, msg, cmds, cb, kit.Dict(
"replace", function(cmds) { can.runAction(msg, nfs.GREP, [cmds[0]], function(msg) { show(msg, cmds[0]) }) },
nfs.GREP, function(cmds) { can.runAction(msg, nfs.GREP, [cmds[0]], function(msg) { show(msg, cmds[0]) }) },
"history", function(cmds) { can.core.List(can.history, function(item) { msg.PushRecord(item) }), show(msg) },
"last", function(cmds) { history.pop(), show(history.pop()) },
)) })), can.onimport.toolkit(can, {index: SEARCH}, function(sub) { can.ui.search = sub, sub._show = show, can.base.isFunc(cb) && cb(sub) })
}})

View File

@ -103,8 +103,8 @@ Volcanos(chat.ONKEYMAP, {help: "键盘交互",
},
_plugin: function(event, can) { can.onkeymap._model(can, "plugin"), can.ui.current.blur() },
_normal: function(event, can) { can.onkeymap._model(can, "normal"), can.ui.current.focus() },
_insert: function(event, can, count, begin) { can.onkeymap.prevent(event)
can.onkeymap._model(can, "insert"), can.ui.current.focus()
_insert: function(event, can, count, begin) { can.onkeymap._model(can, "insert"), can.onkeymap.prevent(event)
var scroll = can.ui.content.scrollLeft; can.ui.current.focus(), can.ui.content.scrollLeft = scroll
can.onkeymap.cursorMove(can.ui.current, count, begin)
},
@ -271,10 +271,9 @@ Volcanos(chat.ONACTION, {help: "控件交互",
compile: function(event, can, button) {
can.runAction(can.request(event, {_toast: "编译中..."}), button, [], function(msg) {
if (msg.Length() > 0 || msg.Result()) {
can.onimport.exts(can, "inner/search.js", function() {
can.ui.search._show(msg)
return can.onimport.exts(can, "inner/search.js", function() {
can.onmotion.delay(can, function() { can.ui.search._show(msg) }, 300)
})
return
}
var toast = can.user.toastProcess(can, "重启中...")
@ -306,12 +305,9 @@ Volcanos(chat.ONACTION, {help: "控件交互",
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)
},
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)
@ -329,27 +325,17 @@ Volcanos(chat.ONACTION, {help: "控件交互",
can.onimport.exts(can, list[0])
})
},
"git": function(event, can) {
can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.git.status", 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.opencmd("cd ~/contexts; tail -f var/log/bench.log")
},
"录屏": function(event, can) {
window.openapp("QuickTime Player")
},
"编辑器": 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)
},
"录屏": 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) },
"查找": function(event, can) {
var ui = can.page.Append(can, can._output, [{view: "vimer find", list: [html.ACTION, html.OUTPUT], style: {position: "absolute", left: can.ui.project.offsetWidth, top: 320}}])
can.onmotion.move(can, ui.first)
@ -440,8 +426,12 @@ Volcanos(chat.ONACTION, {help: "控件交互",
_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))
if (event && event.type == "click") { can.onkeymap._insert(event, can, 0, (event.offsetX)/12-1) }
target.focus(), can.ui.content.scrollLeft -= 10000
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.user.localStorage(can, "web.code.vimer.selectLine:"+can.Option(nfs.PATH)+can.Option(nfs.FILE), can.onaction._getLineno(can, can.current.line))
},