build run stop

This commit is contained in:
Van 2014-09-24 12:07:20 +08:00
parent 97fbc16370
commit b2a531629b
9 changed files with 151 additions and 118 deletions

View File

@ -21,17 +21,16 @@
"E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\hello", "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\hello",
"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",
"E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg", "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg",
"D:\\go\\src\\pkg",
"D:\\go\\src\\pkg\\archive", "D:\\go\\src\\pkg\\archive",
"D:\\go\\src\\pkg\\archive\\tar", "D:\\go\\src\\pkg\\archive\\tar",
"D:\\go\\src\\pkg\\archive\\tar\\testdata" "D:\\go\\src\\pkg\\archive\\tar\\testdata"
], ],
"files": [ "files": [
"E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\1123", "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg\\time.go",
"E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\123\\q.exe", "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go"
"E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\hello\\2.json",
"D:\\go\\src\\pkg\\archive\\tar\\testdata\\small.txt"
], ],
"currentFile": "D:\\go\\src\\pkg\\archive\\tar\\testdata\\small.txt" "currentFile": "E:\\Work\\go\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go"
} }
} }
] ]

View File

@ -71,10 +71,14 @@ ul {
content: "\e60b"; content: "\e60b";
} }
.icon-buildrun:before { .ico-buildrun:before {
content: "\e607"; content: "\e607";
} }
.ico-stop:before {
content: "\e608";
}
.ico-close { .ico-close {
color: #666; color: #666;
} }

Binary file not shown.

View File

@ -15,6 +15,7 @@
<glyph unicode="&#xe605;" d="M96 416l320-192-320-192z" /> <glyph unicode="&#xe605;" d="M96 416l320-192-320-192z" />
<glyph unicode="&#xe606;" d="M360.704 429.209c-29.209 21.069-65.843 31.591-109.978 31.591-33.587 0-61.901-7.424-84.915-22.221-36.531-23.194-55.936-62.566-58.291-118.118h84.633c0 16.179 4.71 31.769 14.157 46.771s25.472 22.502 48.077 22.502c22.963 0 38.81-6.093 47.462-18.253 8.678-12.211 13.005-25.702 13.005-40.499 0-12.877-6.451-24.653-14.233-35.379-4.275-6.247-9.933-11.981-16.921-17.255 0 0-45.901-29.44-66.073-53.095-11.699-13.722-12.749-34.253-13.773-63.719-0.077-2.099 0.717-6.425 8.064-6.425s59.315 0 65.843 0 7.885 4.839 7.987 6.963c0.461 10.726 1.664 16.205 3.635 22.4 3.712 11.699 13.747 21.913 25.063 30.695l23.296 16.077c21.017 16.384 37.811 29.824 45.209 40.371 12.647 17.357 21.529 38.707 21.529 64.025 0 41.344-14.618 72.525-43.776 93.568zM249.369 104.345c-29.184 0.87-53.248-19.303-54.169-50.944-0.922-31.616 21.965-52.505 51.149-53.376 30.464-0.896 53.888 18.637 54.81 50.253 0.896 31.642-21.325 53.171-51.789 54.067z" /> <glyph unicode="&#xe606;" d="M360.704 429.209c-29.209 21.069-65.843 31.591-109.978 31.591-33.587 0-61.901-7.424-84.915-22.221-36.531-23.194-55.936-62.566-58.291-118.118h84.633c0 16.179 4.71 31.769 14.157 46.771s25.472 22.502 48.077 22.502c22.963 0 38.81-6.093 47.462-18.253 8.678-12.211 13.005-25.702 13.005-40.499 0-12.877-6.451-24.653-14.233-35.379-4.275-6.247-9.933-11.981-16.921-17.255 0 0-45.901-29.44-66.073-53.095-11.699-13.722-12.749-34.253-13.773-63.719-0.077-2.099 0.717-6.425 8.064-6.425s59.315 0 65.843 0 7.885 4.839 7.987 6.963c0.461 10.726 1.664 16.205 3.635 22.4 3.712 11.699 13.747 21.913 25.063 30.695l23.296 16.077c21.017 16.384 37.811 29.824 45.209 40.371 12.647 17.357 21.529 38.707 21.529 64.025 0 41.344-14.618 72.525-43.776 93.568zM249.369 104.345c-29.184 0.87-53.248-19.303-54.169-50.944-0.922-31.616 21.965-52.505 51.149-53.376 30.464-0.896 53.888 18.637 54.81 50.253 0.896 31.642-21.325 53.171-51.789 54.067z" />
<glyph unicode="&#xe607;" d="M80.231 310.016c23.91 18.56 43.725 5.786 70.169-24.832 2.995-3.43 6.989 0.589 9.242 2.56 2.253 1.997 37.171 33.382 38.861 34.841 1.715 1.51 3.763 4.327 1.049 7.475s-12.647 16-19.021 24.32c-46.285 60.544 126.618 101.607 100.045 102.247-13.491 0.358-67.738 0.973-75.827 0.128-32.845-3.481-74.087-34.176-94.848-48.461-27.136-18.662-37.299-29.491-38.963-31.001-7.68-6.733-1.229-22.195-15.155-34.406-14.72-12.902-23.885-3.149-32.41-10.624-4.25-3.738-16.051-12.57-19.456-15.565-3.379-2.969-3.994-8.013-0.538-12.058 0 0 32.333-35.737 35.072-38.886 2.714-3.149 10.009-5.811 14.541-1.817 4.531 3.968 16.154 14.183 18.125 15.923 1.997 1.715-1.28 22.093 9.114 30.157zM226.381 296.807c-3.072 3.558-6.861 3.635-10.163 0.717l-36.736-32.025c-2.867-2.56-3.251-7.271-0.666-10.24l212.327-241.613c4.941-5.735 13.543-6.323 19.251-1.357l24.858 20.787c5.658 4.966 6.247 13.671 1.305 19.379l-210.176 244.352zM509.491 399.642c-1.894 12.647-8.448 9.984-11.853 4.608-3.353-5.351-18.457-28.186-24.653-38.502-6.144-10.291-21.248-30.489-49.51-10.547-29.389 20.787-19.149 35.303-14.055 45.056 5.146 9.805 20.941 37.248 23.245 40.704 2.253 3.456-0.409 13.491-9.498 9.293-9.139-4.224-64.589-26.265-72.295-57.856-7.859-32.179 6.605-60.903-21.76-89.447l-34.355-35.84 34.509-40.141 42.342 40.218c10.112 10.137 31.642 19.994 51.149 15.565 41.805-9.472 64.589 6.247 78.361 32.179 12.339 23.219 10.291 72.064 8.371 84.71zM70.144 49.894c-5.325-5.376-5.325-14.080 0-19.43l24.346-23.808c5.325-5.351 13.773-3.098 19.097 2.253l125.619 123.52-38.502 43.853-130.56-126.387z" /> <glyph unicode="&#xe607;" d="M80.231 310.016c23.91 18.56 43.725 5.786 70.169-24.832 2.995-3.43 6.989 0.589 9.242 2.56 2.253 1.997 37.171 33.382 38.861 34.841 1.715 1.51 3.763 4.327 1.049 7.475s-12.647 16-19.021 24.32c-46.285 60.544 126.618 101.607 100.045 102.247-13.491 0.358-67.738 0.973-75.827 0.128-32.845-3.481-74.087-34.176-94.848-48.461-27.136-18.662-37.299-29.491-38.963-31.001-7.68-6.733-1.229-22.195-15.155-34.406-14.72-12.902-23.885-3.149-32.41-10.624-4.25-3.738-16.051-12.57-19.456-15.565-3.379-2.969-3.994-8.013-0.538-12.058 0 0 32.333-35.737 35.072-38.886 2.714-3.149 10.009-5.811 14.541-1.817 4.531 3.968 16.154 14.183 18.125 15.923 1.997 1.715-1.28 22.093 9.114 30.157zM226.381 296.807c-3.072 3.558-6.861 3.635-10.163 0.717l-36.736-32.025c-2.867-2.56-3.251-7.271-0.666-10.24l212.327-241.613c4.941-5.735 13.543-6.323 19.251-1.357l24.858 20.787c5.658 4.966 6.247 13.671 1.305 19.379l-210.176 244.352zM509.491 399.642c-1.894 12.647-8.448 9.984-11.853 4.608-3.353-5.351-18.457-28.186-24.653-38.502-6.144-10.291-21.248-30.489-49.51-10.547-29.389 20.787-19.149 35.303-14.055 45.056 5.146 9.805 20.941 37.248 23.245 40.704 2.253 3.456-0.409 13.491-9.498 9.293-9.139-4.224-64.589-26.265-72.295-57.856-7.859-32.179 6.605-60.903-21.76-89.447l-34.355-35.84 34.509-40.141 42.342 40.218c10.112 10.137 31.642 19.994 51.149 15.565 41.805-9.472 64.589 6.247 78.361 32.179 12.339 23.219 10.291 72.064 8.371 84.71zM70.144 49.894c-5.325-5.376-5.325-14.080 0-19.43l24.346-23.808c5.325-5.351 13.773-3.098 19.097 2.253l125.619 123.52-38.502 43.853-130.56-126.387z" />
<glyph unicode="&#xe608;" d="M64 416h384v-384h-384z" />
<glyph unicode="&#xe609;" d="M181.861 118.974l20.649 28.908-22.627 22.628-28.909-20.648c-5.361 2.997-11.102 5.387-17.133 7.096l-5.841 35.042h-32l-5.84-35.043c-6.031-1.709-11.772-4.099-17.133-7.096l-28.909 20.649-22.628-22.628 20.649-28.908c-2.997-5.36-5.387-11.103-7.096-17.133l-35.043-5.841v-32l35.043-5.841c1.709-6.030 4.099-11.772 7.096-17.133l-20.649-28.908 22.627-22.628 28.909 20.648c5.361-2.997 11.102-5.387 17.133-7.096l5.841-35.042h32l5.84 35.043c6.031 1.709 11.772 4.099 17.133 7.096l28.909-20.648 22.627 22.628-20.649 28.908c2.997 5.36 5.387 11.103 7.096 17.133l35.044 5.84v32l-35.043 5.841c-1.709 6.030-4.099 11.772-7.096 17.133zM112 48c-17.674 0-32 14.327-32 32s14.326 32 32 32 32-14.327 32-32-14.326-32-32-32zM512 288v32l-33.691 6.125c-0.621 4.023-1.416 7.989-2.362 11.895l28.779 18.55-12.246 29.564-33.472-7.234c-2.107 3.455-4.363 6.81-6.746 10.065l19.503 28.171-22.628 22.627-28.171-19.503c-3.256 2.383-6.61 4.638-10.065 6.747l7.234 33.472-29.564 12.247-18.55-28.779c-3.906 0.946-7.872 1.741-11.895 2.362l-6.126 33.691h-32l-6.126-33.691c-4.023-0.621-7.988-1.416-11.895-2.362l-18.549 28.779-29.564-12.246 7.234-33.472c-3.455-2.108-6.81-4.364-10.065-6.747l-28.171 19.503-22.627-22.627 19.503-28.171c-2.383-3.255-4.639-6.61-6.747-10.065l-33.472 7.234-12.246-29.564 28.779-18.55c-0.946-3.906-1.741-7.871-2.362-11.895l-33.692-6.126v-32l33.691-6.125c0.621-4.023 1.416-7.989 2.362-11.895l-28.779-18.55 12.246-29.564 33.472 7.234c2.108-3.455 4.364-6.809 6.747-10.065l-19.503-28.171 22.627-22.628 28.171 19.503c3.255-2.383 6.61-4.638 10.065-6.746l-7.234-33.472 29.564-12.246 18.551 28.779c3.905-0.946 7.871-1.741 11.894-2.362l6.126-33.692h32l6.126 33.691c4.022 0.621 7.988 1.416 11.895 2.362l18.55-28.779 29.564 12.246-7.234 33.472c3.455 2.108 6.81 4.363 10.065 6.746l28.171-19.503 22.628 22.628-19.503 28.171c2.383 3.256 4.638 6.61 6.746 10.065l33.472-7.234 12.246 29.565-28.779 18.55c0.946 3.906 1.741 7.871 2.362 11.895l33.691 6.125zM336 234.4c-38.439 0-69.6 31.161-69.6 69.6s31.16 69.6 69.6 69.6 69.6-31.161 69.6-69.6c0-38.439-31.16-69.6-69.6-69.6z" /> <glyph unicode="&#xe609;" d="M181.861 118.974l20.649 28.908-22.627 22.628-28.909-20.648c-5.361 2.997-11.102 5.387-17.133 7.096l-5.841 35.042h-32l-5.84-35.043c-6.031-1.709-11.772-4.099-17.133-7.096l-28.909 20.649-22.628-22.628 20.649-28.908c-2.997-5.36-5.387-11.103-7.096-17.133l-35.043-5.841v-32l35.043-5.841c1.709-6.030 4.099-11.772 7.096-17.133l-20.649-28.908 22.627-22.628 28.909 20.648c5.361-2.997 11.102-5.387 17.133-7.096l5.841-35.042h32l5.84 35.043c6.031 1.709 11.772 4.099 17.133 7.096l28.909-20.648 22.627 22.628-20.649 28.908c2.997 5.36 5.387 11.103 7.096 17.133l35.044 5.84v32l-35.043 5.841c-1.709 6.030-4.099 11.772-7.096 17.133zM112 48c-17.674 0-32 14.327-32 32s14.326 32 32 32 32-14.327 32-32-14.326-32-32-32zM512 288v32l-33.691 6.125c-0.621 4.023-1.416 7.989-2.362 11.895l28.779 18.55-12.246 29.564-33.472-7.234c-2.107 3.455-4.363 6.81-6.746 10.065l19.503 28.171-22.628 22.627-28.171-19.503c-3.256 2.383-6.61 4.638-10.065 6.747l7.234 33.472-29.564 12.247-18.55-28.779c-3.906 0.946-7.872 1.741-11.895 2.362l-6.126 33.691h-32l-6.126-33.691c-4.023-0.621-7.988-1.416-11.895-2.362l-18.549 28.779-29.564-12.246 7.234-33.472c-3.455-2.108-6.81-4.364-10.065-6.747l-28.171 19.503-22.627-22.627 19.503-28.171c-2.383-3.255-4.639-6.61-6.747-10.065l-33.472 7.234-12.246-29.564 28.779-18.55c-0.946-3.906-1.741-7.871-2.362-11.895l-33.692-6.126v-32l33.691-6.125c0.621-4.023 1.416-7.989 2.362-11.895l-28.779-18.55 12.246-29.564 33.472 7.234c2.108-3.455 4.364-6.809 6.747-10.065l-19.503-28.171 22.627-22.628 28.171 19.503c3.255-2.383 6.61-4.638 10.065-6.746l-7.234-33.472 29.564-12.246 18.551 28.779c3.905-0.946 7.871-1.741 11.894-2.362l6.126-33.692h32l6.126 33.691c4.022 0.621 7.988 1.416 11.895 2.362l18.55-28.779 29.564 12.246-7.234 33.472c3.455 2.108 6.81 4.363 10.065 6.746l28.171-19.503 22.628 22.628-19.503 28.171c2.383 3.256 4.638 6.61 6.746 10.065l33.472-7.234 12.246 29.565-28.779 18.55c0.946 3.906 1.741 7.871 2.362 11.895l33.691 6.125zM336 234.4c-38.439 0-69.6 31.161-69.6 69.6s31.16 69.6 69.6 69.6 69.6-31.161 69.6-69.6c0-38.439-31.16-69.6-69.6-69.6z" />
<glyph unicode="&#xe60a;" d="M367.334 149.709l-70.605 80.691 70.605 80.691c12.007 12.007 12.007 31.463 0 43.443s-31.462 11.981-43.443 0l-67.891-77.593-67.865 77.568c-12.006 12.006-31.463 12.006-43.443 0s-11.981-31.463 0-43.443l70.579-80.666-70.605-80.691c-11.981-12.007-11.981-31.411 0-43.392 12.006-12.007 31.463-12.007 43.443 0l67.891 77.543 67.865-77.543c12.007-12.007 31.462-12.007 43.443 0s12.007 31.385 0.026 43.392z" /> <glyph unicode="&#xe60a;" d="M367.334 149.709l-70.605 80.691 70.605 80.691c12.007 12.007 12.007 31.463 0 43.443s-31.462 11.981-43.443 0l-67.891-77.593-67.865 77.568c-12.006 12.006-31.463 12.006-43.443 0s-11.981-31.463 0-43.443l70.579-80.666-70.605-80.691c-11.981-12.007-11.981-31.411 0-43.392 12.006-12.007 31.463-12.007 43.443 0l67.891 77.543 67.865-77.543c12.007-12.007 31.462-12.007 43.443 0s12.007 31.385 0.026 43.392z" />
<glyph unicode="&#xe60b;" d="M224 82.745l-102.627 118.627 29.254 29.255 73.373-57.372 137.372 121.372 29.256-29.254zM415.886 416c0.039-0.033 0.081-0.075 0.114-0.115v-383.771c-0.033-0.039-0.075-0.081-0.114-0.114h-319.772c-0.040 0.033-0.081 0.075-0.114 0.114v383.772c0.033 0.040 0.075 0.081 0.115 0.114h-64.115v-384c0-35.2 28.8-64 64-64h320c35.2 0 64 28.8 64 64v384h-64.114zM320 416v32c0 17.673-14.327 32-32 32h-64c-17.673 0-32-14.327-32-32v-32h-64v-64h256v64h-64zM288 416h-64v32h64v-32z" /> <glyph unicode="&#xe60b;" d="M224 82.745l-102.627 118.627 29.254 29.255 73.373-57.372 137.372 121.372 29.256-29.254zM415.886 416c0.039-0.033 0.081-0.075 0.114-0.115v-383.771c-0.033-0.039-0.075-0.081-0.114-0.114h-319.772c-0.040 0.033-0.081 0.075-0.114 0.114v383.772c0.033 0.040 0.075 0.081 0.115 0.114h-64.115v-384c0-35.2 28.8-64 64-64h320c35.2 0 64 28.8 64 64v384h-64.114zM320 416v32c0 17.673-14.327 32-32 32h-64c-17.673 0-32-14.327-32-32v-32h-64v-64h256v64h-64zM288 416h-64v32h64v-32z" />

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Binary file not shown.

View File

@ -35,7 +35,7 @@ var editors = {
wide.curNode = undefined; wide.curNode = undefined;
wide.curEditor = undefined; wide.curEditor = undefined;
$(".ico-fullscreen").hide(); $(".toolbars").hide();
return false; return false;
} }
@ -207,7 +207,7 @@ var editors = {
}, },
// 新建一个编辑器 Tab如果已经存在 Tab 则切换到该 Tab. // 新建一个编辑器 Tab如果已经存在 Tab 则切换到该 Tab.
newEditor: function (data) { newEditor: function (data) {
$(".ico-fullscreen").show(); $(".toolbars").show();
var id = wide.curNode.tId; var id = wide.curNode.tId;
// 光标位置 // 光标位置

View File

@ -1,93 +1,29 @@
var outputWS = new WebSocket(config.channel.output + '/output/ws?sid=' + config.wideSessionId);
outputWS.onopen = function() {
console.log('[output onopen] connected');
};
outputWS.onmessage = function(e) {
console.log('[output onmessage]' + e.data);
var data = JSON.parse(e.data);
if (goLintFound) {
goLintFound = [];
}
if ('run' === data.nextCmd) {
var request = newWideRequest();
request.executable = data.executable;
$.ajax({
type: 'POST',
url: '/run',
data: JSON.stringify(request),
dataType: "json",
beforeSend: function(data) {
$('.bottom-window-group .output').text('');
},
success: function(data) {
}
});
}
if ('run' === data.cmd) { // 正在运行
$('.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) {
$('.bottom-window-group .output').text(data.output);
if (0 !== data.output.length) { // 说明编译有错误输出
for (var i = 0; i < data.lints.length; i++) {
var lint = data.lints[i];
goLintFound.push({from: CodeMirror.Pos(lint.lineNo, 0),
to: CodeMirror.Pos(lint.lineNo, 0),
message: lint.msg, severity: lint.severity});
}
// TODO: 修改 [构建&运行] 图标状态为可用状态
}
// 触发一次 gutter lint
CodeMirror.signal(wide.curEditor, "change", wide.curEditor);
} else if ('go get' === data.cmd || 'go install' === data.cmd) {
$('.bottom-window-group .output').text($('.bottom-window-group .output').text() + data.output);
}
};
outputWS.onclose = function(e) {
console.log('[output onclose] disconnected (' + e.code + ')');
delete outputWS;
};
outputWS.onerror = function(e) {
console.log('[output onerror] ' + e);
};
var wide = { var wide = {
curNode: undefined, curNode: undefined,
curEditor: undefined, curEditor: undefined,
bottomWindowTab: undefined, bottomWindowTab: undefined,
_initDialog: function() { _initDialog: function () {
$("#dialogAlert").dialog({ $("#dialogAlert").dialog({
"height": 26, "height": 26,
"width": 260, "width": 260,
"title": config.label.tip, "title": config.label.tip,
"hiddenOk": true, "hiddenOk": true,
"cancelText": config.label.confirm, "cancelText": config.label.confirm,
"afterOpen": function(msg) { "afterOpen": function (msg) {
$("#dialogAlert").html(msg); $("#dialogAlert").html(msg);
} }
}); });
$("#dialogRemoveConfirm").dialog({ $("#dialogRemoveConfirm").dialog({
"height": 26, "height": 26,
"width": 260, "width": 260,
"title": config.label.delete, "title": config.label.delete,
"okText": config.label.delete, "okText": config.label.delete,
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function() { "afterOpen": function () {
$("#dialogRemoveConfirm > b").html('"' + wide.curNode.name + '"'); $("#dialogRemoveConfirm > b").html('"' + wide.curNode.name + '"');
}, },
"ok": function() { "ok": function () {
var request = newWideRequest(); var request = newWideRequest();
request.path = wide.curNode.path; request.path = wide.curNode.path;
@ -96,7 +32,7 @@ var wide = {
url: '/file/remove', url: '/file/remove',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function(data) { success: function (data) {
if (!data.succ) { if (!data.succ) {
return false; return false;
} }
@ -126,9 +62,9 @@ var wide = {
} }
}); });
$(".dialog-prompt > input").keydown(function(event) { $(".dialog-prompt > input").keydown(function (event) {
$(".dialog-prompt > .tip").text(''); $(".dialog-prompt > .tip").text('');
if (event.which === 13) { if (event.which === 13) {
$(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)").click(); $(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)").click();
} }
@ -140,10 +76,10 @@ var wide = {
"title": config.label.create_file, "title": config.label.create_file,
"okText": config.label.create, "okText": config.label.create,
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function() { "afterOpen": function () {
$("#dialogNewFilePrompt > input").val('').focus(); $("#dialogNewFilePrompt > input").val('').focus();
}, },
"ok": function() { "ok": function () {
var request = newWideRequest(), var request = newWideRequest(),
name = $("#dialogNewFilePrompt > input").val(); name = $("#dialogNewFilePrompt > input").val();
if ($.trim(name) === "") { if ($.trim(name) === "") {
@ -159,7 +95,7 @@ var wide = {
url: '/file/new', url: '/file/new',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function(data) { success: function (data) {
if (!data.succ) { if (!data.succ) {
return false; return false;
} }
@ -216,10 +152,10 @@ var wide = {
"title": config.label.create_dir, "title": config.label.create_dir,
"okText": config.label.create, "okText": config.label.create,
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function() { "afterOpen": function () {
$("#dialogNewDirPrompt > input").val('').focus(); $("#dialogNewDirPrompt > input").val('').focus();
}, },
"ok": function() { "ok": function () {
var name = $("#dialogNewDirPrompt > input").val(), var name = $("#dialogNewDirPrompt > input").val(),
request = newWideRequest(); request = newWideRequest();
if ($.trim(name) === "") { if ($.trim(name) === "") {
@ -234,7 +170,7 @@ var wide = {
url: '/file/new', url: '/file/new',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function(data) { success: function (data) {
if (!data.succ) { if (!data.succ) {
return false; return false;
} }
@ -257,10 +193,10 @@ var wide = {
"title": config.label.goto_line, "title": config.label.goto_line,
"okText": config.label.goto, "okText": config.label.goto,
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function() { "afterOpen": function () {
$("#dialogGoLinePrompt > input").val('').focus(); $("#dialogGoLinePrompt > input").val('').focus();
}, },
"ok": function() { "ok": function () {
var line = parseInt($("#dialogGoLinePrompt > input").val()); var line = parseInt($("#dialogGoLinePrompt > input").val());
if ($.trim(line) === "") { if ($.trim(line) === "") {
$("#dialogGoLinePrompt > .tip").text(config.label.input_no_empty); $("#dialogGoLinePrompt > .tip").text(config.label.input_no_empty);
@ -272,26 +208,93 @@ var wide = {
} }
}); });
}, },
_initLayout: function() { _initLayout: function () {
var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 2; var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 2;
$(".content, .ztree").height(mainH); $(".content, .ztree").height(mainH);
$(".edit-panel").height(mainH - $(".bottom-window-group").height()); $(".edit-panel").height(mainH - $(".bottom-window-group").height());
}, },
_initBottomWindowGroup: function() { _initBottomWindowGroup: function () {
this.bottomWindowTab = new Tabs({ this.bottomWindowTab = new Tabs({
id: ".bottom-window-group", id: ".bottom-window-group",
clickAfter: function(id) { clickAfter: function (id) {
this._$tabsPanel.find("." + id).focus(); this._$tabsPanel.find("." + id).focus();
} }
}); });
}, },
init: function() { _initWS: function () {
var outputWS = new WebSocket(config.channel.output + '/output/ws?sid=' + config.wideSessionId);
outputWS.onopen = function () {
console.log('[output onopen] connected');
};
outputWS.onmessage = function (e) {
console.log('[output onmessage]' + e.data);
var data = JSON.parse(e.data);
if (goLintFound) {
goLintFound = [];
}
if ('run' === data.nextCmd) {
var request = newWideRequest();
request.executable = data.executable;
$.ajax({
type: 'POST',
url: '/run',
data: JSON.stringify(request),
dataType: "json",
beforeSend: function (data) {
$('.bottom-window-group .output').text('');
},
success: function (data) {
}
});
}
if ('run' === data.cmd) { // 正在运行
$('.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) {
$('.bottom-window-group .output').text(data.output);
if (0 !== data.output.length) { // 说明编译有错误输出
for (var i = 0; i < data.lints.length; i++) {
var lint = data.lints[i];
goLintFound.push({from: CodeMirror.Pos(lint.lineNo, 0),
to: CodeMirror.Pos(lint.lineNo, 0),
message: lint.msg, severity: lint.severity});
}
// TODO: 修改 [构建&运行] 图标状态为可用状态
}
// 触发一次 gutter lint
CodeMirror.signal(wide.curEditor, "change", wide.curEditor);
} else if ('go get' === data.cmd || 'go install' === data.cmd) {
$('.bottom-window-group .output').text($('.bottom-window-group .output').text() + data.output);
}
};
outputWS.onclose = function (e) {
console.log('[output onclose] disconnected (' + e.code + ')');
delete outputWS;
};
outputWS.onerror = function (e) {
console.log('[output onerror] ' + e);
};
},
init: function () {
this._initWS();
this._initLayout(); this._initLayout();
this._initBottomWindowGroup(); this._initBottomWindowGroup();
$("body").bind("mousedown", function(event) { $("body").bind("mousedown", function (event) {
if (!(event.target.id === "dirRMenu" || $(event.target).closest("#dirRMenu").length > 0)) { if (!(event.target.id === "dirRMenu" || $(event.target).closest("#dirRMenu").length > 0)) {
$("#dirRMenu").hide(); $("#dirRMenu").hide();
} }
@ -309,7 +312,7 @@ var wide = {
this._initDialog(); this._initDialog();
}, },
_save: function() { _save: function () {
var request = newWideRequest(); var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title"); request.file = $(".edit-header .current span:eq(0)").attr("title");
request.code = wide.curEditor.getValue(); request.code = wide.curEditor.getValue();
@ -319,51 +322,77 @@ var wide = {
url: '/file/save', url: '/file/save',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function(data) { success: function (data) {
} }
}); });
}, },
saveFile: function() { saveFile: function () {
// 格式化后会对文件进行保存 // 格式化后会对文件进行保存
this.fmt(); this.fmt();
}, },
saveAllFiles: function() { saveAllFiles: function () {
// TODO: save all open files // TODO: save all open files
for (var i = 0, ii = editors.data.length; i < ii; i++) { for (var i = 0, ii = editors.data.length; i < ii; i++) {
} }
console.log("TODO: save all files"); console.log("TODO: save all files");
}, },
closeFile: function() { closeFile: function () {
// TODO: close file // TODO: close file
}, },
closeAllFiles: function() { closeAllFiles: function () {
// TODO: close all files // TODO: close all files
}, },
exit: function() { exit: function () {
// TODO: exit // TODO: exit
}, },
stop: function () {
if ($(".toolbars .ico-buildrun").length === 1) {
wide.run();
return false;
}
var request = newWideRequest();
request.pid = 0;
$.ajax({
type: 'POST',
url: '/stop',
data: JSON.stringify(request),
dataType: "json",
beforeSend: function (data) {
$('.bottom-window-group .output').text('');
},
success: function (data) {
$(".toolbars .ico-stop").removeClass("ico-stop").addClass("ico-buildrun");
}
});
},
// 构建 & 运行. // 构建 & 运行.
run: function() { run: function () {
if ($(".toolbars .ico-stop").length === 1) {
wide.stop();
return false;
}
var request = newWideRequest(); var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title"); request.file = $(".edit-header .current span:eq(0)").attr("title");
request.code = wide.curEditor.getValue(); request.code = wide.curEditor.getValue();
// TODO: 修改 [构建&运行] 图标状态为不可用状态
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/build', url: '/build',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function(data) { beforeSend: function (data) {
$('.bottom-window-group .output').text(''); $('.bottom-window-group .output').text('');
}, },
success: function(data) { success: function (data) {
$(".toolbars .ico-buildrun").addClass("ico-stop").removeClass("ico-buildrun");
} }
}); });
}, },
goget: function() { goget: function () {
var request = newWideRequest(); var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title"); request.file = $(".edit-header .current span:eq(0)").attr("title");
@ -372,14 +401,14 @@ var wide = {
url: '/go/get', url: '/go/get',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function(data) { beforeSend: function (data) {
$('.bottom-window-group .output').text(''); $('.bottom-window-group .output').text('');
}, },
success: function(data) { success: function (data) {
} }
}); });
}, },
goinstall: function() { goinstall: function () {
var request = newWideRequest(); var request = newWideRequest();
request.file = $(".edit-header .current span:eq(0)").attr("title"); request.file = $(".edit-header .current span:eq(0)").attr("title");
request.code = wide.curEditor.getValue(); request.code = wide.curEditor.getValue();
@ -389,14 +418,14 @@ var wide = {
url: '/go/install', url: '/go/install',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function(data) { beforeSend: function (data) {
$('.bottom-window-group .output').text(''); $('.bottom-window-group .output').text('');
}, },
success: function(data) { success: function (data) {
} }
}); });
}, },
fmt: function() { fmt: function () {
var path = $(".edit-header .current span:eq(0)").attr("title"); var path = $(".edit-header .current span:eq(0)").attr("title");
var mode = wide.curEditor.getOption("mode"); var mode = wide.curEditor.getOption("mode");
@ -413,7 +442,7 @@ var wide = {
url: '/go/fmt', url: '/go/fmt',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function(data) { success: function (data) {
if (data.succ) { if (data.succ) {
wide.curEditor.setValue(data.code); wide.curEditor.setValue(data.code);
} }
@ -427,7 +456,7 @@ var wide = {
url: '/html/fmt', url: '/html/fmt',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function(data) { success: function (data) {
if (data.succ) { if (data.succ) {
wide.curEditor.setValue(data.code); wide.curEditor.setValue(data.code);
} }
@ -456,7 +485,7 @@ var wide = {
} }
}; };
$(document).ready(function() { $(document).ready(function () {
wide.init(); wide.init();
tree.init(); tree.init();
menu.init(); menu.init();

View File

@ -95,11 +95,11 @@
</li> </li>
</ul> </ul>
<div class="toolbars fn-right"> <div class="toolbars fn-right fn-none">
<span onclick="wide.run()" class="font-ico icon-buildrun" title="{{.i18n.build_n_run}}"></span> <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.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()" class="ico-format font-ico" title="{{.i18n.format}}"></span>
<span class="fn-none font-ico ico-fullscreen" onclick="editors.fullscreen()" title="{{.i18n.full_screen}}"></span> <span class="font-ico ico-fullscreen" onclick="editors.fullscreen()" title="{{.i18n.full_screen}}"></span>
</div> </div>
</div> </div>