This commit is contained in:
Liang Ding 2014-09-16 22:39:22 +08:00
parent f5ff038910
commit 1ced1982ce
5 changed files with 28 additions and 5 deletions

View File

@ -28,6 +28,7 @@ type snippet struct {
Contents []string `json:"contents"` // 代码行
}
// 建立编辑器通道.
func WSHandler(w http.ResponseWriter, r *http.Request) {
session, _ := user.Session.Get(r, "wide-session")
sid := session.Values["id"].(string)
@ -101,8 +102,26 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
session, _ := user.Session.Get(r, "wide-session")
username := session.Values["username"].(string)
path := args["path"].(string)
fout, err := os.Create(path)
if nil != err {
glog.Error(err)
http.Error(w, err.Error(), 500)
return
}
code := args["code"].(string)
// TODO: 保存文件
fout.WriteString(code)
if err := fout.Close(); nil != err {
glog.Error(err)
http.Error(w, err.Error(), 500)
return
}
line := int(args["cursorLine"].(float64))
ch := int(args["cursorCh"].(float64))

View File

@ -78,7 +78,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
ret := map[string]interface{}{"output": "Notification initialized", "cmd": "init-notification"}
wsChan.Conn.WriteJSON(&ret)
glog.Infof("Open a new [Notification] with session [%s], %d", sid, len(notificationWSs))
glog.V(4).Infof("Open a new [Notification] with session [%s], %d", sid, len(notificationWSs))
// 初始化用户事件队列
event.InitUserQueue(sid, event.HandleFunc(event2Notification))

View File

@ -249,10 +249,12 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
channelRet := map[string]interface{}{}
channelRet["output"] = string(buf[:count])
channelRet["cmd"] = "build"
channelRet["nextCmd"] = "run"
channelRet["executable"] = executable
if 0 == count { // 说明构建成功,没有错误信息输出
// 设置下一次执行命令(前端会根据这个发送请求)
channelRet["nextCmd"] = "run"
go func() { // 运行 go install生成的库用于 gocode lib-path
cmd := exec.Command("go", "install")
cmd.Dir = curDir

View File

@ -78,7 +78,9 @@ var editors = {
while (start && word.test(curLine.charAt(start - 1))) {
--start;
}
var request = {
path: $(".edit-header .current > span:eq(0)").attr("title"),
code: editor.getValue(),
cursorLine: cur.line,
cursorCh: cur.ch
@ -269,7 +271,7 @@ var editors = {
"Ctrl-S": function () {
wide.saveFile();
},
"Alt-Shift-F": function () {
"Shift-Alt-F": function () {
wide.fmt();
},
"Alt-F7": "findUsages"

View File

@ -234,7 +234,7 @@ var wide = {
break;
default :
// TODO: XML/JSON 格式化处理
// TODO: XML 格式化处理
break;
}
}