Ctrl 0,1,4,5,6

This commit is contained in:
Van 2014-09-17 10:10:26 +08:00
parent 004c0a67a7
commit 5b81e7ec1d
5 changed files with 65 additions and 15 deletions

View File

@ -245,8 +245,7 @@ ul {
cursor: pointer;
}
#output,
#notification {
.bottom-window-group textarea {
border-width: 0;
color: #555555;
height: 130px;

View File

@ -1,5 +1,12 @@
var hotkeys = {
defaultKeyMap: {
// Ctrl+0 焦点切换到当前编辑器
goEditor: {
ctrlKey: true,
altKey: false,
shiftKey: false,
which: 48
},
// Ctrl+1 焦点切换到文件树
goFileTree: {
ctrlKey: true,
@ -14,6 +21,20 @@ var hotkeys = {
shiftKey: false,
which: 52
},
// Ctrl+5 焦点切换到搜索窗口
goSearch: {
ctrlKey: true,
altKey: false,
shiftKey: false,
which: 53
},
// Ctrl+6 焦点切换到通知窗口
goNotification: {
ctrlKey: true,
altKey: false,
shiftKey: false,
which: 54
},
// F6 构建并运行
buildRun: {
ctrlKey: false,
@ -140,6 +161,16 @@ var hotkeys = {
var hotKeys = this.defaultKeyMap;
$(document).keydown(function(event) {
if (event.ctrlKey === hotKeys.goEditor.ctrlKey
&& event.which === hotKeys.goEditor.which) { // Ctrl+0 焦点切换到当前编辑器
if (wide.curEditor) {
wide.curEditor.focus();
}
event.preventDefault();
return;
}
if (event.ctrlKey === hotKeys.goFileTree.ctrlKey
&& event.which === hotKeys.goFileTree.which) { // Ctrl+1 焦点切换到文件树
// 有些元素需设置 tabindex 为 -1 时才可以 focus
@ -150,8 +181,26 @@ var hotkeys = {
}
if (event.ctrlKey === hotKeys.goOutPut.ctrlKey
&& event.which === hotKeys.goOutPut.which) { // Ctrl+4 焦点切换到输出窗口
$("#output").focus();
&& event.which === hotKeys.goOutPut.which) { // Ctrl+4 焦点切换到输出窗口
wide.bottomWindowTab.setCurrent("output");
$(".bottom-window-group .output").focus();
event.preventDefault();
return;
}
if (event.ctrlKey === hotKeys.goSearch.ctrlKey
&& event.which === hotKeys.goSearch.which) { // Ctrl+5 焦点切换到搜索窗口
wide.bottomWindowTab.setCurrent("search");
$(".bottom-window-group .search").focus();
event.preventDefault();
return;
}
if (event.ctrlKey === hotKeys.goNotification.ctrlKey
&& event.which === hotKeys.goNotification.which) { // Ctrl+6 焦点切换到通知窗口
wide.bottomWindowTab.setCurrent("notification");
$(".bottom-window-group .notification").focus();
event.preventDefault();
return;

View File

@ -6,7 +6,7 @@ notificationWS.onmessage = function(e) {
console.log('[notification onmessage]' + e.data);
var data = JSON.parse(e.data);
if ('init-notification' !== data.cmd) {
$('#notification').val(data.output);
$('.bottom-window-group .notification').val(data.output);
}
};
notificationWS.onclose = function(e) {

View File

@ -22,7 +22,7 @@ outputWS.onmessage = function(e) {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function(data) {
$('#output').text('');
$('.bottom-window-group .output').text('');
},
success: function(data) {
@ -31,11 +31,11 @@ outputWS.onmessage = function(e) {
}
if ('run' === data.cmd) { // 正在运行
$('#output').text($('#output').text() + data.output);
$('.bottom-window-group .output').text($('.bottom-window-group .output').text() + data.output);
} else if ('run-done' === data.cmd) { // 运行结束
// TODO: 运行结束后修改 [构建&运行] 图标状态为可用状态
} else if ('build' === data.cmd || 'go install' === data.cmd) {
$('#output').text(data.output);
$('.bottom-window-group .output').text(data.output);
if (0 !== data.output.length) { // 说明编译有错误输出
for (var i = 0; i < data.lints.length; i++) {
@ -52,7 +52,7 @@ outputWS.onmessage = function(e) {
// 触发一次 gutter lint
CodeMirror.signal(wide.curEditor, "change", wide.curEditor);
} else if ('go get' === data.cmd || 'go install' === data.cmd) {
$('#output').text($('#output').text() + data.output);
$('.bottom-window-group .output').text($('.bottom-window-group .output').text() + data.output);
}
};
outputWS.onclose = function(e) {
@ -66,6 +66,7 @@ outputWS.onerror = function(e) {
var wide = {
curNode: undefined,
curEditor: undefined,
bottomWindowTab: undefined,
_initLayout: function() {
var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 2;
$(".content, .ztree").height(mainH);
@ -73,7 +74,7 @@ var wide = {
$(".edit-panel").height(mainH - $(".bottom-window-group").height());
},
_initBottomWindowGroup: function() {
new Tabs({
this.bottomWindowTab = new Tabs({
id: ".bottom-window-group"
});
},
@ -140,7 +141,7 @@ var wide = {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function(data) {
$('#output').text('');
$('.bottom-window-group .output').text('');
},
success: function(data) {
}
@ -157,7 +158,7 @@ var wide = {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function(data) {
$('#output').text('');
$('.bottom-window-group .output').text('');
},
success: function(data) {
}
@ -175,7 +176,7 @@ var wide = {
data: JSON.stringify(request),
dataType: "json",
beforeSend: function(data) {
$('#output').text('');
$('.bottom-window-group .output').text('');
},
success: function(data) {
}

View File

@ -147,12 +147,13 @@
</div>
<div class="tabs-panel">
<div data-index="output">
<textarea id="output"></textarea>
<textarea class="output"></textarea>
</div>
<div class="fn-none" data-index="search">
<div class="search" tabindex="-1"></div>
</div>
<div class="fn-none" data-index="notification">
<textarea id="notification"></textarea>
<textarea class="notification"></textarea>
</div>
</div>
</div>