From df37f1f977306914db989c1548fb9a27a8adddf6 Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 15 Jul 2020 20:05:32 +0800 Subject: [PATCH] opt some --- base/cli/system.go | 1 + base/gdb/gdb.go | 1 + core/code/inner.go | 91 +++++++++++++++++++++++++++++++++------------- core/wiki/word.go | 2 +- 4 files changed, 69 insertions(+), 26 deletions(-) diff --git a/base/cli/system.go b/base/cli/system.go index 7658b73e..0a1de5a3 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -41,6 +41,7 @@ func _system_show(m *ice.Message, cmd *exec.Cmd) { m.Warn(e != nil, ErrRun, strings.Join(cmd.Args, " "), "\n", kit.Select(e.Error(), err.String())) } + m.Push(kit.MDB_TIME, m.Time()) m.Push(CMD_CODE, int(cmd.ProcessState.ExitCode())) m.Push(CMD_ERR, err.String()) m.Push(CMD_OUT, out.String()) diff --git a/base/gdb/gdb.go b/base/gdb/gdb.go index 2bdb2757..1a750422 100644 --- a/base/gdb/gdb.go +++ b/base/gdb/gdb.go @@ -97,6 +97,7 @@ const ( START = "start" STOP = "stop" + RELOAD = "reload" RESTART = "restart" CHANGE = "change" BUILD = "build" diff --git a/core/code/inner.go b/core/code/inner.go index 03586af0..320e42f0 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -48,18 +48,19 @@ func _inner_sub(m *ice.Message, action string, name string, arg ...string) bool return false } -func _inner_list(m *ice.Message, name string) { - if _inner_sub(m, LIST, name) { +func _inner_list(m *ice.Message, dir, file string) { + if _inner_sub(m, LIST, path.Join(dir, file)) { return } - if m.Set(ice.MSG_RESULT); strings.HasSuffix(name, "/") || _inner_source(m, name) { + if m.Set(ice.MSG_RESULT); file == "" || strings.HasSuffix(file, "/") || _inner_source(m, file) { + m.Option(nfs.DIR_ROOT, dir) m.Option(nfs.DIR_DEEP, "true") m.Option(nfs.DIR_TYPE, nfs.TYPE_FILE) - m.Cmdy(nfs.DIR, name, "path size time") + m.Cmdy(nfs.DIR, file, "path size time") return } - m.Echo(name) + m.Echo(path.Join(dir, file)) } func _inner_save(m *ice.Message, name, text string) { if _inner_sub(m, SAVE, name) { @@ -119,15 +120,12 @@ func _inner_show(m *ice.Message, dir, file string) { m.Echo(strings.ReplaceAll(strings.Join(m.Cmd("web.wiki.word", name).Resultv(), ""), "\n", " ")) } } -func _inner_main(m *ice.Message, arg ...string) { - if len(arg) > 2 { - arg = arg[:2] - } - p := _inner_ext(arg[1]) - key := strings.TrimSuffix(path.Base(arg[1]), "."+p) +func _inner_main(m *ice.Message, dir, file string) { + p := _inner_ext(file) + key := strings.TrimSuffix(path.Base(file), "."+p) switch p { case "godoc": - m.Option(cli.CMD_DIR, arg[0]) + m.Option(cli.CMD_DIR, dir) m.Echo(m.Cmdx(cli.SYSTEM, "go", "doc", key)) case "man8", "man3", "man2", "man1": @@ -144,9 +142,9 @@ func _inner_main(m *ice.Message, arg ...string) { } m.Echo(string(res)) - return + default: + _inner_list(m, dir, file) } - _inner_list(m, path.Join(arg...)) } func init() { @@ -155,14 +153,16 @@ func init() { INNER: {Name: "inner", Help: "编辑器", Value: kit.Data( "protect", kit.Dict("etc", "true", "var", "true", "usr", "true"), "source", kit.Dict( - "txt", "true", "url", "true", - "sh", "true", "py", "true", - "shy", "true", - "go", "true", "js", "true", - "c", "true", "h", "true", "makefile", "true", - "mod", "true", - "sum", "true", + "c", "true", "h", "true", + "sh", "true", "shy", "true", "py", "true", + "mod", "true", "sum", "true", + "go", "true", "js", "true", + + "md", "true", "csv", "true", + "txt", "true", "url", "true", + "conf", "true", "json", "true", + "ts", "true", "tsx", "true", "vue", "true", "sass", "true", ), "plug", kit.Dict( "py", kit.Dict( @@ -171,6 +171,48 @@ func init() { ), "md", kit.Dict("display", true, "profile", true), "csv", kit.Dict("display", true), + "ts", kit.Dict( + "prefix", kit.Dict("//", "comment"), + "split", kit.Dict( + "space", " ", + "operator", "{[(.:,;!|)]}", + ), + "keyword", kit.Dict( + "import", "keyword", + "from", "keyword", + "new", "keyword", + "as", "keyword", + "const", "keyword", + "export", "keyword", + "default", "keyword", + + "if", "keyword", + "return", "keyword", + + "class", "keyword", + "extends", "keyword", + "interface", "keyword", + "declare", "keyword", + "async", "keyword", + "await", "keyword", + "try", "keyword", + "catch", "keyword", + + "function", "function", + "arguments", "function", + "console", "function", + "this", "function", + + "string", "datatype", + "number", "datatype", + + "true", "string", + "false", "string", + ), + ), + "tsx", kit.Dict("link", "ts"), + "vue", kit.Dict("link", "ts"), + "sass", kit.Dict("link", "ts"), ), "show", kit.Dict( "sh", []string{"sh"}, @@ -199,9 +241,6 @@ func init() { "find": {Name: "find word", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { web.FavorList(m, arg[0], arg[1], arg[2:]...) }}, - "project": {Name: "project path", Help: "项目", Hand: func(m *ice.Message, arg ...string) { - _inner_list(m, path.Join("./", kit.Select("", arg, 0))+"/") - }}, "history": {Name: "history path name", Help: "历史", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(web.STORY, web.HISTORY, path.Join("./", arg[0], arg[1])) @@ -248,7 +287,9 @@ func init() { mdb.SEARCH: {Name: "search type name text arg...", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.SEARCH, arg) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _inner_main(m, arg...) }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + _inner_main(m, arg[0], kit.Select("", arg, 1)) + }}, }, }, nil) } diff --git a/core/wiki/word.go b/core/wiki/word.go index 42ae2caa..a5aae5e1 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -360,7 +360,7 @@ func init() { _stack_show(m, arg[0], arg[1], arg[2:]...) }}, - WORD: {Name: "word path=hi.shy auto", Help: "语言文字", Meta: kit.Dict( + WORD: {Name: "word path=demo/hi.shy auto", Help: "语言文字", Meta: kit.Dict( "display", "/plugin/local/wiki/word.js", ), Action: map[string]*ice.Action{ "story": {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {