mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 01:04:06 +08:00
opt vimer.js
This commit is contained in:
parent
cb491c1c94
commit
64ee3aab6f
@ -16,19 +16,19 @@ fieldset.editor>div.output {
|
||||
color:white;
|
||||
}
|
||||
fieldset.editor>div.output div.project {
|
||||
max-width:180px; overflow:auto;
|
||||
font-size:14px; font-family:monospace;
|
||||
max-width:180px; overflow:auto;
|
||||
}
|
||||
fieldset.editor>div.output div.content {
|
||||
font-size:16px; font-family:monospace;
|
||||
overflow:auto; padding-right:20px;
|
||||
position:relative;
|
||||
overflow:auto;
|
||||
color:white;
|
||||
}
|
||||
|
||||
fieldset.editor>div.output div.content tr.select td.line {
|
||||
border:solid 1px yellow;
|
||||
background-color:red;
|
||||
border:solid 1px red;
|
||||
border-right:solid 2px red;
|
||||
background-color:blue;
|
||||
}
|
||||
fieldset.editor>div.output div.content td.line:hover {
|
||||
background-color:green;
|
||||
|
@ -25,13 +25,12 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
|
||||
]},
|
||||
{view: "tags", style: {"max-height": 160}},
|
||||
]},
|
||||
]); can.ui.search = ui.search, can.ui.word = ui.word, can.ui.tags = ui.tags
|
||||
]); can.core.Copy(can.ui, ui, "search", "word", "tags")
|
||||
},
|
||||
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())
|
||||
@ -43,9 +42,7 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
|
||||
can._msg = can.tabview[path+file]
|
||||
|
||||
can.Option({path: path, file: file, line: line||parseInt(can._msg.Option("line"))||1})
|
||||
can.onsyntax._init(can, can._msg)
|
||||
typeof cb == "function" && cb()
|
||||
return
|
||||
return can.onsyntax._init(can, can._msg), typeof cb == "function" && cb()
|
||||
}
|
||||
|
||||
can.run({}, ["action", "render", can.base.Ext(file||path), file, path], function(msg) {
|
||||
@ -77,8 +74,8 @@ Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"],
|
||||
can.onmotion.select(can, can._action, "div.file", msg._tab)
|
||||
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.content.scrollTo(0, p.scrollTop)
|
||||
can.onaction.selectLine(can, p.current.line)
|
||||
can.ui.content.scrollTo(0, p.scrollTop)
|
||||
can.max = p.max
|
||||
}
|
||||
}); if (cache) { return }
|
||||
@ -125,12 +122,8 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
||||
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
||||
can.Status("跳转数", can.history.length)
|
||||
},
|
||||
project: function(event, can) {
|
||||
can.onmotion.toggle(can, can.ui.project)
|
||||
},
|
||||
searchShow: function(event, can) {
|
||||
can.onmotion.toggle(can, can.ui.search)
|
||||
},
|
||||
project: function(event, can) { can.onmotion.toggle(can, can.ui.project) },
|
||||
searchShow: function(event, can) { can.onmotion.toggle(can, can.ui.search) },
|
||||
|
||||
appendLine: function(can, value) {
|
||||
var ui = can.page.Append(can, can.ui.content, [{type: "tr", list: [
|
||||
@ -180,30 +173,29 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
||||
typeof line == "object" && can.page.Select(can, line, "td.text", function(item) {
|
||||
can.current = {
|
||||
scroll: function(x, y) { return can.ui.content.scrollBy(x, y) },
|
||||
offset: function() { return can.ui.content.scrollTop },
|
||||
window: function() { return can.ui.content.offsetHeight },
|
||||
height: function() { return line.offsetHeight },
|
||||
offset: function() { return can.ui.content.scrollTop },
|
||||
|
||||
prev: function() { return line.previousSibling },
|
||||
next: function() { return line.nextSibling },
|
||||
line: line, text: function(text) {
|
||||
return text != undefined && can.onaction.modifyLine(can, line, text), item.innerText
|
||||
},
|
||||
}, height: function() { return line.offsetHeight },
|
||||
}
|
||||
|
||||
var push = {path: can.Option("path"), file: can.Option("file"), line: can.Option("line")}
|
||||
can.core.Eq({path: push.path, file: push.file}, can.history[can.history.length-1]) || can.history.push(push)
|
||||
can.Status("跳转数", can.history.length)
|
||||
|
||||
can.onkeymap && can.onkeymap.selectLine(can, line, item)
|
||||
})
|
||||
|
||||
if (can.current) {
|
||||
var pos = can.current.offset()-can.current.line.offsetTop
|
||||
if (pos > 0 || -pos > can._output.offsetHeight) {
|
||||
can.current.scroll(0, -pos)
|
||||
if (can.current) { var offline = 5
|
||||
var pos = can.current.line.offsetTop-can.current.offset()
|
||||
if (pos > can.current.window()-offline*20) {
|
||||
can.current.scroll(0, pos-can.current.window()+offline*20)
|
||||
} else if (pos < offline*20) {
|
||||
can.current.scroll(0, pos-offline*20)
|
||||
}
|
||||
}
|
||||
} can.onkeymap && can.onkeymap.selectLine(can)
|
||||
},
|
||||
searchLine: function(event, can, value) { value = value.trim()
|
||||
can.page.Modify(can, can.ui.search, {style: {display: ""}})
|
||||
@ -264,7 +256,6 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
||||
return true
|
||||
})
|
||||
},
|
||||
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: ["文件数", "解析器", "文件名", "当前行", "跳转数", "标签数"],
|
||||
position: function(can, index, total) { total = total || can.max
|
||||
|
@ -1,3 +1,6 @@
|
||||
fieldset.editor>div.output td.content {
|
||||
position:relative;
|
||||
}
|
||||
fieldset.editor>div.output input.current {
|
||||
position:absolute; padding:0; margin:0;
|
||||
font-size:16px; font-family:monospace;
|
||||
@ -17,7 +20,6 @@ fieldset.editor>div.output input.current.command {
|
||||
}
|
||||
|
||||
fieldset.editor>div.output input.command {
|
||||
margin:0; padding:0 12px;
|
||||
font-size:16px; font-family:monospace;
|
||||
background-color:black; color:white;
|
||||
caret-color:red;
|
||||
@ -25,6 +27,7 @@ fieldset.editor>div.output input.command {
|
||||
border:solid 1px red;
|
||||
border-left:solid 3px green;
|
||||
width:-webkit-fill-available;
|
||||
margin:0; padding:0 12px;
|
||||
}
|
||||
fieldset.editor>div.output input.command.normal {
|
||||
display:none;
|
||||
@ -34,7 +37,7 @@ fieldset.editor>div.output input.command.insert {
|
||||
}
|
||||
|
||||
fieldset.editor>div.output div.display {
|
||||
border:solid 2px greenyellow;
|
||||
border:solid 1px greenyellow;
|
||||
padding:10px;
|
||||
}
|
||||
fieldset.editor>div.output div.display input.cmd {
|
||||
|
@ -6,7 +6,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _merge: function(can, sub)
|
||||
can.keylist = [], can.onkeymap._init(can, "insert")
|
||||
typeof cb == "function" && cb(msg)
|
||||
|
||||
var ui = can.page.Append(can, can.ui.content, [
|
||||
var ui = can.page.Append(can, can.ui.content.parentNode, [
|
||||
{view: ["current", "input"], onkeydown: function(event) {
|
||||
can.onkeymap.parse(event, can, "insert")
|
||||
can.core.Timer(10, function() {
|
||||
@ -15,6 +15,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _merge: function(can, sub)
|
||||
}, onblur: function(event) {
|
||||
can.current.text(can.ui.current.value)
|
||||
}, onfocus: function(event) {
|
||||
can._output.scrollBy(-1000, 0)
|
||||
can.current.scroll(-1000, 0)
|
||||
}, onclick: function(event) {
|
||||
can.onkeymap._insert(can)
|
||||
@ -22,6 +23,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _merge: function(can, sub)
|
||||
{view: ["command", "input"], onkeydown: function(event) {
|
||||
can.onkeymap.parse(event, can, "command")
|
||||
}, onfocus: function(event) {
|
||||
can._output.scrollBy(-1000, 0)
|
||||
can.current.scroll(-1000, 0)
|
||||
}},
|
||||
]); can.core.Copy(can.ui, ui, "current", "command")
|
||||
@ -37,10 +39,9 @@ Volcanos("onimport", {help: "导入数据", list: [], _merge: function(can, sub)
|
||||
can.onkeymap.command.Enter(event, can, can.ui.cmd.value)
|
||||
}]},
|
||||
{button: ["关闭", function(event) {
|
||||
can.page.Modify(can, can.ui.display, {style: {display: "none"}})
|
||||
can.onmotion.hidden(can, can.ui.display)
|
||||
} ]},
|
||||
]},
|
||||
{view: "output"},
|
||||
]}, {view: "output"},
|
||||
]); can.core.Copy(can.ui, ui, "output", "cmd")
|
||||
}, target)
|
||||
})
|
||||
@ -62,9 +63,7 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
||||
},
|
||||
_command: function(can) { can.onkeymap._mode(can, "command")
|
||||
if (can.ui.display.style.display == "none") {
|
||||
can.page.Modify(can, can.ui.command, {style: {
|
||||
display: "", position: "absolute", top: can.current.offset()+can.current.window()-can.current.height(),
|
||||
}})
|
||||
can.page.Modify(can, can.ui.command, {style: {display: ""}})
|
||||
can.ui.command.focus()
|
||||
} else {
|
||||
can.page.Modify(can, can.ui.display, {style: {display: "block"}})
|
||||
@ -93,9 +92,9 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
||||
},
|
||||
|
||||
parse: function(event, can, mode) {
|
||||
event.key.length == 1 && can.keylist.push(event.key); if (can.mode != mode) {
|
||||
can.keylist.push(event.key); if (can.mode != mode) {
|
||||
event.stopPropagation(), event.preventDefault()
|
||||
}; can.mode != "command" && can.Status("按键", can.keylist.join(""))
|
||||
}; can.mode == "normal" && can.Status("按键", can.keylist.join(""))
|
||||
|
||||
for (var pre = 0; pre < can.keylist.length; pre++) {
|
||||
if ("0" <= can.keylist[pre] && can.keylist[pre] <= "9") { continue } break
|
||||
@ -119,22 +118,18 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
||||
}
|
||||
},
|
||||
command: {
|
||||
Escape: function(event, can) {
|
||||
can.page.Modify(can, can.ui.command, {style: {display: "none"}, value: ""})
|
||||
can.onkeymap._normal(can)
|
||||
},
|
||||
Enter: function(event, can) { var line = can.ui.command.value || can.ui.cmd.value ; var ls = can.core.Split(line, " ", ",")
|
||||
can.page.Modify(can, can.ui.command, {style: {display: "none"}, value: ""})
|
||||
Escape: function(event, can) { can.onkeymap._normal(can) },
|
||||
Enter: function(event, can) { can.onmotion.hidden(can, can.ui.command)
|
||||
can.page.Modify(can, can.ui.display, {style: {display: "block"}})
|
||||
can.ui.cmd.value = line, can.ui.cmd.focus()
|
||||
can.ui.cmd.setSelectionRange(0, -1)
|
||||
|
||||
can.onmotion.clear(can, can.ui.output)
|
||||
var cb = can.onkeymap._engine[ls[0]];
|
||||
if (typeof cb == "function") {
|
||||
cb(event, can, line, ls)
|
||||
can.page.Modify(can, can.ui.display, {style: {display: "none"}})
|
||||
var line = can.ui.command.value || can.ui.cmd.value ; var ls = can.core.Split(line, " ", ",")
|
||||
var cb = can.onkeymap._engine[ls[0]]; if (typeof cb == "function") {
|
||||
can.onmotion.hidden(can, can.ui.display)
|
||||
can.onkeymap._normal(can)
|
||||
cb(event, can, line, ls)
|
||||
} else {
|
||||
can.onkeymap._remote(event, can, line, ["action", "command"].concat(ls))
|
||||
}
|
||||
@ -145,8 +140,8 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
||||
},
|
||||
normal: {
|
||||
":": function(event, can) {
|
||||
can.ui.command.value = ""
|
||||
can.onkeymap._command(can)
|
||||
can.ui.command.value = ""
|
||||
},
|
||||
".": function(event, can) {
|
||||
can.keylist = can.lastcmd
|
||||
@ -167,15 +162,15 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
||||
},
|
||||
j: function(event, can) {
|
||||
can.onaction.selectLine(can, can.current.next())
|
||||
var pos = can.current.offset()+can.current.window()-can.ui.current.offsetTop; if (pos < 5*can.current.height()) {
|
||||
can.current.scroll(0, can.current.height())
|
||||
}
|
||||
// var pos = can.current.offset()+can.current.window()-can.ui.current.offsetTop; if (pos < 5*can.current.height()) {
|
||||
// can.current.scroll(0, can.current.height())
|
||||
// }
|
||||
},
|
||||
k: function(event, can) {
|
||||
can.onaction.selectLine(can, can.current.prev())
|
||||
var pos = can.ui.current.offsetTop-can.current.offset(); if (pos < can.current.height()*5) {
|
||||
can.current.scroll(0, -can.current.height())
|
||||
}
|
||||
// var pos = can.ui.current.offsetTop-can.current.offset(); if (pos < can.current.height()*5) {
|
||||
// can.current.scroll(0, -can.current.height())
|
||||
// }
|
||||
},
|
||||
|
||||
gg: function(event, can, count) { count = count || 1
|
||||
@ -278,21 +273,18 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
||||
},
|
||||
},
|
||||
|
||||
selectLine: function(can, line, item) {
|
||||
can.page.Modify(can, can.ui.current, {className: "current "+can.mode, value: item.innerText, style: {
|
||||
left: item.offsetLeft, top: item.offsetTop,
|
||||
height: item.offsetHeight,
|
||||
}})
|
||||
can.page.Modify(can, can.ui.command, {className: "command "+can.mode, value: item.innerText, style: {
|
||||
left: item.offsetLeft, top: item.offsetTop + can.ui.profile.offsetHeight-100,
|
||||
height: item.offsetHeight,
|
||||
selectLine: function(can) { var line = can.current.line
|
||||
can.page.Select(can, can.current.line, "td.text", function(item) { line = item })
|
||||
can.page.Modify(can, can.ui.current, {className: "current "+can.mode, value: can.current.text(), style: {
|
||||
left: line.offsetLeft, top: line.offsetTop-can.current.offset()-2,
|
||||
height: line.offsetHeight, width: line.offsetWidth
|
||||
}})
|
||||
can.page.Modify(can, can.ui.command, {className: "command "+can.mode})
|
||||
},
|
||||
insertLine: function(can, value, before) {
|
||||
var line = can.onaction.appendLine(can, value)
|
||||
before && can.ui.content.insertBefore(line, before)
|
||||
can.onaction.rerankLine(can)
|
||||
return line
|
||||
return can.onaction.rerankLine(can), line
|
||||
},
|
||||
deleteLine: function(can, line) {
|
||||
can.page.Remove(can, line)
|
||||
@ -300,17 +292,13 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "控件交互", list: [],
|
||||
_engine: function(event, can, key) {
|
||||
can.onkeymap._remote(event, can, key)
|
||||
},
|
||||
display: function(event, can) { can.onmotion.toggle(can, can.ui.display) },
|
||||
|
||||
save: function(event, can) {
|
||||
var msg = can.request(event); msg.Option("content", can.onexport.content(can))
|
||||
can.run(event, ["action", "save", can.parse, can.Option("file"), can.Option("path")], function(msg) {
|
||||
can.user.toast(can, "保存成功")
|
||||
}, true)
|
||||
},
|
||||
display: function(event, can) {
|
||||
can.onmotion.toggle(can, can.ui.display)
|
||||
},
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: ["文件数", "模式", "按键", "解析器", "文件名", "当前行", "跳转数", "标签数"]})
|
||||
|
Loading…
x
Reference in New Issue
Block a user