diff --git a/conf/wide.json b/conf/wide.json index a932613..8dcc030 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -21,10 +21,9 @@ "D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg" ], "Files": [ - "D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go", - "D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg\\time.go" + "D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go" ], - "CurrentFile": "D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\pkg\\time.go" + "CurrentFile": "D:\\GoGoGo\\src\\github.com\\b3log\\wide\\data\\user_workspaces\\admin\\src\\mytest\\time\\main.go" } } ] diff --git a/editor/editors.go b/editor/editors.go index 9dc89df..0b46130 100644 --- a/editor/editors.go +++ b/editor/editors.go @@ -356,6 +356,7 @@ func FindUsagesHandler(w http.ResponseWriter, r *http.Request) { ch := int(args["cursorCh"].(float64)) offset := getCursorOffset(code, line, ch) + // glog.Infof("offset [%d]", offset) // TODO: 目前是调用 liteide_stub 工具来查找使用,后续需要重新实现 ide_stub := conf.Wide.GetIDEStub() @@ -391,11 +392,11 @@ func FindUsagesHandler(w http.ResponseWriter, r *http.Request) { cursorLine, _ := strconv.Atoi(found[cursorSep+1 : strings.LastIndex(found, ":")]) cursorCh, _ := strconv.Atoi(found[strings.LastIndex(found, ":")+1:]) - usage := &file.Snippet{Path: path, Line: cursorLine, Ch: cursorCh /* TODO: 获取附近的代码片段 */} + usage := &file.Snippet{Path: path, Line: cursorLine, Ch: cursorCh, Contents: []string{""}} usages = append(usages, usage) } - data["usages"] = usages + data["founds"] = usages } // 计算光标偏移位置. diff --git a/i18n/zh_CN.json b/i18n/zh_CN.json index 3c8662e..2a15381 100644 --- a/i18n/zh_CN.json +++ b/i18n/zh_CN.json @@ -44,5 +44,7 @@ "notification": "通知", "min": "最小化", "restore_side": "左侧窗口还原", + "usages": "查找使用", + "search_text": "查找文本", "restore_bottom": "底部窗口还原" } \ No newline at end of file diff --git a/main.go b/main.go index 0da0d30..62cd886 100644 --- a/main.go +++ b/main.go @@ -149,9 +149,11 @@ func indexHandler(w http.ResponseWriter, r *http.Request) { t.Execute(w, model) } -// favicon.ico 请求处理. -func faviconHandler(w http.ResponseWriter, r *http.Request) { - // TODO: favicon.ico 请求处理 +// 单个文件资源请求处理. +func serveSingle(pattern string, filename string) { + http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, filename) + }) } // 主程序入口. @@ -160,17 +162,17 @@ func main() { defer glog.Flush() - // 静态资源 - http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) - http.HandleFunc("/favicon.ico", handlerWrapper(faviconHandler)) - - // 库资源 - http.Handle("/data/", http.StripPrefix("/data/", http.FileServer(http.Dir("data")))) - // IDE http.HandleFunc("/login", handlerWrapper(loginHandler)) http.HandleFunc("/", handlerWrapper(indexHandler)) + // 静态资源 + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) + serveSingle("/favicon.ico", "./static/favicon.ico") + + // 库资源 + http.Handle("/data/", http.StripPrefix("/data/", http.FileServer(http.Dir("data")))) + // 会话 http.HandleFunc("/session/ws", handlerWrapper(session.WSHandler)) http.HandleFunc("/session/save", handlerWrapper(session.SaveContent)) diff --git a/static/css/login.css b/static/css/login.css index a2a7aff..7aec7fa 100644 --- a/static/css/login.css +++ b/static/css/login.css @@ -3,8 +3,10 @@ width: 980px; } -.header h1 { - margin: 0; +.header .logo { + float: left; + height: 32px; + margin-top: 3px; } .header { diff --git a/static/css/wide.css b/static/css/wide.css index 970e539..1be49dd 100644 --- a/static/css/wide.css +++ b/static/css/wide.css @@ -280,6 +280,31 @@ width: 50px; padding: 0 5px; } + +.bottom-window-group .search li { + cursor: pointer; + line-height: 20px; + padding: 0 3px; + word-wrap: normal; + word-break: normal; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.bottom-window-group .search li.selected { + background-color: #3875d7; + color: #FFF; +} + +.bottom-window-group .search .path { + color: #999; + font-size: 12px; +} + +.bottom-window-group .search li.selected .path { + color: #FFF; +} /* end bottom-window-group */ /* start footer */ diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..73bb45f Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/images/wide-logo.png b/static/images/wide-logo.png new file mode 100644 index 0000000..02463de Binary files /dev/null and b/static/images/wide-logo.png differ diff --git a/static/js/editors.js b/static/js/editors.js index 05b51b5..bbdf980 100644 --- a/static/js/editors.js +++ b/static/js/editors.js @@ -259,38 +259,69 @@ var editors = { return; } - var usagesHTML = ''; - - editors.appendSearch(usagesHTML); + editors.appendSearch(data.founds, 'usages', ''); } }); }; }, - appendSearch: function (html) { - var $usages = $('.bottom-window-group .search'); - if ($usages.find("ul").length === 0) { - wide.usagesTab = new Tabs({ + appendSearch: function (data, type, key) { + var searcHTML = ''; + + var $search = $('.bottom-window-group .search'), + title = config.label.usages; + if (type === "founds") { + title = config.label.search_text; + } + if ($search.find("ul").length === 0) { + wide.searchTab = new Tabs({ id: ".bottom-window-group .search", removeAfter: function (id, prevId) { - if ($usages.find("ul").length === 1) { - $usages.find(".tabs").hide(); + if ($search.find("ul").length === 1) { + $search.find(".tabs").hide(); } } }); - $usages.find(".tabs-panel > div").append(html); - } else if ($usages.find("ul").length === 1) { - $usages.find(".tabs").show(); - wide.usagesTab.add({ - id: "b", - "title": 'Usages of ', - "content": html + 1 + $search.on("click", "li", function () { + $search.find("li").removeClass("selected"); + $(this).addClass("selected"); + }); + + $search.on("dblclick", "li", function () { + var $it = $(this), + tId = tree.getTIdByPath($it.attr("title")); + tree.openFile(tree.fileTree.getNodeByTId(tId)); + tree.fileTree.selectNode(wide.curNode); + + var cursor = CodeMirror.Pos($it.find(".position").data("line") - 1, $it.find(".position").data("ch") - 1); + wide.curEditor.setCursor(cursor); + wide.curEditor.focus(); + }); + + $search.find(".tabs-panel > div").append(searcHTML); + + $search.find(".tabs .first").text(title); + } else { + $search.find(".tabs").show(); + wide.searchTab.add({ + "id": "search" + (new Date()).getTime(), + "title": title, + "content": searcHTML }); } diff --git a/static/js/wide.js b/static/js/wide.js index 77f5845..3435455 100644 --- a/static/js/wide.js +++ b/static/js/wide.js @@ -213,8 +213,8 @@ var wide = { $("#dialogSearchForm").dialog({ "height": 52, "width": 260, - "title": config.label.create_dir, - "okText": config.label.create, + "title": config.label.search, + "okText": config.label.search, "cancelText": config.label.cancel, "afterOpen": function () { $("#dialogSearchForm > input:eq(0)").val('').focus(); @@ -234,16 +234,9 @@ var wide = { if (!data.succ) { return; } - - var searcHTML = ''; - - editors.appendSearch(searcHTML); + + $("#dialogSearchForm").dialog("close"); + editors.appendSearch(data.founds, 'founds', request.text); } }); } diff --git a/view/index.html b/view/index.html index c434ae3..e7c9b87 100644 --- a/view/index.html +++ b/view/index.html @@ -15,6 +15,8 @@ + + @@ -155,12 +157,12 @@
@@ -216,7 +218,10 @@ "tip": "{{.i18n.tip}}", "confirm": "{{.i18n.confirm}}", "build_n_run": "{{.i18n.build_n_run}}", - "stop": "{{.i18n.stop}}" + "stop": "{{.i18n.stop}}", + "usages": "{{.i18n.usages}}", + "search_text": "{{.i18n.search_text}}", + "search": "{{.i18n.search}}" }, "channel": { "editor": '{{.conf.EditorChannel}}', diff --git a/view/login.html b/view/login.html index a4ff680..e6060d4 100644 --- a/view/login.html +++ b/view/login.html @@ -5,11 +5,14 @@ {{.i18n.wide}} - {{.i18n.login}} +
-

Wide

+ +
  • GitHub
  • {{.i18n.help}}
  • diff --git a/view/shell.html b/view/shell.html index 19d9a29..9633b7e 100644 --- a/view/shell.html +++ b/view/shell.html @@ -4,6 +4,8 @@ {{.i18n.wide}} + + @@ -14,12 +16,11 @@ + channel: { + shell: '{{.conf.ShellChannel}}' + }, + wideSessionId: {{.session.Id}} + };