mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
add some
This commit is contained in:
parent
7622ca567f
commit
8fcb2dfdfa
@ -220,10 +220,13 @@ Volcanos("misc", {
|
||||
}) }
|
||||
return socket
|
||||
},
|
||||
ResourceFavicon: function(can, path) { return can.misc.Resource(can, path||can.user.info.favicon||nfs.SRC_MAIN_ICO) },
|
||||
ResourceFavicon: function(can, path, space) { return can.misc.Resource(can, path||can.user.info.favicon||nfs.SRC_MAIN_ICO, space) },
|
||||
Resource: function(can, path, space, serve) {
|
||||
if (!can.base.beginWith(path, web.HTTP, nfs.PS)) { path = nfs.P+path+_version }
|
||||
if (!can.base.beginWith(path, web.HTTP, nfs.PS)) {
|
||||
path = nfs.P+path+(path.indexOf("usr/icons/") == -1? (space? can.core.Split(_version, "&")[0]: _version): "")
|
||||
}
|
||||
if (!can.base.beginWith(path, web.HTTP)) { if (serve && serve.indexOf(location.origin) == -1) { var u = can.base.ParseURL(serve); path = u.origin + path } }
|
||||
if (can.base.beginWith(path, web.HTTP)) { return path }
|
||||
if (path.indexOf("pod=") > 0) { return path }
|
||||
return can.base.MergeURL(path, ice.POD, space||can.ConfSpace()||can.misc.Search(can, ice.POD))
|
||||
},
|
||||
|
@ -5,8 +5,8 @@ Volcanos(chat.ONIMPORT, {
|
||||
}) })
|
||||
},
|
||||
_input: function(can) { var ui = can.page.Append(can, can.ui.content.parentNode, [
|
||||
{view: [code.CURRENT, html.INPUT], spellcheck: false, onkeydown: function(event) { if (event.metaKey) { return }
|
||||
can.onimport._value(can), can.onkeymap._parse(event, can, can.db.mode+(event.ctrlKey? "_ctrl": ""), can.ui.current)
|
||||
{view: [code.CURRENT, html.INPUT], spellcheck: false, onkeydown: function(event) { if (event.metaKey) { return }
|
||||
can.onimport._value(can), can.onkeymap._parse(event, can, can.db.mode+(event.ctrlKey? "_ctrl": ""), can.ui.current)
|
||||
if (can.db.mode == mdb.INSERT) { can.ui.current._keylist = [] }
|
||||
if (can.db.mode == mdb.NORMAL) { can.onkeymap.prevent(event) }
|
||||
}, onkeyup: function(event) { if (event.metaKey) { return }
|
||||
@ -24,7 +24,8 @@ Volcanos(chat.ONFIGURE, {
|
||||
can.core.List(paths.concat(msg.Table(function(value) { return value.path })), function(p) {
|
||||
if (can.base.beginWith(p, nfs.USR_LOCAL_WORK) || can.base.isIn(p,
|
||||
// nfs.USR_LEARNING, nfs.USR_INTSHELL,
|
||||
nfs.USR_ICONS, nfs.USR_GEOAREA, nfs.USR_PROGRAM, nfs.USR_NODE_MODULES,
|
||||
nfs.USR_ICONS, nfs.USR_GEOAREA, nfs.USR_NODE_MODULES,
|
||||
// nfs.USR_PROGRAM,
|
||||
nfs.USR_WEBSOCKET, nfs.USR_GO_QRCODE, nfs.USR_GO_GIT
|
||||
)) { return }
|
||||
if (p && paths.indexOf(p) == -1 && p[0] != nfs.PS) { paths.push(p) }
|
||||
@ -175,136 +176,137 @@ Volcanos(chat.ONKEYMAP, {
|
||||
case lex.SP:
|
||||
case nfs.PT:
|
||||
case "[":
|
||||
case "(":
|
||||
case "{": update(); break
|
||||
case "":
|
||||
default: filter()
|
||||
}
|
||||
},
|
||||
_mode: {
|
||||
plugin: {
|
||||
Escape: shy("清除浮窗", function(event, can) { can.onaction.clear(event, can) }),
|
||||
f: shy("打开文件", function(event, can) { can.onaction.open(event, can) }),
|
||||
g: shy("查找搜索", function(event, can) { can.onaction.find(event, can) }),
|
||||
d: shy("查找函数", function(event, can) { can.page.Select(can, can.ui.path, "span.func", function(target) { target.click() }) }),
|
||||
n: shy("命令模式", function(event, can) { can.onaction.selectLine(can, can.onaction.selectLine(can)), can.onkeymap._normal(can) }),
|
||||
i: shy("插入模式", function(event, can) { can.onaction.selectLine(can, can.onaction.selectLine(can)), can.onkeymap._insert(event, can) }),
|
||||
s: shy("保存文件", function(event, can) { can.onaction.save(event, can, nfs.SAVE) }),
|
||||
c: shy("编译项目", function(event, can) { can.onaction.compile(event, can, code.COMPILE) }),
|
||||
v: shy("渲染界面", function(event, can) { can.onaction.show(event, can) }),
|
||||
r: shy("执行命令", function(event, can) { can.onaction.exec(event, can) }),
|
||||
t: shy("添加命令", function(event, can) { can.onaction["命令"](event, can) }),
|
||||
p: shy("添加插件", function(event, can) { can.onaction["插件"](event, can) }),
|
||||
l: shy("打开右边标签", function(can) { var next = can._tab.nextSibling; next && next.click() }),
|
||||
h: shy("打开左边标签", function(can) { var prev = can._tab.previousSibling; prev && prev.click() }),
|
||||
x: shy("关闭标签", function(can) { can._tab._close() }),
|
||||
},
|
||||
normal: {
|
||||
s: shy("保存文件", function(event, can) { can.onaction.save(event, can, nfs.SAVE) }),
|
||||
c: shy("编译项目", function(event, can) { can.onaction.compile(event, can, code.COMPILE) }),
|
||||
v: shy("渲染界面", function(event, can) { can.onaction.show(event, can) }),
|
||||
r: shy("执行命令", function(event, can) { can.onaction.exec(event, can) }),
|
||||
case "(":
|
||||
case "{": update(); break
|
||||
case "":
|
||||
default: filter()
|
||||
}
|
||||
},
|
||||
_mode: {
|
||||
plugin: {
|
||||
Escape: shy("清除浮窗", function(event, can) { can.onaction.clear(event, can) }),
|
||||
f: shy("打开文件", function(event, can) { can.onaction.open(event, can) }),
|
||||
g: shy("查找搜索", function(event, can) { can.onaction.find(event, can) }),
|
||||
d: shy("查找函数", function(event, can) { can.page.Select(can, can.ui.path, "span.func", function(target) { target.click() }) }),
|
||||
n: shy("命令模式", function(event, can) { can.onaction.selectLine(can, can.onaction.selectLine(can)), can.onkeymap._normal(can) }),
|
||||
i: shy("插入模式", function(event, can) { can.onaction.selectLine(can, can.onaction.selectLine(can)), can.onkeymap._insert(event, can) }),
|
||||
s: shy("保存文件", function(event, can) { can.onaction.save(event, can, nfs.SAVE) }),
|
||||
c: shy("编译项目", function(event, can) { can.onaction.compile(event, can, code.COMPILE) }),
|
||||
v: shy("渲染界面", function(event, can) { can.onaction.show(event, can) }),
|
||||
r: shy("执行命令", function(event, can) { can.onaction.exec(event, can) }),
|
||||
t: shy("添加命令", function(event, can) { can.onaction["命令"](event, can) }),
|
||||
p: shy("添加插件", function(event, can) { can.onaction["插件"](event, can) }),
|
||||
l: shy("打开右边标签", function(can) { var next = can._tab.nextSibling; next && next.click() }),
|
||||
h: shy("打开左边标签", function(can) { var prev = can._tab.previousSibling; prev && prev.click() }),
|
||||
x: shy("关闭标签", function(can) { can._tab._close() }),
|
||||
},
|
||||
normal: {
|
||||
s: shy("保存文件", function(event, can) { can.onaction.save(event, can, nfs.SAVE) }),
|
||||
c: shy("编译项目", function(event, can) { can.onaction.compile(event, can, code.COMPILE) }),
|
||||
v: shy("渲染界面", function(event, can) { can.onaction.show(event, can) }),
|
||||
r: shy("执行命令", function(event, can) { can.onaction.exec(event, can) }),
|
||||
|
||||
Escape: shy("切换模式", function(can) { can.onkeymap._plugin(can) }),
|
||||
ArrowLeft: shy("光标左移", function(can, target) { can.onkeymap.cursorMove(target, -1) }),
|
||||
ArrowRight: shy("光标右移", function(can, target) { can.onkeymap.cursorMove(target, 1) }),
|
||||
ArrowDown: shy("光标下移", function(can, target) { can.onkeymap.cursorDown(can, target) }),
|
||||
ArrowUp: shy("光标上移", function(can, target) { can.onkeymap.cursorUp(can, target) }),
|
||||
H: shy("跳到行首", function(can, target) { can.onkeymap.cursorMove(target, 0, 0) }),
|
||||
L: shy("跳到行尾", function(can, target) { can.onkeymap.cursorMove(target, 0, -1) }),
|
||||
h: shy("光标左移", function(can, target) { can.onkeymap.cursorMove(target, -1) }),
|
||||
l: shy("光标右移", function(can, target) { can.onkeymap.cursorMove(target, 1) }),
|
||||
j: shy("光标下移", function(can, target) { can.onkeymap.cursorDown(can, target) }),
|
||||
k: shy("光标上移", function(can, target) { can.onkeymap.cursorUp(can, target) }),
|
||||
Escape: shy("切换模式", function(can) { can.onkeymap._plugin(can) }),
|
||||
ArrowLeft: shy("光标左移", function(can, target) { can.onkeymap.cursorMove(target, -1) }),
|
||||
ArrowRight: shy("光标右移", function(can, target) { can.onkeymap.cursorMove(target, 1) }),
|
||||
ArrowDown: shy("光标下移", function(can, target) { can.onkeymap.cursorDown(can, target) }),
|
||||
ArrowUp: shy("光标上移", function(can, target) { can.onkeymap.cursorUp(can, target) }),
|
||||
H: shy("跳到行首", function(can, target) { can.onkeymap.cursorMove(target, 0, 0) }),
|
||||
L: shy("跳到行尾", function(can, target) { can.onkeymap.cursorMove(target, 0, -1) }),
|
||||
h: shy("光标左移", function(can, target) { can.onkeymap.cursorMove(target, -1) }),
|
||||
l: shy("光标右移", function(can, target) { can.onkeymap.cursorMove(target, 1) }),
|
||||
j: shy("光标下移", function(can, target) { can.onkeymap.cursorDown(can, target) }),
|
||||
k: shy("光标上移", function(can, target) { can.onkeymap.cursorUp(can, target) }),
|
||||
|
||||
I: shy("插入行首", function(event, can) { can.onkeymap._insert(event, can, 0, 0) }),
|
||||
A: shy("插入行尾", function(event, can) { can.onkeymap._insert(event, can, 0, -1) }),
|
||||
i: shy("插入模式", function(event, can) { can.onkeymap._insert(event, can) }),
|
||||
a: shy("插入模式", function(event, can) { can.onkeymap._insert(event, can) }),
|
||||
o: shy("插入下一行", function(event, can) { var text = can.current.text()
|
||||
text = text.substr(0, text.indexOf(text.trimLeft()))+(can.base.endWith(text, "{")? lex.TB: "")
|
||||
can.onaction.selectLine(can, can.onaction.insertLine(can, text, can.current.next()))
|
||||
can.onkeymap._insert(event, can, 0, -1)
|
||||
}),
|
||||
O: shy("插入上一行", function(event, can) { var text = can.current.text()
|
||||
text = text.substr(0, text.indexOf(text.trimLeft()))+(can.base.beginWith(text, "}")? lex.TB: "")
|
||||
can.onaction.selectLine(can, can.onaction.insertLine(can, text, can.current.line))
|
||||
can.onkeymap._insert(event, can, 0, -1)
|
||||
}),
|
||||
I: shy("插入行首", function(event, can) { can.onkeymap._insert(event, can, 0, 0) }),
|
||||
A: shy("插入行尾", function(event, can) { can.onkeymap._insert(event, can, 0, -1) }),
|
||||
i: shy("插入模式", function(event, can) { can.onkeymap._insert(event, can) }),
|
||||
a: shy("插入模式", function(event, can) { can.onkeymap._insert(event, can) }),
|
||||
o: shy("插入下一行", function(event, can) { var text = can.current.text()
|
||||
text = text.substr(0, text.indexOf(text.trimLeft()))+(can.base.endWith(text, "{")? lex.TB: "")
|
||||
can.onaction.selectLine(can, can.onaction.insertLine(can, text, can.current.next()))
|
||||
can.onkeymap._insert(event, can, 0, -1)
|
||||
}),
|
||||
O: shy("插入上一行", function(event, can) { var text = can.current.text()
|
||||
text = text.substr(0, text.indexOf(text.trimLeft()))+(can.base.beginWith(text, "}")? lex.TB: "")
|
||||
can.onaction.selectLine(can, can.onaction.insertLine(can, text, can.current.line))
|
||||
can.onkeymap._insert(event, can, 0, -1)
|
||||
}),
|
||||
|
||||
yy: shy("复制当前行", function(event, can, target, count) { var list = [], line = can.current.line
|
||||
for (var i = 0; i < count; i++) { list.push(can.onexport.text(can, line)), line = line.nextSibling } can.db._last_text = list; return true
|
||||
}),
|
||||
dd: shy("剪切当前行", function(event, can, target, count) { var line = can.onaction.selectLine(can), callee = arguments.callee
|
||||
var list = []; for (var i = 0; i < count; i++) { (function() { var line = can.onaction.selectLine(can), text = can.current.text(); list.push(text)
|
||||
can.onaction.selectLine(can, can.onaction.deleteLine(can, line)), can.db.undo.push(function() { can.onaction.insertLine(can, text, line), can.onaction.selectLine(can, line) })
|
||||
})() } can.db._last_text = list, can.db.redo.push(function() { callee(event, can, target, count) })
|
||||
return true
|
||||
}),
|
||||
p: shy("向后粘贴", function(can) { if (!can.db._last_text) { return } var line = can.onaction.selectLine(can), callee = arguments.callee
|
||||
for (var i = can.db._last_text.length-1; i >= 0; i--) { (function() { var line = can.onaction.insertLine(can, can.db._last_text[i], can.current.next())
|
||||
can.db.undo.push(function() { can.onaction.deleteLine(can, line), can.onaction.selectLine(can, line-1) })
|
||||
})() } can.db.redo.push(function() { callee(event, can, target, count) })
|
||||
}),
|
||||
P: shy("向前粘贴", function(can) { if (!can.db._last_text) { return } var line = can.onaction.selectLine(can), callee = arguments.callee
|
||||
for (var i = 0; i < can.db._last_text.length; i++) { (function() { var line = can.onaction.insertLine(can, can.db._last_text[i], can.current.line)
|
||||
can.db.undo.push(function() { can.onaction.deleteLine(can, line), can.onaction.selectLine(can, line+1) })
|
||||
})() } can.db.redo.push(function() { callee(event, can, target, count) })
|
||||
}),
|
||||
J: shy("合并两行", function(can) { var next = can.current.next(); if (!next) { return }
|
||||
var line = can.onaction.selectLine(can), text = can.current.text(), rest = can.onexport.text(can, next)
|
||||
can.ui.current.value = can.current.text(text.trimRight()+(can.base.endWith(text.trim(), "(", "[")||can.base.beginWith(rest.trim(), ",", "]", ")")? "": lex.SP)+rest.trimLeft())
|
||||
can.onkeymap.cursorMove(can.ui.current, text.length, 0), can.onaction.deleteLine(can, next)
|
||||
can.db.undo.push(function() { can.onaction.modifyLine(can, line, text), can.onaction.insertLine(can, rest, line+1) })
|
||||
}),
|
||||
".": shy("重复操作", function(can) { var cb = can.db.redo.pop(); cb && cb() }),
|
||||
u: shy("撤销操作", function(can) { var cb = can.db.undo.pop(); cb && cb() }),
|
||||
yy: shy("复制当前行", function(event, can, target, count) { var list = [], line = can.current.line
|
||||
for (var i = 0; i < count; i++) { list.push(can.onexport.text(can, line)), line = line.nextSibling } can.db._last_text = list; return true
|
||||
}),
|
||||
dd: shy("剪切当前行", function(event, can, target, count) { var line = can.onaction.selectLine(can), callee = arguments.callee
|
||||
var list = []; for (var i = 0; i < count; i++) { (function() { var line = can.onaction.selectLine(can), text = can.current.text(); list.push(text)
|
||||
can.onaction.selectLine(can, can.onaction.deleteLine(can, line)), can.db.undo.push(function() { can.onaction.insertLine(can, text, line), can.onaction.selectLine(can, line) })
|
||||
})() } can.db._last_text = list, can.db.redo.push(function() { callee(event, can, target, count) })
|
||||
return true
|
||||
}),
|
||||
p: shy("向后粘贴", function(can) { if (!can.db._last_text) { return } var line = can.onaction.selectLine(can), callee = arguments.callee
|
||||
for (var i = can.db._last_text.length-1; i >= 0; i--) { (function() { var line = can.onaction.insertLine(can, can.db._last_text[i], can.current.next())
|
||||
can.db.undo.push(function() { can.onaction.deleteLine(can, line), can.onaction.selectLine(can, line-1) })
|
||||
})() } can.db.redo.push(function() { callee(event, can, target, count) })
|
||||
}),
|
||||
P: shy("向前粘贴", function(can) { if (!can.db._last_text) { return } var line = can.onaction.selectLine(can), callee = arguments.callee
|
||||
for (var i = 0; i < can.db._last_text.length; i++) { (function() { var line = can.onaction.insertLine(can, can.db._last_text[i], can.current.line)
|
||||
can.db.undo.push(function() { can.onaction.deleteLine(can, line), can.onaction.selectLine(can, line+1) })
|
||||
})() } can.db.redo.push(function() { callee(event, can, target, count) })
|
||||
}),
|
||||
J: shy("合并两行", function(can) { var next = can.current.next(); if (!next) { return }
|
||||
var line = can.onaction.selectLine(can), text = can.current.text(), rest = can.onexport.text(can, next)
|
||||
can.ui.current.value = can.current.text(text.trimRight()+(can.base.endWith(text.trim(), "(", "[")||can.base.beginWith(rest.trim(), ",", "]", ")")? "": lex.SP)+rest.trimLeft())
|
||||
can.onkeymap.cursorMove(can.ui.current, text.length, 0), can.onaction.deleteLine(can, next)
|
||||
can.db.undo.push(function() { can.onaction.modifyLine(can, line, text), can.onaction.insertLine(can, rest, line+1) })
|
||||
}),
|
||||
".": shy("重复操作", function(can) { var cb = can.db.redo.pop(); cb && cb() }),
|
||||
u: shy("撤销操作", function(can) { var cb = can.db.undo.pop(); cb && cb() }),
|
||||
|
||||
gg: shy("跳到某行", function(can, count) { return can.onaction.selectLine(can, count), true }),
|
||||
G: shy("跳到某行", function(can, count) { return can.onaction.selectLine(can, count = count>1? count: can.db.max), true }),
|
||||
zt: shy("屏幕最上", function(can, count) { return can.current.scroll(can.current.scroll()-(count>1? count: 3)), true }),
|
||||
zz: shy("屏幕中间", function(can, count) { return can.current.scroll(can.current.scroll()-(count = count>1? count: can.current.window()/2)), true }),
|
||||
zb: shy("屏幕最下", function(can, count) { return can.current.scroll(can.current.scroll()-can.current.window()+(count>1? count: 5)), true }),
|
||||
F5: shy("刷新网页", function(can, target) { can.user.reload(true) }),
|
||||
},
|
||||
normal_ctrl: {
|
||||
e: shy("向上滚屏", function(can) { can.current.scroll(1); if (can.current.scroll()<2) { can.onaction.selectLine(can, can.current.next()) } }),
|
||||
y: shy("向下滚屏", function(can) { can.current.scroll(-1); if (can.current.scroll()>can.current.window()-3) { can.onaction.selectLine(can, can.current.prev()) } }),
|
||||
f: shy("向下翻页", function(can, count) { can.current.scroll(can.current.window()) }),
|
||||
b: shy("向上翻页", function(can, count) { can.current.scroll(-can.current.window()) }),
|
||||
r: shy("刷新页面", function(can) { can.user.reload(true) }),
|
||||
},
|
||||
insert_ctrl: {
|
||||
a: shy("光标行首", function(can, target) { for (var i = 0; i < target.value.length; i++) { if (target.value[i] != lex.TB) { break } } can.onkeymap.cursorMove(target, i, 0), can.onkeymap.prevent(event) }),
|
||||
e: shy("光标行尾", function(can, target) { can.user.isWindows && can.onkeymap.cursorMove(target, 0, -1) }),
|
||||
b: shy("光标左移", function(can, target) { can.user.isWindows && can.onkeymap.cursorMove(target, -1) }),
|
||||
f: shy("光标右移", function(can, target) { can.user.isWindows && can.onkeymap.cursorMove(target, 1) }),
|
||||
d: shy("删除字符", function(can, target) { can.user.isWindows && can.onkeymap.deleteText(target, target.selectionStart, 1) }),
|
||||
},
|
||||
insert: {
|
||||
Escape: shy("退出编辑", function(can) { can.onkeymap._normal(can), can.ui.current._keylist = [] }),
|
||||
ArrowUp: shy("光标上移", function(can, target) { can.onkeymap.cursorUp(can, target) }),
|
||||
ArrowDown: shy("光标下移", function(can, target) { can.onkeymap.cursorDown(can, target) }),
|
||||
Backspace: shy("删除字符", function(event, can, target) { if (target.selectionStart > 0 || !can.current.prev()) { return } can.onkeymap.prevent(event)
|
||||
var rest = can.current.text(); can.onaction.selectLine(can, can.current.prev()), can.onaction.deleteLine(can, can.current.next())
|
||||
var text = can.current.text(); can.ui.current.value = text+rest, can.onkeymap.cursorMove(target, 0, text.length)
|
||||
}),
|
||||
Tab: shy("添加缩进", function(event, can) { can.onkeymap.insertText(can.ui.current, lex.TB), can.onkeymap.prevent(event) }),
|
||||
Enter: shy("插入换行", function(can, target) {
|
||||
var rest = can.onkeymap.deleteText(target, target.selectionEnd).trimLeft(), text = can.ui.current.value
|
||||
var left = text.substr(0, text.indexOf(text.trimLeft()))||(text.trimRight() == ""? text: "")
|
||||
var line = can.onaction.selectLine(can), next = rest; for (var i = line; i < can.db.max; i++) { next += can.onexport.text(can, can.onaction._getLine(can, i)).trimLeft(); if (next != "") { break } }
|
||||
function deep(text) { var deep = 0; for (var i = 0; i < text.length; i++) { if (text[i] == lex.TB) { deep += 4 } else if (text[i] == lex.SP) { deep++ } else { break } } return deep }
|
||||
text.trim() && can.core.List(["{}", "[]", "()", "``"], function(item) { if (can.base.endWith(text, item[0])) {
|
||||
if (can.base.beginWith(next, item[1])) {
|
||||
can.onaction.insertLine(can, left+rest, can.current.next()), rest = ""
|
||||
} else if (deep(text) >= deep(can.onexport.text(can, can.onaction._getLine(can, line+1))) && rest == "") {
|
||||
can.onaction.insertLine(can, left+item[1], can.current.next())
|
||||
} left += lex.TB
|
||||
} else if (can.base.beginWith(rest, item[1])) { left = left.slice(0, -1) }})
|
||||
var line = can.onaction.insertLine(can, left+rest, can.current.next())
|
||||
can.current.text(text.trimRight()||text), can.onaction.selectLine(can, line), can.onkeymap._insert(event, can, 0, left.length)
|
||||
}),
|
||||
},
|
||||
}, _engine: {},
|
||||
})
|
||||
|
||||
gg: shy("跳到某行", function(can, count) { return can.onaction.selectLine(can, count), true }),
|
||||
G: shy("跳到某行", function(can, count) { return can.onaction.selectLine(can, count = count>1? count: can.db.max), true }),
|
||||
zt: shy("屏幕最上", function(can, count) { return can.current.scroll(can.current.scroll()-(count>1? count: 3)), true }),
|
||||
zz: shy("屏幕中间", function(can, count) { return can.current.scroll(can.current.scroll()-(count = count>1? count: can.current.window()/2)), true }),
|
||||
zb: shy("屏幕最下", function(can, count) { return can.current.scroll(can.current.scroll()-can.current.window()+(count>1? count: 5)), true }),
|
||||
F5: shy("刷新网页", function(can, target) { can.user.reload(true) }),
|
||||
},
|
||||
normal_ctrl: {
|
||||
e: shy("向上滚屏", function(can) { can.current.scroll(1); if (can.current.scroll()<2) { can.onaction.selectLine(can, can.current.next()) } }),
|
||||
y: shy("向下滚屏", function(can) { can.current.scroll(-1); if (can.current.scroll()>can.current.window()-3) { can.onaction.selectLine(can, can.current.prev()) } }),
|
||||
f: shy("向下翻页", function(can, count) { can.current.scroll(can.current.window()) }),
|
||||
b: shy("向上翻页", function(can, count) { can.current.scroll(-can.current.window()) }),
|
||||
r: shy("刷新页面", function(can) { can.user.reload(true) }),
|
||||
},
|
||||
insert_ctrl: {
|
||||
a: shy("光标行首", function(can, target) { for (var i = 0; i < target.value.length; i++) { if (target.value[i] != lex.TB) { break } } can.onkeymap.cursorMove(target, i, 0), can.onkeymap.prevent(event) }),
|
||||
e: shy("光标行尾", function(can, target) { can.user.isWindows && can.onkeymap.cursorMove(target, 0, -1) }),
|
||||
b: shy("光标左移", function(can, target) { can.user.isWindows && can.onkeymap.cursorMove(target, -1) }),
|
||||
f: shy("光标右移", function(can, target) { can.user.isWindows && can.onkeymap.cursorMove(target, 1) }),
|
||||
d: shy("删除字符", function(can, target) { can.user.isWindows && can.onkeymap.deleteText(target, target.selectionStart, 1) }),
|
||||
},
|
||||
insert: {
|
||||
Escape: shy("退出编辑", function(can) { can.onkeymap._normal(can), can.ui.current._keylist = [] }),
|
||||
ArrowUp: shy("光标上移", function(can, target) { can.onkeymap.cursorUp(can, target) }),
|
||||
ArrowDown: shy("光标下移", function(can, target) { can.onkeymap.cursorDown(can, target) }),
|
||||
Backspace: shy("删除字符", function(event, can, target) { if (target.selectionStart > 0 || !can.current.prev()) { return } can.onkeymap.prevent(event)
|
||||
var rest = can.current.text(); can.onaction.selectLine(can, can.current.prev()), can.onaction.deleteLine(can, can.current.next())
|
||||
var text = can.current.text(); can.ui.current.value = text+rest, can.onkeymap.cursorMove(target, 0, text.length)
|
||||
}),
|
||||
Tab: shy("添加缩进", function(event, can) { can.onkeymap.insertText(can.ui.current, lex.TB), can.onkeymap.prevent(event) }),
|
||||
Enter: shy("插入换行", function(can, target) {
|
||||
var rest = can.onkeymap.deleteText(target, target.selectionEnd).trimLeft(), text = can.ui.current.value
|
||||
var left = text.substr(0, text.indexOf(text.trimLeft()))||(text.trimRight() == ""? text: "")
|
||||
var line = can.onaction.selectLine(can), next = rest; for (var i = line; i < can.db.max; i++) { next += can.onexport.text(can, can.onaction._getLine(can, i)).trimLeft(); if (next != "") { break } }
|
||||
function deep(text) { var deep = 0; for (var i = 0; i < text.length; i++) { if (text[i] == lex.TB) { deep += 4 } else if (text[i] == lex.SP) { deep++ } else { break } } return deep }
|
||||
text.trim() && can.core.List(["{}", "[]", "()", "``"], function(item) { if (can.base.endWith(text, item[0])) {
|
||||
if (can.base.beginWith(next, item[1])) {
|
||||
can.onaction.insertLine(can, left+rest, can.current.next()), rest = ""
|
||||
} else if (deep(text) >= deep(can.onexport.text(can, can.onaction._getLine(can, line+1))) && rest == "") {
|
||||
can.onaction.insertLine(can, left+item[1], can.current.next())
|
||||
} left += lex.TB
|
||||
} else if (can.base.beginWith(rest, item[1])) { left = left.slice(0, -1) }})
|
||||
var line = can.onaction.insertLine(can, left+rest, can.current.next())
|
||||
can.current.text(text.trimRight()||text), can.onaction.selectLine(can, line), can.onkeymap._insert(event, can, 0, left.length)
|
||||
}),
|
||||
},
|
||||
}, _engine: {},
|
||||
})
|
||||
|
6
proto.js
6
proto.js
@ -32,7 +32,9 @@ var Volcanos = shy({iceberg: "", volcano: "", frame: chat.FRAME_JS, _cache: {},
|
||||
if (libs[0].indexOf(nfs.SRC) == 0 || libs[0].indexOf(nfs.USR) == 0) { libs[0] = nfs.P+libs[0] }
|
||||
if (libs[0][0] != nfs.PS && libs[0].indexOf(web.HTTP) != 0) { libs[0] = can._path.slice(0, can._path.lastIndexOf(ice.PS)+1)+libs[0] }
|
||||
// var name = (libs[0].indexOf(web.HTTP) == 0 || libs[0].indexOf("?pod=") > -1? libs[0]: libs[0].split(ice.QS)[0]).toLowerCase()
|
||||
var name = (libs[0].indexOf(web.HTTP) == 0 || libs[0].indexOf("?pod=") > -1? libs[0]: libs[0]).toLowerCase()
|
||||
// var name = (libs[0].indexOf(web.HTTP) == 0 || libs[0].indexOf("?pod=") > -1? libs[0]: libs[0]).toLowerCase()
|
||||
var name = libs[0].indexOf(web.HTTP) == 0 || libs[0].indexOf("?pod=") > -1? libs[0]: libs[0]
|
||||
if (name.indexOf("pod=") == -1) { name = name.toLowerCase() }
|
||||
function next() { can._load(name, cbs), can.require(libs.slice(1), cb, cbs) }
|
||||
if (name.indexOf("/lib/") == 0) { name = "/v"+name }
|
||||
if (name.indexOf("/panel/") == 0) { name = "/v"+name }
|
||||
@ -139,7 +141,7 @@ try { if (typeof(window) == code.OBJECT) { var meta = Volcanos.meta
|
||||
meta.version = window._version, window.outerWidth-window.innerWidth > 100 && (meta.version = "", debug = false)
|
||||
}
|
||||
meta._load = function(url, cb) {
|
||||
if (meta.version) { url += (url.indexOf(web.QS) == -1? web.QS: "&")+meta.version.slice(1) }
|
||||
if (meta.version && url.indexOf("/p/usr/icons/") == -1) { url += (url.indexOf(web.QS) == -1? web.QS: "&")+meta.version.slice(1) }
|
||||
if (meta._cache[url]) { return meta._cache[url].push(cb) } else { meta._cache[url] = [cb] }
|
||||
function _cb() { meta._cache[url].forEach(function(cb) { cb() }), delete(meta._cache[url]) }
|
||||
switch (url.split(web.QS)[0].split(nfs.PT).pop().toLowerCase()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user