This commit is contained in:
Van 2014-11-18 10:29:08 +08:00
parent 97a6b1b69f
commit 1b60c8712e
4 changed files with 43 additions and 48 deletions

View File

@ -27,9 +27,20 @@
"LineHeight": "17px"
},
"LatestSessionContent": {
"FileTree": [],
"Files": [],
"CurrentFile": ""
"FileTree": [
"E:\\Work\\go\\src",
"E:\\Work\\go\\src\\code.google.com\\p",
"E:\\Work\\go\\src\\code.google.com\\p\\go.net",
"E:\\Work\\go\\src\\github.com",
"E:\\Work\\go\\src\\github.com\\88250",
"E:\\Work\\go\\src\\github.com\\88250\\gohtml"
],
"Files": [
"E:\\Work\\go\\src\\github.com\\88250\\gohtml\\consts.go",
"E:\\Work\\go\\src\\github.com\\88250\\gohtml\\doc.go",
"E:\\Work\\go\\src\\github.com\\88250\\gohtml\\formatter.go"
],
"CurrentFile": "E:\\Work\\go\\src\\github.com\\88250\\gohtml\\formatter.go"
}
}
]

View File

@ -371,10 +371,10 @@ var editors = {
});
CodeMirror.commands.autocompleteAfterDot = function (cm) {
var token = cm.getTokenAt(cm.getCursor());
if ("comment" === token.type) {
return;
}
var token = cm.getTokenAt(cm.getCursor());
if ("comment" === token.type) {
return;
}
setTimeout(function () {
if (!cm.state.completionActive) {
@ -448,6 +448,7 @@ var editors = {
var request = newWideRequest();
request.path = data.path;
// TODO: refactor
$.ajax({
type: 'POST',
url: '/file',
@ -466,7 +467,7 @@ var editors = {
data.cursorLine = cursorLine;
data.cursorCh = cursorCh;
editors.newEditor(data);
tree.openFile(wide.curNode);
}
});
}
@ -577,30 +578,6 @@ var editors = {
$(".toolbars").show();
var id = wide.curNode.tId;
var cursor = CodeMirror.Pos(0, 0);
if (data.cursorLine && data.cursorCh) {
cursor = CodeMirror.Pos(data.cursorLine - 1, data.cursorCh - 1);
}
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === id) {
editors.tabs.setCurrent(id);
wide.curEditor = editors.data[i].editor;
var editor = wide.curEditor;
editor.setCursor(cursor);
var half = Math.floor(editor.getScrollInfo().clientHeight / editor.defaultTextHeight() / 2);
var cursorCoords = editor.cursorCoords({line: cursor.line - half, ch: 0}, "local");
editor.scrollTo(0, cursorCoords.top);
editor.focus();
return false;
}
}
editors.tabs.add({
id: id,
title: '<span title="' + wide.curNode.path + '"><span class="'
@ -610,9 +587,6 @@ var editors = {
menu.undisabled(['save-all', 'close-all', 'build', 'run', 'go-test', 'go-get', 'go-install']);
var rulers = [];
rulers.push({color: "#ccc", column: 120, lineStyle: "dashed"});
var textArea = document.getElementById("editor" + id);
textArea.value = data.content;
@ -622,7 +596,7 @@ var editors = {
autoCloseBrackets: true,
matchBrackets: true,
highlightSelectionMatches: {showToken: /\w/},
rulers: rulers,
rulers: [{color: "#ccc", column: 120, lineStyle: "dashed"}],
styleActiveLine: true,
theme: 'wide',
indentUnit: 4,
@ -825,16 +799,18 @@ var editors = {
editor.setOption("autoCloseTags", true);
}
editor.setCursor(cursor);
var half = Math.floor(editor.getScrollInfo().clientHeight / editor.defaultTextHeight() / 2);
var cursorCoords = editor.cursorCoords({line: cursor.line - half, ch: 0}, "local");
editor.scrollTo(0, cursorCoords.top);
wide.curEditor = editor;
editors.data.push({
"editor": editor,
"id": id
});
var cursor = CodeMirror.Pos(0, 0);
if (data.cursorLine && data.cursorCh) {
cursor = CodeMirror.Pos(data.cursorLine - 1, data.cursorCh - 1);
}
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
editor.setCursor(cursor);
editor.focus();
}
};

View File

@ -249,12 +249,17 @@ var tree = {
// 该节点文件已经打开
if (editors.data[i].id === treeNode.tId) {
editors.tabs.setCurrent(treeNode.tId);
wide.curNode = treeNode;
wide.curEditor = editors.data[i].editor;
wide.curEditor.focus();
var cursor = wide.curEditor.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
wide.curEditor.setCursor(cursor);
var half = Math.floor(wide.curEditor.getScrollInfo().clientHeight / wide.curEditor.defaultTextHeight() / 2);
var cursorCoords = wide.curEditor.cursorCoords({line: cursor.line - half, ch: 0}, "local");
wide.curEditor.scrollTo(0, cursorCoords.top);
wide.curEditor.focus();
return false;
}
}
@ -288,7 +293,7 @@ var tree = {
}
},
_initSearch: function () {
$("#dialogSearchForm > input:eq(0)").keyup(function (event) {
$("#dialogSearchForm > input:eq(0)").keyup(function (event) {
var $okBtn = $(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");
if (event.which === 13 && !$okBtn.prop("disabled")) {
$okBtn.click();

View File

@ -262,6 +262,7 @@ var wide = {
$("#dialogGoFilePrompt").on("dblclick", "li", function () {
var tId = tree.getTIdByPath($(this).find(".ft-small").text());
tree.openFile(tree.fileTree.getNodeByTId(tId));
tree.fileTree.selectNode(wide.curNode);
$("#dialogGoFilePrompt").dialog("close");
});
@ -275,6 +276,7 @@ var wide = {
hotkeys.bindList($("#dialogGoFilePrompt > input"), $("#dialogGoFilePrompt > .list"), function ($selected) {
var tId = tree.getTIdByPath($selected.find(".ft-small").text());
tree.openFile(tree.fileTree.getNodeByTId(tId));
tree.fileTree.selectNode(wide.curNode);
$("#dialogGoFilePrompt").dialog("close");
});
@ -330,6 +332,7 @@ var wide = {
"ok": function () {
var tId = tree.getTIdByPath($("#dialogGoFilePrompt .selected .ft-small").text());
tree.openFile(tree.fileTree.getNodeByTId(tId));
tree.fileTree.selectNode(wide.curNode);
$("#dialogGoFilePrompt").dialog("close");
}
});