diff --git a/base/ctx/command.go b/base/ctx/command.go index b75bc946..6a587e3c 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -77,8 +77,11 @@ func init() { }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] != "" && arg[0] != ice.EXIT { - m.Cmdy(arg).Search(arg[0], func(key string, cmd *ice.Command) { - m.Cut(kit.Format(kit.Value(cmd.List, kit.Format("%d.name", len(arg)-1)))) + m.Search(arg[0], func(key string, cmd *ice.Command) { + field := kit.Format(kit.Value(cmd.List, kit.Format("%d.name", len(arg)-1))) + if m.Cmdy(arg[0], mdb.INPUTS, field); m.Length() == 0 { + m.Cmdy(arg).Cut(field) + } }) } }}, diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index 657a0728..cb508531 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -277,6 +277,9 @@ func ImportantHashAction(arg ...Any) ice.Actions { }, HashAction(arg...)) } func saveImportant(m *ice.Message, key, sub string, arg ...string) { + if m.Option("skip.important") == ice.TRUE { + return + } kit.If(m.Conf(key, kit.Keys(META, "important")) == ice.TRUE, func() { ice.SaveImportant(m, arg...) }) } func ToMaps(value Map) Maps { diff --git a/base/nfs/dir.go b/base/nfs/dir.go index e2cde662..cd12a218 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -123,7 +123,7 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di } if deep && isDir { switch s.Name() { - case "pluged": + case "pluged", "node_modules": continue } _total, _last := _dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields) diff --git a/base/tcp/host.go b/base/tcp/host.go index 489545ca..ac7526dd 100644 --- a/base/tcp/host.go +++ b/base/tcp/host.go @@ -63,7 +63,7 @@ func init() { } }}, ISLOCAL: {Hand: func(m *ice.Message, arg ...string) { - if arg[0] = strings.Split(strings.TrimPrefix(arg[0], "["), "]")[0]; arg[0] == "::1" || strings.HasPrefix(arg[0], "127.") { + if arg[0] = strings.Split(strings.TrimPrefix(arg[0], "["), "]")[0]; arg[0] == "::1" || strings.HasPrefix(arg[0], "127.") || arg[0] == LOCALHOST { m.Echo(ice.OK) } else if mdb.HashSelectField(m, strings.Split(arg[0], nfs.DF)[0], mdb.TYPE) == aaa.WHITE { m.Echo(ice.OK) diff --git a/base/web/html/html.go b/base/web/html/html.go index 3039b016..727fc836 100644 --- a/base/web/html/html.go +++ b/base/web/html/html.go @@ -8,5 +8,6 @@ const ( ) const ( - FLOAT = "float" + FLOAT = "float" + OUTPUT = "output" ) diff --git a/base/web/space.go b/base/web/space.go index 2c94d7fc..60ce27f5 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -90,17 +90,14 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) { if next := msg.Option(ice.MSG_TARGET); next == "" || len(target) == 0 { m.Go(func() { _space_exec(msg, source, target, c) }, strings.Join(kit.Simple(SPACE, name, msg.Detailv()), lex.SP)) } else { - done := false m.Warn(!mdb.HashSelectDetail(m, next, func(value ice.Map) { switch c := value[mdb.TARGET].(type) { case (*websocket.Conn): // 转发报文 _space_echo(msg, source, target, c) case ice.Handler: // 接收响应 - done = true - c(msg) + m.Go(func() { c(msg) }) } }), ice.ErrNotFound, next) - kit.If(done, func() { mdb.HashRemove(m, mdb.HASH, next) }) } } } diff --git a/core/chat/flows.js b/core/chat/flows.js index c4a5b0a4..4ac8c3c9 100644 --- a/core/chat/flows.js +++ b/core/chat/flows.js @@ -1,6 +1,8 @@ +(function() { +const ACTION_STORE = "web.flows:action:" Volcanos(chat.ONIMPORT, { _init: function(can, msg, cb) { can.onmotion.clear(can), can.ui = can.onappend.layout(can), can.onmotion.hidden(can, can.ui.profile), can.onmotion.hidden(can, can.ui.display) - cb && cb(msg), can.core.Item(can.Action(), function(key) { can.onaction[key] = can.onaction[key]||can.onaction.refresh, can.Action(key, can.misc.localStorage(can, "web.flows.action."+key)) }), can.onkeymap._build(can) + cb && cb(msg), can.core.Item(can.Action(), function(key) { can.onaction[key] = can.onaction[key]||can.onaction.refresh, can.Action(key, can.misc.localStorage(can, ACTION_STORE+key)) }), can.onkeymap._build(can) if (can.Option(mdb.ZONE)) { return can.onmotion.hidden(can, can.ui.project), can.onimport._content(can, msg, can.Option(mdb.ZONE)) } can.onimport._project(can, msg) }, _project: function(can, msg) { var target; msg.Table(function(value) { @@ -122,7 +124,7 @@ Volcanos(chat.ONACTION, { [html.MARGIN, 20, 40, 60], ["delay", 100, 200, 500, 1000], ], _trans: {play: "播放", prev: "上一步", next: "下一步"}, - refresh: function(event, can, button) { can.misc.localStorage(can, "web.flows.action."+button, can.Action(button)), can.onimport._flows(can, can.db._content_plugin) }, + refresh: function(event, can, button) { can.misc.localStorage(can, ACTION_STORE+button, can.Action(button)), can.onimport._flows(can, can.db._content_plugin) }, travel: function() {}, delay: function() {}, play: function(event, can) { var list = can.onexport.travel(can, can.db.root, true) can.core.List(list, function(item) { item._line && item._line.Value(html.CLASS, ""), item._rect.Value(html.CLASS, ""), item._text.Value(html.CLASS, "") }) @@ -192,3 +194,4 @@ Volcanos(chat.ONKEYMAP, { ArrowDown: shy("下一步", function(event, can) { can.db.current && can.db.current.to? can.ondetail._select(event, can, can.db.current.to): can.onaction.next(event, can) }), }}, _engine: {}, }) +})() diff --git a/core/chat/iframe.go b/core/chat/iframe.go index 709e2acd..5a5c5041 100644 --- a/core/chat/iframe.go +++ b/core/chat/iframe.go @@ -32,9 +32,11 @@ func init() { m.Push(arg[0], web.UserWeb(m).Host) case mdb.LINK: m.Push(arg[0], m.Option(ice.MSG_USERWEB)) - m.Push(arg[0], "http://localhost:20000") - m.Push(arg[0], "http://localhost:20001") m.Copy(m.Cmd(web.SPIDE).CutTo(web.CLIENT_URL, arg[0])) + case mdb.HASH: + m.Cmd(mdb.SEARCH, mdb.FOREACH, "", "type,name,text", func(value ice.Maps) { + kit.If(value[mdb.TYPE] == "link", func() { m.Push(arg[0], value[mdb.TEXT]) }) + }) } }}, FAVOR_INPUTS: {Hand: func(m *ice.Message, arg ...string) { diff --git a/core/code/inner.go b/core/code/inner.go index ed9e235d..f6deec46 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -21,9 +21,7 @@ func _inner_list(m *ice.Message, ext, file, dir string) { m.Cmdy(nfs.CAT, path.Join(dir, file)) }, func() { _inner_show(m.RenderResult().SetResult(), ext, file, dir) - if m.Result() == "" { - m.Cmdy(nfs.CAT, path.Join(dir, file)) - } + kit.If(m.Result() == "", func() { m.Cmdy(nfs.CAT, path.Join(dir, file)) }) }) }) } @@ -101,9 +99,7 @@ func init() { case ctx.INDEX: m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX)) case ctx.ARGS: - kit.If(m.Option(ctx.INDEX) != "", func() { - m.Cmdy(m.Option(ctx.INDEX)).Search(m.Option(ctx.INDEX), func(key string, cmd *ice.Command) { m.Cut(kit.Format(kit.Value(cmd.List, "0.name"))) }) - }) + m.Cmdy(ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX)) case nfs.PATH: m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS) kit.If(strings.HasPrefix(p, bind[0]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[0], bind[1], 1), nfs.DIR_CLI_FIELDS) }) diff --git a/core/code/makefile.go b/core/code/makefile.go new file mode 100644 index 00000000..328c53db --- /dev/null +++ b/core/code/makefile.go @@ -0,0 +1,28 @@ +package code + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/nfs" + "shylinux.com/x/icebergs/base/web/html" + kit "shylinux.com/x/toolkits" +) + +func _makefile_xterm(m *ice.Message, arg ...string) { + ctx.Process(m, XTERM, func() []string { + m.Push(ctx.STYLE, html.OUTPUT) + return []string{mdb.TYPE, "sh", nfs.PATH, kit.Select("", kit.Dir(arg[2], arg[1]), arg[2] != ice.SRC)} + }, arg...) +} + +const MAKEFILE = "makefile" + +func init() { + Index.MergeCommands(ice.Commands{ + MAKEFILE: {Name: "makefile path auto", Help: "构建", Actions: ice.MergeActions(ice.Actions{ + mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _makefile_xterm(m, arg...) }}, + mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _makefile_xterm(m, arg...) }}, + }, PlugAction())}, + }) +} diff --git a/core/code/sh.go b/core/code/sh.go index 03e7249d..e25ef623 100644 --- a/core/code/sh.go +++ b/core/code/sh.go @@ -33,14 +33,6 @@ const SH = nfs.SH func init() { Index.MergeCommands(ice.Commands{ SH: {Name: "sh path auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{ - mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { - if arg[0] == mdb.FOREACH && arg[1] == ssh.SHELL { - return - m.Cmd(nfs.CAT, "/etc/shells", func(text string) { - kit.If(text != "" && !strings.HasPrefix(text, "#"), func() { m.PushSearch(mdb.TYPE, ssh.SHELL, mdb.NAME, path.Base(text), mdb.TEXT, path.Base(text)) }) - }) - } - }}, mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { cmds, text := _sh_cmds(m, path.Join(arg[2], arg[1])) ProcessXterm(m, cmds, text, path.Join(arg[2], arg[1])) diff --git a/core/code/xterm.go b/core/code/xterm.go index 1a40bef7..5b61d22a 100644 --- a/core/code/xterm.go +++ b/core/code/xterm.go @@ -21,6 +21,7 @@ import ( func _xterm_get(m *ice.Message, h string) xterm.XTerm { h = kit.Select(m.Option(mdb.HASH), h) m.Assert(h != "") + m.Option("skip.important", ice.TRUE) if m.Option(ice.MSG_USERPOD) == "" { mdb.HashModify(m, mdb.TIME, m.Time(), cli.DAEMON, kit.Keys(m.Option(ice.MSG_DAEMON))) } else { @@ -60,7 +61,7 @@ func _xterm_get(m *ice.Message, h string) xterm.XTerm { }).(xterm.XTerm) } func _xterm_echo(m *ice.Message, h string, str string) { - m.Options(ice.LOG_DISABLE, ice.TRUE, "__target", "", ice.MSG_DAEMON, mdb.HashSelectField(m, h, cli.DAEMON)) + m.Options(ice.MSG_COUNT, "0", ice.LOG_DISABLE, ice.TRUE, "__target", "", ice.MSG_DAEMON, mdb.HashSelectField(m, h, cli.DAEMON)) web.PushNoticeGrow(m, h, str) } func _xterm_cmds(m *ice.Message, h string, cmd string, arg ...ice.Any) { @@ -126,7 +127,11 @@ func init() { }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }}, ctx.PROCESS: {Hand: func(m *ice.Message, arg ...string) { - ctx.ProcessField(m, m.PrefixKey(), func() string { return m.Cmdx("", mdb.CREATE, arg) }, arg...) + if len(arg) == 1 { + ctx.ProcessField(m, m.PrefixKey(), arg, arg...) + } else { + ctx.ProcessField(m, m.PrefixKey(), func() string { return m.Cmdx("", mdb.CREATE, arg) }, arg...) + } }}, "terminal": {Help: "本机", Hand: func(m *ice.Message, arg ...string) { if h := kit.Select(m.Option(mdb.HASH), arg, 0); h == "" { @@ -162,5 +167,11 @@ end tell } func ProcessXterm(m *ice.Message, cmds, text string, arg ...string) { - ctx.Process(m, XTERM, []string{mdb.TYPE, cmds, mdb.NAME, kit.Select("", arg, 0), mdb.TEXT, text}, arg...) + ctx.Process(m, XTERM, func() []string { + if ls := kit.Simple(kit.UnMarshal(m.Option(ctx.ARGS))); len(ls) > 0 { + return ls + } else { + return []string{mdb.TYPE, cmds, mdb.NAME, kit.Select("", arg, 0), mdb.TEXT, text} + } + }, arg...) } diff --git a/misc/webview/webview.go b/misc/webview/webview.go index db4697d5..63bc755b 100644 --- a/misc/webview/webview.go +++ b/misc/webview/webview.go @@ -8,6 +8,7 @@ import ( "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/nfs" + "shylinux.com/x/icebergs/base/tcp" kit "shylinux.com/x/toolkits" "shylinux.com/x/webview" ) @@ -47,12 +48,21 @@ func (w WebView) Menu() bool { } func (w WebView) Title(text string) { w.WebView.SetTitle(text) } func (w WebView) Webview(url string) { w.WebView.Navigate(url) } -func (w WebView) Open(url string) { w.WebView.Navigate(url) } -func (w WebView) OpenUrl(url string) { cli.Opens(ice.Pulse, url) } -func (w WebView) OpenApp(app string) { cli.Opens(ice.Pulse, app) } +func (w WebView) Open(url string) { + w.Message.Debug("open %v", url) + w.WebView.Navigate(url) +} +func (w WebView) OpenUrl(url string) { + w.Message.Debug("open %v", url) + cli.Opens(w.Message, url) +} +func (w WebView) OpenApp(app string) { + w.Message.Debug("open %v", app) + cli.Opens(w.Message, app) +} func (w WebView) OpenCmd(cmd string) { w.Cmd(nfs.SAVE, kit.HomePath(".bash_temp"), cmd) - cli.Opens(ice.Pulse, "Terminal.app", "-n") + cli.Opens(w.Message, "Terminal.app", "-n") } func (w WebView) SetSize(width, height int) { w.Cmd(nfs.SAVE, "etc/webview.size", kit.Format("%v,%v", width, height)) @@ -66,8 +76,11 @@ func (w WebView) Power() string { } return "" } -func (w WebView) Close() { kit.If(!w.Menu(), func() { w.WebView.Terminate() }) } -func (w WebView) Terminate() { w.WebView.Terminate() } +func (w WebView) Close() { kit.If(!w.Menu(), func() { w.WebView.Terminate() }) } +func (w WebView) Terminate() { + w.WebView.Eval("window.onbeforeunload()") + w.WebView.Terminate() +} func (w WebView) navigate(url string) { w.WebView.SetSize(1200, 800, webview.HintNone) w.WebView.Navigate(url) @@ -77,7 +90,7 @@ func Run(cb func(*WebView) ice.Any) { w := webview.New(true) defer w.Destroy() defer w.Run() - view := &WebView{Source: "etc/webview.txt", WebView: w, Message: ice.Pulse} + view := &WebView{Source: "etc/webview.txt", WebView: w, Message: ice.Pulse.Spawn(kit.Dict(ice.MSG_USERIP, tcp.LOCALHOST))} if cb == nil { kit.Reflect(view, func(name string, value ice.Any) { w.Bind(name, value) }) } else { diff --git a/render.go b/render.go index b143c917..62e3a527 100644 --- a/render.go +++ b/render.go @@ -190,15 +190,15 @@ func (m *Message) PushDownload(key string, arg ...string) *Message { return m } -func (m *Message) EchoFields(cmd string) *Message { - return m.Echo(`