diff --git a/i18n/zh_CN.json b/i18n/zh_CN.json index cea06b1..8d9f60d 100644 --- a/i18n/zh_CN.json +++ b/i18n/zh_CN.json @@ -28,6 +28,7 @@ "goget": "go get", "goinstall": "go install", "build_n_run": "构建 & 运行", + "editor": "编辑器", "max_editor": "编辑器窗口最大化", "restore_editor": "编辑器窗口还原", "unread_notification": "未读通知", @@ -48,9 +49,10 @@ "restore_bottom": "底部窗口还原", "file_format": "文件后缀", "keyword": "关键字", - "initialise": "初始化", + "start_page": "起始页", "user_guide": "用户指南", "dev_guide": "开发指南", + "keyboard_shortcuts": "键盘快捷键", "ver": "版本", "current_ver": "当前版本", "dev_team": "开发团队", @@ -60,5 +62,27 @@ "workspace": "工作空间", "project_address": "项目地址", "community": "社区", + "autocomplete": "自动补全", + "jump_to_decl": "跳转到声明", + "show_expr_info": "查看表达式信息", + "find_usages": "查找使用", + "format": "格式化", + "goto_line": "跳转到行", + "delete_line": "删除当前行", + "save_editor_file": "保存当前编辑器文件", + "close_editor": "关闭当前编辑器", + "full_screen": "编辑器全屏", + "auto_indent": "自动缩进", + "indent": "缩进", + "unindent": "反缩进", + "focus": "焦点", + "switch_tab": "切换编辑器/窗口组 tab", + "focus_editor": "焦点切换到编辑器", + "focus_file_tree": "焦点切换到文件树", + "focus_output": "焦点切换到输出窗口", + "focus_search": "焦点切换到搜索窗口", + "focus_notification": "焦点切换到通知窗口", + "build_run": "构建并运行", + "colon": ":" } diff --git a/main.go b/main.go index a50efa6..c0e9ade 100644 --- a/main.go +++ b/main.go @@ -203,6 +203,24 @@ func startHandler(w http.ResponseWriter, r *http.Request) { t.Execute(w, model) } +// 键盘快捷键页请求处理. +func keyboardShortcutsHandler(w http.ResponseWriter, r *http.Request) { + i18n.Load() + + model := map[string]interface{}{"conf": conf.Wide, "i18n": i18n.GetAll(r), "locale": i18n.GetLocale(r)} + + t, err := template.ParseFiles("view/keyboard_shortcuts.html") + + if nil != err { + glog.Error(err) + http.Error(w, err.Error(), 500) + + return + } + + t.Execute(w, model) +} + // 关于页请求处理. func aboutHandler(w http.ResponseWriter, r *http.Request) { i18n.Load() @@ -234,6 +252,7 @@ func main() { http.HandleFunc("/", handlerWrapper(indexHandler)) http.HandleFunc("/start", handlerWrapper(startHandler)) http.HandleFunc("/about", handlerWrapper(aboutHandler)) + http.HandleFunc("/keyboard_shortcuts", handlerWrapper(keyboardShortcutsHandler)) // 静态资源 http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) diff --git a/static/js/editors.js b/static/js/editors.js index 686f3ce..85fab8b 100644 --- a/static/js/editors.js +++ b/static/js/editors.js @@ -102,7 +102,7 @@ var editors = { editors.tabs.add({ id: "startPage", - title: '' + config.label.initialise + '', + title: '' + config.label.start_page + '', content: '
', after: function () { $("#startPage").load('/start'); @@ -149,7 +149,7 @@ var editors = { }, getCurrentPath: function () { var currentPath = $(".edit-panel .tabs .current span:eq(0)").attr("title"); - if (currentPath === config.label.initialise) { + if (currentPath === config.label.start_page) { currentPath = null; } return currentPath; diff --git a/static/js/session.js b/static/js/session.js index 3f7f8dc..201aac9 100644 --- a/static/js/session.js +++ b/static/js/session.js @@ -12,7 +12,7 @@ var session = { editors.tabs.obj._$tabs.find("div").each(function () { var $it = $(this); - if ($it.find("span:eq(0)").attr("title") !== config.label.initialise) { + if ($it.find("span:eq(0)").attr("title") !== config.label.start_page) { filse.push($it.find("span:eq(0)").attr("title")); } }); diff --git a/static/js/tabs.js b/static/js/tabs.js index 53c4c09..5981a54 100644 --- a/static/js/tabs.js +++ b/static/js/tabs.js @@ -1,6 +1,7 @@ var Tabs = function (obj) { obj._$tabsPanel = $(obj.id + " > .tabs-panel"); obj._$tabs = $(obj.id + " > .tabs"); + obj._stack = []; this.obj = obj; @@ -47,21 +48,19 @@ $.extend(Tabs.prototype, { var $tabsPanel = this.obj._$tabsPanel, $tabs = this.obj._$tabs; - this.obj._prevId = $tabs.children("div.current").data("index"); - - $tabs.children("div").removeClass("current"); - $tabsPanel.children("div").hide(); - $tabs.append('
' + data.title + '
'); $tabsPanel.append('
' + data.content + '
'); - + + this.setCurrent(data.id); + if (typeof data.after === 'function') { data.after(); } }, del: function (id) { + // TODO: var $tabsPanel = this.obj._$tabsPanel, $tabs = this.obj._$tabs, prevId = undefined, @@ -99,7 +98,11 @@ $.extend(Tabs.prototype, { return false; } - this.obj._prevId = $currentTab.data("index"); + if (this.obj._stack.length === 1024) { + this.obj._stack.splice(1023, 1); + } else { + this.obj._stack.push(id); + } $tabs.children("div").removeClass("current"); $tabsPanel.children("div").hide(); diff --git a/view/index.html b/view/index.html index 4ce2802..1c23dfd 100644 --- a/view/index.html +++ b/view/index.html @@ -80,8 +80,12 @@ {{.i18n.report_issues}}
  • +
  • + {{.i18n.keyboard_shortcuts}} +
  • +
  • - {{.i18n.start_page}} + {{.i18n.start_page}}
  • {{.i18n.about}} @@ -216,7 +220,7 @@ "usages": "{{.i18n.usages}}", "search_text": "{{.i18n.search_text}}", "search": "{{.i18n.search}}", - "initialise": "{{.i18n.initialise}}", + "start_page": "{{.i18n.start_page}}", "confirm_save": "{{.i18n.confirm_save}}", "community": "{{.i18n.community}}" }, diff --git a/view/keyboard_shortcuts.html b/view/keyboard_shortcuts.html new file mode 100644 index 0000000..0d3dc5e --- /dev/null +++ b/view/keyboard_shortcuts.html @@ -0,0 +1,39 @@ + + + + + {{.i18n.wide}} - {{.i18n.keyboard_shortcuts}} + + + +

    {{.i18n.editor}}

    + +

    {{.i18n.focus}}

    + +

    {{.i18n.run}}

    + + +