This commit is contained in:
parent
f5ff038910
commit
1ced1982ce
|
@ -28,6 +28,7 @@ type snippet struct {
|
||||||
Contents []string `json:"contents"` // 代码行
|
Contents []string `json:"contents"` // 代码行
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 建立编辑器通道.
|
||||||
func WSHandler(w http.ResponseWriter, r *http.Request) {
|
func WSHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
session, _ := user.Session.Get(r, "wide-session")
|
session, _ := user.Session.Get(r, "wide-session")
|
||||||
sid := session.Values["id"].(string)
|
sid := session.Values["id"].(string)
|
||||||
|
@ -101,8 +102,26 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
session, _ := user.Session.Get(r, "wide-session")
|
session, _ := user.Session.Get(r, "wide-session")
|
||||||
username := session.Values["username"].(string)
|
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)
|
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))
|
line := int(args["cursorLine"].(float64))
|
||||||
ch := int(args["cursorCh"].(float64))
|
ch := int(args["cursorCh"].(float64))
|
||||||
|
|
|
@ -78,7 +78,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
ret := map[string]interface{}{"output": "Notification initialized", "cmd": "init-notification"}
|
ret := map[string]interface{}{"output": "Notification initialized", "cmd": "init-notification"}
|
||||||
wsChan.Conn.WriteJSON(&ret)
|
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))
|
event.InitUserQueue(sid, event.HandleFunc(event2Notification))
|
||||||
|
|
|
@ -249,10 +249,12 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
channelRet := map[string]interface{}{}
|
channelRet := map[string]interface{}{}
|
||||||
channelRet["output"] = string(buf[:count])
|
channelRet["output"] = string(buf[:count])
|
||||||
channelRet["cmd"] = "build"
|
channelRet["cmd"] = "build"
|
||||||
channelRet["nextCmd"] = "run"
|
|
||||||
channelRet["executable"] = executable
|
channelRet["executable"] = executable
|
||||||
|
|
||||||
if 0 == count { // 说明构建成功,没有错误信息输出
|
if 0 == count { // 说明构建成功,没有错误信息输出
|
||||||
|
// 设置下一次执行命令(前端会根据这个发送请求)
|
||||||
|
channelRet["nextCmd"] = "run"
|
||||||
|
|
||||||
go func() { // 运行 go install,生成的库用于 gocode lib-path
|
go func() { // 运行 go install,生成的库用于 gocode lib-path
|
||||||
cmd := exec.Command("go", "install")
|
cmd := exec.Command("go", "install")
|
||||||
cmd.Dir = curDir
|
cmd.Dir = curDir
|
||||||
|
|
|
@ -78,7 +78,9 @@ var editors = {
|
||||||
while (start && word.test(curLine.charAt(start - 1))) {
|
while (start && word.test(curLine.charAt(start - 1))) {
|
||||||
--start;
|
--start;
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = {
|
var request = {
|
||||||
|
path: $(".edit-header .current > span:eq(0)").attr("title"),
|
||||||
code: editor.getValue(),
|
code: editor.getValue(),
|
||||||
cursorLine: cur.line,
|
cursorLine: cur.line,
|
||||||
cursorCh: cur.ch
|
cursorCh: cur.ch
|
||||||
|
@ -269,7 +271,7 @@ var editors = {
|
||||||
"Ctrl-S": function () {
|
"Ctrl-S": function () {
|
||||||
wide.saveFile();
|
wide.saveFile();
|
||||||
},
|
},
|
||||||
"Alt-Shift-F": function () {
|
"Shift-Alt-F": function () {
|
||||||
wide.fmt();
|
wide.fmt();
|
||||||
},
|
},
|
||||||
"Alt-F7": "findUsages"
|
"Alt-F7": "findUsages"
|
||||||
|
|
|
@ -234,7 +234,7 @@ var wide = {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
// TODO: XML/JSON 格式化处理
|
// TODO: XML 格式化处理
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue