mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 01:04:06 +08:00
opt inner.js
This commit is contained in:
parent
144611db1a
commit
7a7cf9b1ab
3
frame.js
3
frame.js
@ -88,7 +88,8 @@ Volcanos("onengine", {help: "解析引擎", list: [], _init: function(can, meta,
|
||||
}},
|
||||
"project": {name: "研发群", storm: {
|
||||
"studio": {name: "研发 studio", action: [
|
||||
{name: "vimer", help: "编辑器", index: "web.code.vimer", args: ["src/", "main.go"]},
|
||||
// {name: "vimer", help: "编辑器", index: "web.code.vimer", args: ["src/", "main.go"]},
|
||||
{name: "inner", help: "编辑器", index: "web.code.inner", args: ["src/", "main.go"]},
|
||||
{name: "repos", help: "代码库", index: "web.code.git.status"},
|
||||
{name: "plan", help: "任务表", index: "web.team.plan"},
|
||||
{name: "contexts", help: "上下文", index: "web.wiki.word", args: ["src/main.shy"]},
|
||||
|
@ -162,13 +162,13 @@ Volcanos("base", {help: "基础模块",
|
||||
console.log.apply(console, args)
|
||||
},
|
||||
Warn: function() {
|
||||
var args = [this.Time(null, "%H:%M:%S"), this.FileLine(2, 3), "error"]
|
||||
var args = [this.Time(null, "%H:%M:%S"), this.FileLine(2, 3), "warn"]
|
||||
for (var i in arguments) { args.push(arguments[i]) }
|
||||
args.push("\n", this._fileLine().split("\n").slice(2).join("\n"))
|
||||
console.log.apply(console, args)
|
||||
},
|
||||
Debug: function() {
|
||||
var args = [this.Time(null, "%H:%M:%S"), this.FileLine(2, 3), "warn"]
|
||||
var args = [this.Time(null, "%H:%M:%S"), this.FileLine(2, 3), "debug"]
|
||||
for (var i in arguments) { args.push(arguments[i]) }
|
||||
args.push(this.fileLine(2, 3))
|
||||
console.log.apply(console, args)
|
||||
|
@ -54,6 +54,7 @@ Volcanos("page", {help: "网页模块",
|
||||
|
||||
value = value || {}
|
||||
can.core.List(key, function(item, index) { if (!item) { return }
|
||||
if (typeof item == "string") { target.innerHTML = item; return }
|
||||
if (item.nodeName) { target.appendChild(item); return }
|
||||
|
||||
// 基本结构: type name data list
|
||||
|
@ -103,7 +103,8 @@ table.content th {
|
||||
padding:2px 6px;
|
||||
}
|
||||
table.content td {
|
||||
max-width:1200px; overflow:auto;
|
||||
/* max-width:1200px; */
|
||||
overflow:auto;
|
||||
padding:2px 6px;
|
||||
}
|
||||
table.content td.select {
|
||||
@ -215,6 +216,9 @@ fieldset>div.status>div.item>label {
|
||||
font-size:10px; color:gray;
|
||||
}
|
||||
|
||||
table.layout>td {
|
||||
vertical-align:top;
|
||||
}
|
||||
table.layout>tr {
|
||||
margin:0;border:0;padding:0;
|
||||
}
|
||||
|
@ -39,56 +39,60 @@ fieldset.editor>div.output div.project {
|
||||
font-size:14px; font-family:monospace;
|
||||
color:white;
|
||||
}
|
||||
fieldset.editor>div.output div.profile {
|
||||
fieldset.editor>div.output div.content {
|
||||
overflow:auto;
|
||||
padding:0; margin:0;
|
||||
position:relative;
|
||||
}
|
||||
fieldset.editor>div.output div.display {
|
||||
display:none;
|
||||
}
|
||||
|
||||
fieldset.editor>div.output table.content {
|
||||
fieldset.editor>div.output div.content {
|
||||
font-size:16px; font-family:monospace;
|
||||
}
|
||||
fieldset.editor>div.output table.content tr {
|
||||
fieldset.editor>div.output div.content tr {
|
||||
background-color:#99CCFF00;
|
||||
}
|
||||
fieldset.editor>div.output table.content tr.select td.line {
|
||||
fieldset.editor>div.output div.content tr.select td.line {
|
||||
background-color:red;
|
||||
border:solid 1px yellow;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.line {
|
||||
fieldset.editor>div.output div.content td.line {
|
||||
text-align:right; margin:0;
|
||||
border-right:solid 2px red;
|
||||
padding:0 6px;
|
||||
color:white;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.line:hover {
|
||||
fieldset.editor>div.output div.content td.line:hover {
|
||||
background-color:green;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.text {
|
||||
fieldset.editor>div.output div.content td.text {
|
||||
text-align:left; height:20px;
|
||||
border:solid 1px #173d4000;
|
||||
padding:0; margin:0;
|
||||
padding-left:10px;
|
||||
color:white;
|
||||
white-space:pre;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.text:hover {
|
||||
fieldset.editor>div.output div.content td.text:hover {
|
||||
background-color:#06062700;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.text span.comment {
|
||||
fieldset.editor>div.output div.content td.text span.comment {
|
||||
color:cyan; background-color:blue;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.text span.keyword {
|
||||
fieldset.editor>div.output div.content td.text span.keyword {
|
||||
color:yellow; font-weight:bold;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.text span.function {
|
||||
fieldset.editor>div.output div.content td.text span.function {
|
||||
color:cyan; font-weight:bold;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.text span.datatype {
|
||||
fieldset.editor>div.output div.content td.text span.datatype {
|
||||
color:lightgreen; font-weight:bold;
|
||||
}
|
||||
fieldset.editor>div.output table.content td.text span.string {
|
||||
fieldset.editor>div.output div.content td.text span.string {
|
||||
color:magenta;
|
||||
}
|
||||
body.white fieldset.editor>div.output table.content td.text span.string {
|
||||
body.white fieldset.editor>div.output div.content td.text span.string {
|
||||
color:#a703a7;
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,7 @@
|
||||
Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb, target) {
|
||||
|
||||
/*
|
||||
var width = can.Conf("width"), height = can.Conf("height")
|
||||
can.onimport.resize = function(can, width, height) {
|
||||
can.Conf({width: width, height: height})
|
||||
can.onimport._init(can, msg, list, cb, target)
|
||||
|
||||
}, can.onengine.listen(can, "action.resize", function(width, height) {
|
||||
can.onimport.resize(can, width, height)
|
||||
})
|
||||
|
||||
|
||||
can.ui = can.page.Appends(can, target, [
|
||||
{view: ["void", "table"], list: [{type: "tr", list: [
|
||||
{type: "td", list: [{view: "project", style: {"max-height": height-240, display: "none"}} ]},
|
||||
@ -38,66 +31,73 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
|
||||
{view: "tags", style: {"max-height": 160}},
|
||||
]},
|
||||
])
|
||||
*/
|
||||
|
||||
typeof cb == "function" && cb(msg)
|
||||
can.history = can.history || []
|
||||
can.onmotion.clear(can), can.ui = can.onlayout.profile(can)
|
||||
can.page.Modify(can, can.ui.content, {style: {"max-height": can.Conf("height")-480}})
|
||||
can.page.Modify(can, can.ui.project, {style: {"max-height": can.Conf("height")-480}})
|
||||
|
||||
can.tabview = {}, can.tabview[can.Option("path")+can.Option("file")] = msg
|
||||
msg.Option({path: can.Option("path"), file: can.Option("file"), line: can.Option("line")||1})
|
||||
can.onimport.tabview(can, can.Option("path"), can.Option("file"), can.Option("line")||1)
|
||||
can.onimport.project(can, can.Option("path"))
|
||||
can.tabview = can.tabview || {}, can.tabview[can.Option("path")+can.Option("file")] = msg
|
||||
|
||||
can.onimport.tabview(can, msg.Option("path"), msg.Option("file"), msg.Option("line")||1)
|
||||
can.onimport.project(can, msg.Option("path"))
|
||||
typeof cb == "function" && cb(msg)
|
||||
},
|
||||
project: function(can, path) { can.Option({path: path})
|
||||
var msg = can.request({}, {dir_root: path, dir_deep: true})
|
||||
can.run(msg._event, ["action", "dir", "./"], function(msg) {
|
||||
can.onmotion.clear(can, can.ui.project)
|
||||
|
||||
can.onappend.tree(can, msg.Table(), "path", "/", function(event, item) {
|
||||
can.onimport.tabview(can, path, item.path)
|
||||
}, can.ui.project), can.Status("文件数", msg.Length())
|
||||
}, true)
|
||||
},
|
||||
tabview: function(can, path, file, line, cb) {
|
||||
function show() {
|
||||
if (can.tabview[path+file]) {
|
||||
can._msg && can._msg.Option("line", can.Option("line"))
|
||||
can._msg = can.tabview[path+file]
|
||||
|
||||
can.Option({path: path, file: file, line: line||parseInt(can._msg.Option("line"))||1})
|
||||
can.onmotion.select(can, can._action, "div.file", can._msg._tab)
|
||||
can.onsyntax._init(can, can._msg)
|
||||
typeof cb == "function" && cb()
|
||||
return
|
||||
}
|
||||
if (can.tabview[path+file]) { return show() }
|
||||
|
||||
can.run({}, ["action", "render", can.base.Ext(file||path), file, path], function(msg) {
|
||||
msg.Option({path: path, file: file, line: line||1})
|
||||
can.tabview[path+file] = msg
|
||||
|
||||
can.page.EnableDrop(can, can._action, "div.file", can.page.Append(can, can._action, [
|
||||
{view: ["file", "div", file.split("/").pop()], title: file, onclick: function(event) {
|
||||
msg._tab = can.page.Append(can, can._action, [
|
||||
{text: [file.split("/").pop(), "div", "file"], title: file, onclick: function(event) {
|
||||
can.onimport.tabview(can, path, file, "", cb)
|
||||
}, _init: function(item) {
|
||||
can.core.Timer(10, function() { item.click() })
|
||||
can.page.EnableDrop(can, can._action, "div.file", item)
|
||||
}}
|
||||
]).first).click()
|
||||
}, true)
|
||||
},
|
||||
project: function(can, path, cb) { can.Option({path: path})
|
||||
var msg = can.request({}, {dir_root: path, dir_deep: true})
|
||||
can.run(msg._event, ["action", "dir", "./"], function(msg) { can.ui.project.innerHTML = ""
|
||||
msg.path && can.Status("文件数", msg.path.length)
|
||||
can.onappend.tree(can, msg.Table(), "path", "/", function(event, value) {
|
||||
can.onimport.tabview(can, can.Option("path"), value.path)
|
||||
}, can.ui.project), typeof cb == "function" && cb()
|
||||
]).last
|
||||
}, true)
|
||||
},
|
||||
}, ["/plugin/local/code/inner.css"])
|
||||
Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"], _init: function(can, msg) { can._msg = msg
|
||||
can.page.Select(can, can._action, "div.file", function(item) {
|
||||
can.page.ClassList.set(can, item, "select", item.title == msg.Option("file"))
|
||||
})
|
||||
|
||||
Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"], _init: function(can, msg) {
|
||||
// caches save
|
||||
can.core.List(["content"], function(item) { can.page.Cache(can.file+item, can.ui[item], {
|
||||
can.file && can.core.List(["content", "profile", "display"], function(item) { can.page.Cache(can.file, can.ui[item], {
|
||||
scrollTop: can.ui.profile.parentNode.scrollTop,
|
||||
current: can.current,
|
||||
max: can.max,
|
||||
current: can.current, max: can.max,
|
||||
}) })
|
||||
|
||||
can.file = can.base.Path(msg.Option("path"), msg.Option("file"))
|
||||
can.parse = can.base.Ext(can.file)
|
||||
can.Status("解析器", can.parse)
|
||||
can.Status("文件名", can.file)
|
||||
can.Status("模式", "normal")
|
||||
|
||||
// caches load
|
||||
var cache = false; can.core.List(["content"], function(item) {
|
||||
var p = can.page.Cache(can.file+item, can.ui[item]); if (p != undefined) { cache = true
|
||||
var cache = false; can.core.List(["content", "profile", "display"], function(item) {
|
||||
var p = can.page.Cache(can.file, can.ui[item]); if (p != undefined && !cache) { cache = true
|
||||
can.ui.profile.parentNode.scrollTo(0, p.scrollTop)
|
||||
can.onaction.selectLine(can, p.current.line)
|
||||
can.max = p.max
|
||||
@ -107,11 +107,11 @@ Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"],
|
||||
function init(p) {
|
||||
can.max = 0, can.core.List(can.ls = msg.Result().split("\n"), function(item) {
|
||||
can.onaction.appendLine(can, item)
|
||||
}), can.onaction.selectLine(can, can.Option("line")||1)
|
||||
}), can.onaction.selectLine(can, msg.Option("line")||1)
|
||||
}
|
||||
|
||||
// plugin
|
||||
var p = can.onsyntax[can.parse]; !p? can.run({}, ["action", "plugin", can.parse, can.Option("file"), can.Option("path")], function(msg) {
|
||||
var p = can.onsyntax[can.parse]; !p? can.run({}, ["action", "plugin", can.parse, msg.Option("file"), msg.Option("path")], function(msg) {
|
||||
init(p = can.onsyntax[can.parse] = can.base.Obj(msg.Result()))
|
||||
}, true): init(p)
|
||||
},
|
||||
@ -141,102 +141,30 @@ Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"],
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "控件交互", list: [],
|
||||
"返回": function(event, can) {
|
||||
var last = can.history.pop(); last = can.history.pop()
|
||||
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
||||
can.Status("跳转数", can.history.length)
|
||||
},
|
||||
project: function(event, can) {
|
||||
can.page.Toggle(can, can.ui.project, function() {
|
||||
// can.onimport.project(can, can.Option("path"))
|
||||
})
|
||||
},
|
||||
searchShow: function(event, can) {
|
||||
can.page.Toggle(can, can.ui.search, function() {
|
||||
// can.onaction.searchLine(event, can, "")
|
||||
})
|
||||
},
|
||||
appendLine: function(can, value) {
|
||||
var ui = can.page.Append(can, can.ui.content, [{type: "tr", list: [
|
||||
{view: ["line", "td", ++can.max], onclick: function(event) {
|
||||
can.onaction.selectLine(can, ui.tr)
|
||||
|
||||
appendLine: function(can, value) { var index = ++can.max
|
||||
var ui = can.page.Append(can, can.ui.content, [{type: "tr", list: [{view: ["line", "td", index], onclick: function(event) {
|
||||
can.onaction.selectLine(can, ui.tr)
|
||||
}, ondblclick: function(event) {
|
||||
can.onaction.favorLine(can)
|
||||
}},
|
||||
{view: ["text", "td"], list: [can.onsyntax._parse(can, value)], onclick: function(event) {
|
||||
can.onaction._selectLine(can, ui, value)
|
||||
|
||||
}, ondblclick: function(event) {
|
||||
can.user.input(event, can, [
|
||||
{_input: "text", name: "topic", value: "@key"},
|
||||
{_input: "text", name: "name", value: "@key"},
|
||||
], function(event, button, meta, list) {
|
||||
can.run(event, [
|
||||
"favor", "topic", meta.topic||"some",
|
||||
"type", can.parse, "name", meta.name||"some", "text", value,
|
||||
"path", can.Option("path"), "file", can.Option("file"), "line", can.Option("line"),
|
||||
], function(msg) {
|
||||
can.user.toast(can, "收藏成功")
|
||||
}, true)
|
||||
return true
|
||||
})
|
||||
}}, {view: ["text", "td"], _init: function(td) {
|
||||
var p = can.onsyntax._parse(can, value)
|
||||
typeof p == "object"? can.page.Appends(can, td, [p]): td.innerHTML = p
|
||||
|
||||
}, onclick: function(event) {
|
||||
can.onkeymap && can.onkeymap._mode(can, "insert")
|
||||
can.onaction.selectLine(can, ui.tr)
|
||||
can.onkeymap && can.ui.editor.focus()
|
||||
// can.ui.editor.setSelectionRange(0, 0)
|
||||
// can.ui.editor.setSelectionRange(event.offsetX/10, event.offsetX/10)
|
||||
|
||||
}, ondblclick: function(event) {
|
||||
var str = ui.text.innerText
|
||||
var s = document.getSelection().toString()
|
||||
var begin = str.indexOf(s)
|
||||
var 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
|
||||
}
|
||||
}
|
||||
if (s.indexOf(".") == 0) {
|
||||
s = s.slice(1)
|
||||
}
|
||||
if (s.indexOf("kit.") == 0) {
|
||||
s = s.replace("kit.", "toolkits.")
|
||||
}
|
||||
|
||||
can.onaction.searchLine(event, can, s)
|
||||
}} ] }])
|
||||
return ui.tr
|
||||
},
|
||||
rerankLine: function(can, value) { can.max = 0
|
||||
can.page.Select(can, can.ui.content, "tr", function(item, index) {
|
||||
can.max++, can.page.Select(can, item, "td.line", function(item) {
|
||||
item.innerText = index+1
|
||||
})
|
||||
})
|
||||
},
|
||||
modifyLine: function(can, line, value) {
|
||||
can.page.Select(can, can.ui.content, "tr", function(item, index) {
|
||||
if (item != line && index+1 != line) { return }
|
||||
|
||||
can.page.Select(can, item, "td.text", function(item) {
|
||||
var p = can.onsyntax._parse(can, value)
|
||||
typeof p == "object"? can.page.Appends(can, item, [p]): item.innerHTML = p
|
||||
})
|
||||
})
|
||||
}, ondblclick: function(event) {
|
||||
can.onaction._searchLine(can, ui, value)
|
||||
}}
|
||||
]}]); return ui.tr
|
||||
},
|
||||
selectLine: function(can, line) { if (!line) { return }
|
||||
can.page.Select(can, can.ui.content, "tr", function(item, index) {
|
||||
can.page.ClassList.del(can, item, "select")
|
||||
if (item != line && index+1 != line) { return }
|
||||
can.page.ClassList.add(can, item, "select")
|
||||
line = item
|
||||
|
||||
line = item
|
||||
can.Option("line", index+1)
|
||||
can.Status("文件名", can.file)
|
||||
can.Status("解析器", can.parse)
|
||||
can.Status("当前行", can.onexport.position(can, index+1))
|
||||
})
|
||||
|
||||
@ -269,6 +197,85 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"返回": function(event, can) {
|
||||
var last = can.history.pop(); last = can.history.pop()
|
||||
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
||||
can.Status("跳转数", can.history.length)
|
||||
},
|
||||
project: function(event, can) {
|
||||
can.page.Toggle(can, can.ui.project, function() {
|
||||
// can.onimport.project(can, can.Option("path"))
|
||||
})
|
||||
},
|
||||
searchShow: function(event, can) {
|
||||
can.page.Toggle(can, can.ui.search, function() {
|
||||
// can.onaction.searchLine(event, can, "")
|
||||
})
|
||||
},
|
||||
favorLine: function(can, value) {
|
||||
can.user.input(event, can, [
|
||||
{_input: "text", name: "topic", value: "@key"},
|
||||
{_input: "text", name: "name", value: "@key"},
|
||||
], function(event, button, meta, list) {
|
||||
can.run(event, [
|
||||
"favor", "topic", meta.topic||"some",
|
||||
"type", can.parse, "name", meta.name||"some", "text", value,
|
||||
"path", can.Option("path"), "file", can.Option("file"), "line", can.Option("line"),
|
||||
], function(msg) {
|
||||
can.user.toast(can, "收藏成功")
|
||||
}, true)
|
||||
return true
|
||||
})
|
||||
},
|
||||
|
||||
rerankLine: function(can, value) { can.max = 0
|
||||
can.page.Select(can, can.ui.content, "tr", function(item, index) {
|
||||
can.max++, can.page.Select(can, item, "td.line", function(item) {
|
||||
item.innerText = index+1
|
||||
})
|
||||
})
|
||||
},
|
||||
modifyLine: function(can, line, value) {
|
||||
can.page.Select(can, can.ui.content, "tr", function(item, index) {
|
||||
if (item != line && index+1 != line) { return }
|
||||
|
||||
can.page.Select(can, item, "td.text", function(item) {
|
||||
var p = can.onsyntax._parse(can, value)
|
||||
typeof p == "object"? can.page.Appends(can, item, [p]): item.innerHTML = p
|
||||
})
|
||||
})
|
||||
},
|
||||
_selectLine: function(can, ui) {
|
||||
can.onkeymap && can.onkeymap._mode(can, "insert")
|
||||
can.onaction.selectLine(can, ui.tr)
|
||||
can.onkeymap && can.ui.editor.focus()
|
||||
// can.ui.editor.setSelectionRange(0, 0)
|
||||
// can.ui.editor.setSelectionRange(event.offsetX/10, event.offsetX/10)
|
||||
},
|
||||
_searchLine: function(can, ui, value) {
|
||||
var str = ui.text.innerText
|
||||
var s = document.getSelection().toString()
|
||||
var begin = str.indexOf(s)
|
||||
var 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
|
||||
}
|
||||
}
|
||||
if (s.indexOf(".") == 0) {
|
||||
s = s.slice(1)
|
||||
}
|
||||
if (s.indexOf("kit.") == 0) {
|
||||
s = s.replace("kit.", "toolkits.")
|
||||
}
|
||||
|
||||
can.onaction.searchLine(event, can, s)
|
||||
},
|
||||
searchLine: function(event, can, value) { value = value.trim()
|
||||
can.page.Modify(can, can.ui.search, {style: {display: ""}})
|
||||
value = can.ui.word.value = value || can.ui.word.value || "main"
|
||||
|
Loading…
x
Reference in New Issue
Block a user