This commit is contained in:
Liang Ding 2014-10-11 14:59:38 +08:00
parent 4ceabaa75e
commit 0cf675ce5b
2 changed files with 5 additions and 9 deletions

View File

@ -222,7 +222,7 @@ func RemoveFile(w http.ResponseWriter, r *http.Request) {
} }
// 在目录中搜索包含指定字符串的文件. // 在目录中搜索包含指定字符串的文件.
func Search(w http.ResponseWriter, r *http.Request) { func SearchText(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true} data := map[string]interface{}{"succ": true}
defer util.RetJSON(w, r, data) defer util.RetJSON(w, r, data)
@ -235,16 +235,11 @@ func Search(w http.ResponseWriter, r *http.Request) {
return return
} }
// TODO: 选定目录
dir := args["dir"].(string) dir := args["dir"].(string)
dir = "" extension := args["extension"].(string)
text := args["text"].(string)
_ = dir founds := search(dir, extension, text, []*Snippet{})
founds := []*Snippet{}
usage := &Snippet{Path: "", Line: 1, Ch: 2 /* TODO: 获取附近的代码片段 */}
founds = append(founds, usage)
data["founds"] = founds data["founds"] = founds
} }

View File

@ -189,6 +189,7 @@ func main() {
http.HandleFunc("/file/save", handlerWrapper(file.SaveFile)) http.HandleFunc("/file/save", handlerWrapper(file.SaveFile))
http.HandleFunc("/file/new", handlerWrapper(file.NewFile)) http.HandleFunc("/file/new", handlerWrapper(file.NewFile))
http.HandleFunc("/file/remove", handlerWrapper(file.RemoveFile)) http.HandleFunc("/file/remove", handlerWrapper(file.RemoveFile))
http.HandleFunc("/file/search/text", handlerWrapper(file.SearchText))
// 编辑器 // 编辑器
http.HandleFunc("/editor/ws", handlerWrapper(editor.WSHandler)) http.HandleFunc("/editor/ws", handlerWrapper(editor.WSHandler))