保存所有文件,关闭所有文件
This commit is contained in:
parent
bf505af3a8
commit
3e720d8179
|
@ -5,7 +5,6 @@
|
|||
"OutputChannel": "ws://{IP}:7070",
|
||||
"ShellChannel": "ws://{IP}:7070",
|
||||
"SessionChannel": "ws://{IP}:7070",
|
||||
"HTTPSessionMaxAge": 86400,
|
||||
"StaticResourceVersion": "201409032040",
|
||||
"MaxProcs": 4,
|
||||
"RuntimeMode": "dev",
|
||||
|
@ -17,13 +16,12 @@
|
|||
"Workspace": "{pwd}/data/user_workspaces/admin",
|
||||
"LatestSessionContent": {
|
||||
"FileTree": [
|
||||
"/home/daniel/gogogo/src/github.com/b3log/wide/data/user_workspaces/admin/src/mytest",
|
||||
"/home/daniel/gogogo/src/github.com/b3log/wide/data/user_workspaces/admin/src/mytest/time"
|
||||
"E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest",
|
||||
"E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time",
|
||||
"E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg"
|
||||
],
|
||||
"Files": [
|
||||
"/home/daniel/gogogo/src/github.com/b3log/wide/data/user_workspaces/admin/src/mytest/time/main.go"
|
||||
],
|
||||
"CurrentFile": "/home/daniel/gogogo/src/github.com/b3log/wide/data/user_workspaces/admin/src/mytest/time/main.go"
|
||||
"Files": [],
|
||||
"CurrentFile": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
"delete": "删除",
|
||||
"save": "保存",
|
||||
"exit": "退出",
|
||||
"close_file": "关闭文件",
|
||||
"close_all_files": "关闭所有文件",
|
||||
"save_all_files": "保存所有文件",
|
||||
"format": "格式化",
|
||||
|
|
|
@ -146,13 +146,13 @@
|
|||
float: left;
|
||||
}
|
||||
|
||||
.menu > ul > li > a,
|
||||
.menu > ul > li > span {
|
||||
color: #000;
|
||||
font-size: 12px;
|
||||
line-height: 24px;
|
||||
padding: 5px;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
/* end menu */
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ var editors = {
|
|||
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
||||
if (editors.data[i].id === id) {
|
||||
editors.data.splice(i, 1);
|
||||
wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -388,7 +389,7 @@ var editors = {
|
|||
wide.saveAllFiles();
|
||||
},
|
||||
"Shift-Alt-F": function () {
|
||||
wide.fmt();
|
||||
wide.fmt(editors.getCurrentPath(), wide.curEditor);
|
||||
},
|
||||
"Alt-F7": "findUsages"
|
||||
}
|
||||
|
|
|
@ -398,20 +398,26 @@ var wide = {
|
|||
},
|
||||
saveFile: function () {
|
||||
// 格式化后会对文件进行保存
|
||||
this.fmt();
|
||||
this.fmt(editors.getCurrentPath(), wide.curEditor);
|
||||
},
|
||||
saveAllFiles: function () {
|
||||
// TODO: save all open files
|
||||
// TODO: 需要全部保存的接口
|
||||
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
||||
|
||||
this.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
|
||||
}
|
||||
console.log("TODO: save all files");
|
||||
},
|
||||
closeFile: function () {
|
||||
// TODO: close file
|
||||
},
|
||||
closeAllFiles: function () {
|
||||
// TODO: close all files
|
||||
this.saveAllFiles();
|
||||
editors.data = [];
|
||||
tree.fileTree.cancelSelectedNode();
|
||||
wide.curNode = undefined;
|
||||
wide.curEditor = undefined;
|
||||
$(".toolbars").hide();
|
||||
|
||||
$(".edit-panel .tabs, .edit-panel .tabs-panel").html('');
|
||||
},
|
||||
exit: function () {
|
||||
// TODO: exit
|
||||
|
@ -497,15 +503,14 @@ var wide = {
|
|||
}
|
||||
});
|
||||
},
|
||||
fmt: function () {
|
||||
var path = editors.getCurrentPath();
|
||||
var mode = wide.curEditor.getOption("mode");
|
||||
fmt: function (path, curEditor) {
|
||||
var mode = curEditor.getOption("mode");
|
||||
|
||||
var request = newWideRequest();
|
||||
request.file = path;
|
||||
request.code = wide.curEditor.getValue();
|
||||
request.cursorLine = wide.curEditor.getCursor().line;
|
||||
request.cursorCh = wide.curEditor.getCursor().ch;
|
||||
request.code = curEditor.getValue();
|
||||
request.cursorLine = curEditor.getCursor().line;
|
||||
request.cursorCh = curEditor.getCursor().ch;
|
||||
|
||||
switch (mode) {
|
||||
case "text/x-go": // 会保存文件
|
||||
|
@ -516,7 +521,7 @@ var wide = {
|
|||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.succ) {
|
||||
wide.curEditor.setValue(data.code);
|
||||
curEditor.setValue(data.code);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -530,7 +535,7 @@ var wide = {
|
|||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.succ) {
|
||||
wide.curEditor.setValue(data.code);
|
||||
curEditor.setValue(data.code);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -539,14 +544,13 @@ var wide = {
|
|||
case "application/json":
|
||||
try {
|
||||
// 在客户端浏览器中进行 JSON 格式化
|
||||
var json = JSON.parse(wide.curEditor.getValue());
|
||||
wide.curEditor.setValue(JSON.stringify(json, "", " "));
|
||||
var json = JSON.parse(curEditor.getValue());
|
||||
curEditor.setValue(JSON.stringify(json, "", " "));
|
||||
|
||||
wide._save();
|
||||
} catch (e) {
|
||||
delete e;
|
||||
}
|
||||
|
||||
break;
|
||||
default :
|
||||
// TODO: XML 格式化处理
|
||||
|
|
|
@ -26,16 +26,9 @@
|
|||
<span>{{.i18n.file}}</span>
|
||||
<div class="frame">
|
||||
<ul>
|
||||
<li onclick="wide.saveFile()">
|
||||
<span>{{.i18n.save}}</span>
|
||||
</li>
|
||||
<li onclick="wide.saveAllFiles()">
|
||||
<span>{{.i18n.save_all_files}}</span>
|
||||
</li>
|
||||
<li class="hr"></li>
|
||||
<li onclick="wide.closeFile()">
|
||||
<span>{{.i18n.close_file}}</span>
|
||||
</li>
|
||||
<li onclick="wide.closeAllFiles()">
|
||||
<span>{{.i18n.close_all_files}}</span>
|
||||
</li>
|
||||
|
@ -132,7 +125,7 @@
|
|||
<div class="toolbars fn-none">
|
||||
<span onclick="wide.run()" class="font-ico ico-buildrun" title="{{.i18n.build_n_run}}"></span>
|
||||
<span onclick="wide.saveFile()" title="{{.i18n.save}}" class="font-ico ico-save"></span>
|
||||
<span onclick="wide.fmt()" class="ico-format font-ico" title="{{.i18n.format}}"></span>
|
||||
<span onclick="wide.fmt(editors.getCurrentPath(), wide.curEditor)" class="ico-format font-ico" title="{{.i18n.format}}"></span>
|
||||
<span class="font-ico ico-max" onclick="windows.maxEditor()" title="{{.i18n.max_editor}}"></span>
|
||||
</div>
|
||||
<div class="tabs"></div>
|
||||
|
|
Loading…
Reference in New Issue