1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 08:48:06 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-04-18 07:32:23 +08:00
parent 6779eed0c5
commit c50f7ef5bb
5 changed files with 30 additions and 11 deletions

View File

@ -201,7 +201,7 @@ Volcanos("misc", {
_stacks: function(n, s) { var list = ((s||(new Error())).stack||"").split(ice.NL).slice(typeof n == undefined? 2: n)
for (var i = 0; i < list.length; i++) { var ls = list[i].trim().split(ice.SP)
list[i] = ls.pop().trim(); if (list[i][0] == "(") { list[i] = list[i].slice(1, -1) }
list[i] = ice.TB+list[i]; if (ls.length > 1) { list[i] += ice.TB+ls.pop() }
list[i] = " "+list[i]; if (ls.length > 1) { list[i] += " "+ls.pop() }
list[i] = list[i].replace(/\?[^:]+/, "").replace(location.origin, "")
} return list
}, _stack: function() { return ((new Error()).stack||"").split(ice.NL).slice(2) },

View File

@ -3,7 +3,7 @@
"background": {"page": "/publish/chrome/daemon.html"},
"browser_action": {"default_popup": "/publish/chrome/popup.html"},
"content_scripts": [
{"matches": ["<all_urls>"], "permissions": [
{"matches": [""], "permissions": [
"tabs", "history", "cookies", "bookmarks", "contextMenus", "notifications", "http://localhost:9020/*"
], "css": ["/page/can.css"], "js": ["/page/can.js", "/publish/chrome/contexts.js"]}
]

View File

@ -347,7 +347,7 @@ Volcanos(chat.ONSYNTAX, {_init: function(can, msg, cb) {
Volcanos(chat.ONACTION, {
_getLine: function(can, line) { return can.page.Select(can, can.ui.content, "tr.line>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return td.parentNode } })[0] },
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) }) },
appendLine: function(can, value) { var ui = can.page.Append(can, can.ui._content, [{view: [nfs.LINE, html.TR], list: [
appendLine: function(can, value, target) { var ui = can.page.Append(can, target||can.ui._content, [{view: [nfs.LINE, html.TR], list: [
{view: [nfs.LINE, html.TD, ++can.db.max], onclick: function(event) {
can.onaction.selectLine(can, ui.tr)
}, ondblclick: function(event) { can.onaction.find(event, can) }},
@ -356,18 +356,18 @@ Volcanos(chat.ONACTION, {
if (event.metaKey) { if (ui.text.innerText.indexOf(ice.HTTP) > -1) { var ls = (/(http[^ ]+)/).exec(ui.text.innerText); if (ls && ls[1]) { can.user.open(ls[1]) } } }
}, ondblclick: function(event) { can.onaction.searchLine(event, can, can.onexport.selection(can, ui.text.innerText)) }}
]}]); return ui._target },
rerankLine: function(can, which) { can.db.max = can.page.Select(can, can.ui.content, which||"tr.line:not(.delete)>td.line", function(td, index) { return td.innerText = index+1 }).length },
rerankLine: function(can, which, target) { can.db.max = can.page.Select(can, target||can.ui.content, which||"tr.line:not(.delete)>td.line", function(td, index) { return td.innerText = index+1 }).length },
selectLine: function(can, line, scroll) { if (!line) { return can.onexport.line(can, can.page.SelectOne(can, can.ui.content, "tr.select")) }
can.page.Select(can, can.ui._content, "tr.line>td.line", function(target) { var n = parseInt(target.innerText); target = target.parentNode
can.page.Select(can, can.ui.content, "tr.line>td.line", function(target) { var n = parseInt(target.innerText); target = target.parentNode
if (!can.page.ClassList.set(can, target, html.SELECT, n == line || target == line)) { return }
line = target, can.Status(nfs.LINE, can.onexport.position(can, can.Option(nfs.LINE, n)))
}); if (!can.base.isObject(line)) { return 0 }
can.page.Select(can, line, "td.text", function(target) {
can.current = {line: line, next: function() { return line.nextSibling }, prev: function() { return line.previousSibling },
text: function(text) { return text != undefined && can.onaction.modifyLine(can, line, text), target.innerText },
scroll: function(count) { if (count) { can.ui._content.scrollTop += count*can.current.line.offsetHeight }
return parseInt((can.current.line.offsetTop-can.ui._content.scrollTop)/can.current.line.offsetHeight)
}, window: function() { return parseInt(can.ui._content.offsetHeight/can.current.line.offsetHeight) },
scroll: function(count) { if (count) { can.ui.content.scrollTop += count*can.current.line.offsetHeight }
return parseInt((can.current.line.offsetTop-can.ui.content.scrollTop)/can.current.line.offsetHeight)
}, window: function() { return parseInt(can.ui.content.offsetHeight/can.current.line.offsetHeight) }, content: line.parentNode,
}, can.onimport.history(can, {path: can.Option(nfs.PATH), file: can.Option(nfs.FILE), line: can.Option(nfs.LINE), text: can.current.text()})
can.onexport.hash(can), scroll && can.onaction.scrollIntoView(can), can.onengine.signal(can, LINE_SELECT, can._msg)
})
@ -482,7 +482,7 @@ Volcanos(chat.ONEXPORT, {list: [mdb.COUNT, mdb.TYPE, nfs.FILE, nfs.LINE, ice.BAC
keys: function(can, path, file) { return [path||can.Option(nfs.PATH), file||can.Option(nfs.FILE)].join(ice.DF) },
line: function(can, line) { return parseInt(can.core.Value(can.page.SelectOne(can, line, "td.line"), "innerText")) },
text: function(can, line) { return can.core.Value(can.page.SelectOne(can, line, "td.text"), "innerText") },
content: function(can) { return can.page.Select(can, can.ui.content, "td.text", function(item) { return item.innerText }).join(ice.NL) },
content: function(can) { return can.page.Select(can, can.current&&can.current.content||can.ui.content, "td.text", function(item) { return item.innerText }).join(ice.NL) },
position: function(can, index, total) { total = total||can.db.max; return (parseInt(index))+ice.PS+parseInt(total)+" = "+parseInt((index)*100/total)+"%" },
selection: function(can, str) { var s = document.getSelection().toString(), begin = str.indexOf(s), end = begin+s.length
for (var i = begin; i >= 0; i--) { if (str[i].match(/[a-zA-Z0-9_.]/)) { s = str.slice(i, end) } else { break } } return s

View File

@ -13,3 +13,4 @@ body.black fieldset.vimer>div.output input.current.insert { caret-color:yellow;
body.dark fieldset.vimer>div.output input.current.normal { caret-color:gray; }
body.dark fieldset.vimer>div.output input.current.insert { caret-color:yellow; }
div.input.vimer.source.create.float td:first-child { display:none; }
div.layout.flex>* { float:left; clear:none; }

View File

@ -182,11 +182,27 @@ Volcanos(chat.ONACTION, {list: ["编译", "变更", "源码", "终端", "导图"
}) },
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.onexport.line(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 },
scrollHold: function(can, count, begin) { var scroll = can.ui.content.scrollLeft; can.ui.current.focus(), count != undefined && can.onkeymap.cursorMove(can.ui.current, count, begin == undefined? count: begin), can.ui.content.scrollLeft = scroll },
scrollHold: function(can, count, begin) {
var scroll = can.ui.content.scrollLeft, _scroll = can.current.content.scrollLeft;
can.ui.current.focus(), count != undefined && can.onkeymap.cursorMove(can.ui.current, count, begin == undefined? count: begin)
can.ui.content.scrollLeft = scroll, can.current.content.scrollLeft = _scroll
},
cursorDown: function(can, target) { var p = can.onkeymap.cursorMove(target); can.onaction.selectLine(can, can.current.next()), can.onkeymap.cursorMove(target, 0, p) },
cursorUp: function(can, target) { var p = can.onkeymap.cursorMove(target); can.onaction.selectLine(can, can.current.prev()), can.onkeymap.cursorMove(target, 0, p) },
})
Volcanos(chat.ONEXPORT, {list: [mdb.COUNT, mdb.TYPE, nfs.FILE, nfs.LINE, ice.BACK, ice.MODE, mdb.KEYS]})
Volcanos(chat.ONLAYOUT, {
_split: function(can, target, layout) {
var layout = can.page.Create(can, html.DIV, {className: html.LAYOUT+ice.SP+layout})
var style = layout == html.FLOW? {width: target.offsetWidth, height: target.offsetHeight/2}: {width: target.offsetWidth/2, height: target.offsetHeight}
var left = can.page.Create(can, html.DIV, {className: html.CONTENT, style: style}), right = can.page.Create(can, html.DIV, {className: html.CONTENT, style: style})
can.page.SelectChild(can, target, "*", function(target) { left.appendChild(target), can.onaction.appendLine(can, can.page.SelectOne(can, target, "td.text").innerText, right) })
layout.appendChild(left), layout.appendChild(right), can.onaction.rerankLine(can, "", right), target.appendChild(layout)
var content = can.ui.content; can.ui.content = left, can.onaction.selectLine(can, can.Option(nfs.LINE)), can.ui.content = right, can.onaction.selectLine(can, can.Option(nfs.LINE)), can.ui.content = content
},
split: function(can, target) { can.onlayout._split(can, target, html.FLOW) },
vsplit: function(can, target) { can.onlayout._split(can, target, html.FLEX) },
})
Volcanos(chat.ONKEYMAP, {
_model: function(can, value) { can.Status(ice.MODE, can.db.mode = value), can.page.styleClass(can, can.ui.current, [code.CURRENT, can.db.mode]), can.page.styleClass(can, can.ui.complete, [code.COMPLETE, can.db.mode, chat.FLOAT]), can.onimport.__tabPath(can, true) },
_plugin: function(can) { can.onkeymap._model(can, mdb.PLUGIN), can.ui.current.blur() },
@ -293,6 +309,8 @@ Volcanos(chat.ONKEYMAP, {
f: shy("向下翻页", function(can, count) { var line = can.onaction.selectLine(can)+can.current.window()-3-can.current.scroll(); return can.current.scroll(line), can.onaction.selectLine(can, line), true }),
b: shy("向上翻页", function(can, count) { var line = can.onaction.selectLine(can)-can.current.window()+3; return can.current.scroll(line), can.onaction.selectLine(can, line), true }),
r: shy("刷新页面", function(can) { can.user.reload(true) }),
v: shy("刷新页面", function(can) { can.onlayout.vsplit(can, can._msg._view||can.ui.content) }),
s: shy("刷新页面", function(can) { can.onlayout.split(can, can._msg._view||can.ui.content) }),
},
insert_ctrl: {
f: shy("光标右移", function(can, target) { can.user.isWindows && can.onkeymap.cursorMove(target, 1) }),