diff --git a/data/user_workspaces/admin/src/mytest/1.go b/data/user_workspaces/admin/src/mytest/1.go new file mode 100644 index 0000000..4900a1b --- /dev/null +++ b/data/user_workspaces/admin/src/mytest/1.go @@ -0,0 +1 @@ +111111111111111111111111111 \ No newline at end of file diff --git a/data/user_workspaces/admin/src/mytest/2.go b/data/user_workspaces/admin/src/mytest/2.go new file mode 100644 index 0000000..d83615b --- /dev/null +++ b/data/user_workspaces/admin/src/mytest/2.go @@ -0,0 +1 @@ +222222222222222222222 \ No newline at end of file diff --git a/static/css/base.css b/static/css/base.css index f613214..32e12c5 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -252,3 +252,11 @@ ul { width: 100%; } /* end output */ + +/* start footer */ +.notification-count { + float: right; + display: none; + cursor: pointer; +} +/* end footer */ diff --git a/static/js/hotkeys.js b/static/js/hotkeys.js index 4ac7488..753610a 100644 --- a/static/js/hotkeys.js +++ b/static/js/hotkeys.js @@ -35,6 +35,20 @@ var hotkeys = { shiftKey: false, which: 54 }, + // Ctrl+Q 关闭当前编辑器 + closeCurEditor: { + ctrlKey: true, + altKey: false, + shiftKey: false, + which: 81 + }, + // Ctrl+D 窗口组切换 + changeEditor: { + ctrlKey: true, + altKey: false, + shiftKey: false, + which: 68 + }, // F6 构建并运行 buildRun: { ctrlKey: false, @@ -196,7 +210,7 @@ var hotkeys = { return; } - + if (event.ctrlKey === hotKeys.goNotification.ctrlKey && event.which === hotKeys.goNotification.which) { // Ctrl+6 焦点切换到通知窗口 wide.bottomWindowTab.setCurrent("notification"); @@ -206,6 +220,69 @@ var hotkeys = { return; } + if (event.ctrlKey === hotKeys.closeCurEditor.ctrlKey + && event.which === hotKeys.closeCurEditor.which) { // Ctrl+Q 关闭当前编辑器 + if (editors.tabs.getCurrentId()) { + editors.tabs.del(editors.tabs.getCurrentId()); + } + event.preventDefault(); + + return; + } + + if (event.ctrlKey === hotKeys.changeEditor.ctrlKey + && event.which === hotKeys.changeEditor.which) { // Ctrl+D 窗口组切换 + if (document.activeElement.className === "notification" + || document.activeElement.className === "output" + || document.activeElement.className === "search") { + // 焦点在底部窗口组时,对底部进行切换 + var tabs = ["output", "search", "notification"], + nextId = ""; + for (var i = 0, ii = tabs.length; i < ii; i++) { + if (document.activeElement.className === tabs[i]) { + if (i < ii - 1) { + nextId = tabs[i + 1]; + } else { + nextId = tabs[0]; + } + break; + } + } + wide.bottomWindowTab.setCurrent(nextId); + $(".bottom-window-group ." + nextId).focus(); + + event.preventDefault(); + + return false; + } + + if (editors.data.length > 1) { + var nextId = ""; + for (var i = 0, ii = editors.data.length; i < ii; i++) { + if (editors.tabs.getCurrentId() === editors.data[i].id) { + if (i < ii - 1) { + nextId = editors.data[i + 1].id; + wide.curEditor = editors.data[i + 1].editor; + } else { + nextId = editors.data[0].id; + wide.curEditor = editors.data[0].editor; + } + break; + } + } + + editors.tabs.setCurrent(nextId); + wide.curNode = tree.fileTree.getNodeByTId(nextId); + tree.fileTree.selectNode(wide.curNode); + + wide.curEditor.focus(); + } + + event.preventDefault(); + + return false; + } + if (event.which === hotKeys.buildRun.which) { // F6 构建并运行 wide.run(); event.preventDefault(); diff --git a/static/js/notification.js b/static/js/notification.js index 2bb6f80..96fb8b8 100644 --- a/static/js/notification.js +++ b/static/js/notification.js @@ -1,28 +1,36 @@ -var notificationWS = new WebSocket(config.channel.shell + '/notification/ws?sid=' + config.wideSessionId); -notificationWS.onopen = function() { - console.log('[notification onopen] connected'); -}; -notificationWS.onmessage = function(e) { - console.log('[notification onmessage]' + e.data); - var data = JSON.parse(e.data); - if ('init-notification' !== data.cmd) { - $('.bottom-window-group .notification').val(data.output); - } -}; -notificationWS.onclose = function(e) { - console.log('[notification onclose] disconnected (' + e.code + ')'); - delete notificationWS; -}; -notificationWS.onerror = function(e) { - console.log('[notification onerror] ' + e); -}; - var notification = { init: function() { - - } -}; + $(".notification-count").click(function() { + wide.bottomWindowTab.setCurrent("notification"); + $(".bottom-window-group .notification").focus(); + $(this).hide(); + }); -$(document).ready(function() { - notification.init(); -}); \ No newline at end of file + this._initWS(); + }, + _initWS: function() { + var notificationWS = new WebSocket(config.channel.shell + '/notification/ws?sid=' + config.wideSessionId); + + notificationWS.onopen = function() { + console.log('[notification onopen] connected'); + }; + + notificationWS.onmessage = function(e) { + var data = JSON.parse(e.data); + if ('init-notification' !== data.cmd) { + $(".notification-count").show(); + $('.bottom-window-group .notification').text( + $('.bottom-window-group .notification').text() + data.output); + } + }; + + notificationWS.onclose = function(e) { + console.log('[notification onclose] disconnected (' + e.code + ')'); + delete notificationWS; + }; + + notificationWS.onerror = function(e) { + console.log('[notification onerror] ' + e); + }; + } +}; \ No newline at end of file diff --git a/static/js/tabs.js b/static/js/tabs.js index 070a8e7..9d5066c 100644 --- a/static/js/tabs.js +++ b/static/js/tabs.js @@ -14,7 +14,9 @@ $.extend(Tabs.prototype, { obj._$tabs.on("click", "div", function(event) { var id = $(this).data("index"); _that.setCurrent(id); - obj.clickAfter(id); + if (typeof (obj.clickAfter) === "function") { + obj.clickAfter(id); + } }); obj._$tabs.on("click", ".ico-close", function(event) { @@ -54,7 +56,7 @@ $.extend(Tabs.prototype, { } else { prevId = this.obj._prevId; } - + this.obj.removeAfter(id, prevId); this.setCurrent(prevId); }, diff --git a/static/js/tree.js b/static/js/tree.js index 9af1139..d83da23 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -252,6 +252,7 @@ var tree = { editors.tabs.setCurrent(treeNode.tId); wide.curNode = treeNode; wide.curEditor = editors.data[i].editor; + wide.curEditor.focus(); return false; } } diff --git a/static/js/wide.js b/static/js/wide.js index e1643e6..9204f92 100644 --- a/static/js/wide.js +++ b/static/js/wide.js @@ -74,7 +74,10 @@ var wide = { }, _initBottomWindowGroup: function() { this.bottomWindowTab = new Tabs({ - id: ".bottom-window-group" + id: ".bottom-window-group", + clickAfter: function(id) { + this._$tabsPanel.find("." + id).focus(); + } }); }, init: function() { @@ -241,4 +244,5 @@ $(document).ready(function() { tree.init(); menu.init(); hotkeys.init(); + notification.init(); }); \ No newline at end of file diff --git a/view/index.html b/view/index.html index d8e2bfb..a33dbd5 100644 --- a/view/index.html +++ b/view/index.html @@ -163,6 +163,7 @@