文件树快捷键
This commit is contained in:
parent
1be309b08a
commit
5e5d13965a
|
@ -27,6 +27,7 @@
|
|||
<li>Ctrl+0:焦点切换到编辑器</li>
|
||||
<li>Ctrl+W:关闭当前编辑器</li>
|
||||
<li>Ctrl+4:焦点切换到 Output</li>
|
||||
<li>Alt+Shift+F:格式化</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -191,7 +191,7 @@ func FindDeclarationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
ch := int(args["cursorCh"].(float64))
|
||||
|
||||
offset := getCursorOffset(code, line, ch)
|
||||
glog.Infof("offset [%d]", offset)
|
||||
// glog.Infof("offset [%d]", offset)
|
||||
|
||||
// TODO: 目前是调用 liteide_stub 工具来查找声明,后续需要重新实现
|
||||
argv := []string{"type", "-cursor", filename + ":" + strconv.Itoa(offset), "-def", "."}
|
||||
|
@ -221,8 +221,6 @@ func FindDeclarationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
cursorLine := found[cursorSep+1 : strings.LastIndex(found, ":")]
|
||||
cursorCh := found[strings.LastIndex(found, ":")+1:]
|
||||
|
||||
glog.Infof("Find Decl [path: %s, cursor(%s:%s)]", path, cursorLine, cursorCh)
|
||||
|
||||
data["path"] = path
|
||||
data["cursorLine"] = cursorLine
|
||||
data["cursorCh"] = cursorCh
|
||||
|
|
|
@ -63,6 +63,7 @@ var editors = {
|
|||
},
|
||||
fullscreen: function() {
|
||||
wide.curEditor.setOption("fullScreen", true);
|
||||
wide.curEditor.focus();
|
||||
},
|
||||
_initAutocomplete: function() {
|
||||
CodeMirror.registerHelper("hint", "go", function(editor) {
|
||||
|
@ -274,7 +275,6 @@ var editors = {
|
|||
|
||||
$("#footer-cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
|
||||
// TODO: 关闭 tab 的时候要重置
|
||||
// TODO: 保存当前编辑器光标位置,切换 tab 的时候要设置回来
|
||||
});
|
||||
|
||||
editor.setSize('100%', $(".edit-panel").height() - $(".edit-header").height());
|
||||
|
|
|
@ -205,13 +205,6 @@ var tree = {
|
|||
},
|
||||
_onClick: function(treeNode) {
|
||||
if (wide.curNode) {
|
||||
var id = wide.curNode.tId;
|
||||
if (id === treeNode.tId) {
|
||||
// 再次点击当前选中节点
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
||||
// 该节点文件已经打开
|
||||
if (editors.data[i].id === treeNode.tId) {
|
||||
|
|
|
@ -88,6 +88,8 @@ var wide = {
|
|||
menu.subMenu();
|
||||
}
|
||||
});
|
||||
|
||||
this._bindKey();
|
||||
},
|
||||
saveFile: function () {
|
||||
var request = {
|
||||
|
@ -224,8 +226,46 @@ var wide = {
|
|||
// TODO: XML/JSON 格式化处理
|
||||
break;
|
||||
}
|
||||
},
|
||||
_bindKey: function () {
|
||||
$("#files").keydown(function (event) {
|
||||
if (!wide.curNode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (event.which) {
|
||||
case 13: // 回车
|
||||
if (wide.curNode.iconSkin === "ico-ztree-dir ") { // 选中节点是目录
|
||||
// 不做任何处理
|
||||
return false;
|
||||
}
|
||||
|
||||
// 模拟点击:打开文件
|
||||
tree._onClick(wide.curNode);
|
||||
|
||||
break;
|
||||
case 38: // 上
|
||||
tree.fileTree.selectNode(wide.curNode.getPreNode());
|
||||
wide.curNode = wide.curNode.getPreNode();
|
||||
$("#files").focus();
|
||||
break;
|
||||
case 40: // 下
|
||||
// TODO: 处理滚动条,递归获取下一个
|
||||
tree.fileTree.selectNode(wide.curNode.getNextNode());
|
||||
wide.curNode = wide.curNode.getNextNode();
|
||||
$("#files").focus();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).keydown(function (event) {
|
||||
if (event.ctrlKey && event.which === 49) { // Ctrl+1 焦点切换到文件树
|
||||
|
||||
// 有些元素需设置 tabindex 为 -1 时才可以 focus
|
||||
$("#files").focus();
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
<div class="content">
|
||||
<div class="side">
|
||||
<div class="side-1">
|
||||
<ul id="files" class="ztree"></ul>
|
||||
<ul id="files" tabindex="-1" class="ztree"></ul>
|
||||
|
||||
<!-- 目录右键菜单 -->
|
||||
<div id="dirRMenu" class="frame">
|
||||
|
|
Loading…
Reference in New Issue