切换,关闭,打开 tab,底部行列修改 & rename 时全选

This commit is contained in:
Van 2014-11-17 18:08:03 +08:00
parent 31ef718244
commit 8375ae1130
3 changed files with 23 additions and 10 deletions

View File

@ -110,6 +110,7 @@ var editors = {
id: ".edit-panel", id: ".edit-panel",
clickAfter: function (id) { clickAfter: function (id) {
if (id === 'startPage') { if (id === 'startPage') {
$(".footer .cursor").text('');
return false; return false;
} }
@ -125,8 +126,11 @@ var editors = {
} }
} }
wide.curEditor.setCursor(wide.curEditor.getCursor()); var cursor = wide.curEditor.getCursor();
wide.curEditor.setCursor(cursor);
wide.curEditor.focus(); wide.curEditor.focus();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
}, },
removeBefore: function (id) { removeBefore: function (id) {
if (id === 'startPage') { // 当前关闭的 tab 是起始页 if (id === 'startPage') { // 当前关闭的 tab 是起始页
@ -134,7 +138,6 @@ var editors = {
return true; return true;
} }
// 移除编辑器
for (var i = 0, ii = editors.data.length; i < ii; i++) { for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === id) { if (editors.data[i].id === id) {
if (editors.data[i].editor.doc.isClean()) { if (editors.data[i].editor.doc.isClean()) {
@ -180,6 +183,7 @@ var editors = {
tree.fileTree.cancelSelectedNode(); tree.fileTree.cancelSelectedNode();
wide.curNode = undefined; wide.curNode = undefined;
wide.curEditor = undefined; wide.curEditor = undefined;
$(".footer .cursor").text('');
return false; return false;
} }
@ -199,6 +203,9 @@ var editors = {
break; break;
} }
} }
var cursor = wide.curEditor.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
} }
}); });
@ -570,6 +577,8 @@ var editors = {
cursor = CodeMirror.Pos(data.cursorLine - 1, data.cursorCh - 1); 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++) { for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === id) { if (editors.data[i].id === id) {
editors.tabs.setCurrent(id); editors.tabs.setCurrent(id);
@ -583,7 +592,6 @@ var editors = {
editor.scrollTo(0, cursorCoords.top); editor.scrollTo(0, cursorCoords.top);
editor.focus(); editor.focus();
return false; return false;
} }
} }
@ -770,7 +778,6 @@ var editors = {
var cursor = cm.getCursor(); var cursor = cm.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |'); $(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
// TODO: 关闭 tab 的时候要重置
}); });
editor.on('focus', function (cm) { editor.on('focus', function (cm) {

View File

@ -250,6 +250,9 @@ var tree = {
wide.curNode = treeNode; wide.curNode = treeNode;
wide.curEditor = editors.data[i].editor; wide.curEditor = editors.data[i].editor;
wide.curEditor.focus(); wide.curEditor.focus();
var cursor = wide.curEditor.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
return false; return false;
} }
} }

View File

@ -106,10 +106,13 @@ var wide = {
"okText": config.label.rename, "okText": config.label.rename,
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function () { "afterOpen": function () {
var index = wide.curNode.name.lastIndexOf("."); var index = wide.curNode.name.lastIndexOf("."),
$("#dialogRenamePrompt > input").val(wide.curNode.name.substring(0, index)).focus(); name = wide.curNode.name.substring(0, index);
// TODO: 全选 if (index === -1) {
name = wide.curNode.name;
}
$("#dialogRenamePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true); $("#dialogRenamePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true);
$("#dialogRenamePrompt > input").val(name).select().focus();
}, },
"ok": function () { "ok": function () {
var name = $("#dialogRenamePrompt > input").val(), var name = $("#dialogRenamePrompt > input").val(),