diff --git a/frame.js b/frame.js index 8bf94993..6c247a1d 100644 --- a/frame.js +++ b/frame.js @@ -116,13 +116,6 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { var action = can.page.SelectOne(can, field, html.DIV_ACTION) var output = can.page.SelectOne(can, field, html.DIV_OUTPUT) var status = can.page.SelectOne(can, field, html.DIV_STATUS) - meta.index && can.core.Item({ - "delete": function(event) { sub.onaction.close(event, sub) }, - "refresh": function(event) { sub.Update(event) }, - "lt": function(event) { sub.onimport._back(sub) }, - }, function(key, cb) { - can.page.Append(can, option, [{view: [[html.ITEM, html.ICON, key], html.DIV, can.page.unicode[key]], onclick: cb}]) - }) var sub = Volcanos(meta.name, {_root: can._root||can, _follow: can.core.Keys(can._follow, meta.name), _target: field, _legend: legend, _option: option, _action: action, _output: output, _status: status, _history: [], Status: function(key, value) { if (can.base.isObject(key)) { return can.core.Item(key, sub.Status), key } @@ -156,6 +149,17 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }); return sub }, _option: function(can, meta, option, skip) { var index = -1, args = can.base.Obj(meta.args||meta.arg, []), opts = can.base.Obj(meta.opts, {}) + can.core.List([""].concat(meta.inputs), function(item) { + var icon = { + refresh: {name: "refresh", cb: function(event) { can.Update(event) }}, + run: {name: "refresh", cb: function(event) { can.Update(event) }}, + list: {name: "refresh", cb: function(event) { can.Update(event) }}, + back: {name: "goback", cb: function(event) { can.onimport._back(can) }}, + create: {name: "create", cb: function(event) { can.Update(event, [ctx.ACTION, mdb.CREATE]) }}, + insert: {name: "create", cb: function(event) { can.Update(event, [ctx.ACTION, mdb.INSERT]) }}, + "": {name: "delete", cb: function(event) { can.onaction.close(event, can) }}, + }[item.name||""]; icon && can.page.Append(can, option, [{view: [[html.ITEM, html.ICON, icon.name, item.name], html.DIV, can.page.unicode[icon.name]], onclick: icon.cb}]) + }) function add(item, next) { item = can.base.isString(item)? {type: html.TEXT, name: item}: item, item.type != html.BUTTON && index++ return Volcanos(item.name, {_root: can._root, _follow: can.core.Keys(can._follow, item.name), _target: can.onappend.input(can, item, args[index]||opts[item.name], option||can._option), _option: option||can._option, _action: can._action, _output: can._output, _status: can._status, @@ -375,16 +379,18 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }); return list } ui.list = append(target, type, list||[html.PROJECT, [[html.CONTENT, html.PROFILE], html.DISPLAY]]) function calc(item, size, total) { return !ui.size[item]? can.base.isString(size)? parseInt(can.base.trimSuffix(size, "px")): size: ui.size[item] < 1? total*ui.size[item]: ui.size[item] } var defer = [], content_height, content_width; function layout(type, list, height, width) { var _width = width, _height = height; can.core.List(list, function(item) { + var target = ui[item] if (item == html.CONTENT) { content_height = height, content_width = width - return defer.push(function() { can.page.style(can, ui[item], html.HEIGHT, height, html.WIDTH, width) }) + return defer.push(function() { can.page.style(can, target, html.HEIGHT, height, html.WIDTH, width) }) } - if (!can.page.isDisplay(ui[item])) { return } if (can.base.isObject(item)) { var meta = item; item = item._index } - if (type == FLOW) { var h = calc(item, ui[item].offsetHeight, height) + if (item == "plug") { return } + if (!can.page.isDisplay(target)) { return } if (can.base.isObject(item)) { var meta = item; item = item._index } + if (type == FLOW) { var h = calc(item, target.offsetHeight, height) if (can.base.isObject(meta)) { meta.layout(h, width) } - can.page.style(can, ui[item], html.WIDTH, width), height -= h - } else { var w = calc(item, ui[item].offsetWidth||ui[item].style.width||_width/list.length, _width), h = height + can.page.style(can, target, html.WIDTH, width), height -= h + } else { var w = calc(item, target.offsetWidth||target.style.width||_width/list.length, _width), h = height if (can.base.isObject(meta)) { meta.layout(h, w = _width/list.length) } - can.page.style(can, ui[item], html.HEIGHT, h, html.WIDTH, w), width -= w + can.page.style(can, target, html.HEIGHT, h, html.WIDTH, w), width -= w } }), can.core.List(list, function(item) { if (can.base.isArray(item)) { layout(type == FLOW? FLEX: FLOW, item, height, width) } }) } ui.layout = function(height, width, delay, cb) { can.onmotion.delay(can, function() { defer = [], layout(type, ui.list, height, width), defer.forEach(function(cb) { cb() }), cb && cb(content_height, content_width) }, delay||0) }; return ui diff --git a/index.css b/index.css index d1090d87..a5b69505 100644 --- a/index.css +++ b/index.css @@ -150,8 +150,9 @@ div.item.text { position:relative; } div.item.text>span.icon.delete { font-size:20px; line-height:28px; position:absolute; top:2px; right:10px; visibility:hidden; } div.item.text:hover>span.icon.delete { visibility:visible; } form.option>div.icon:first-child { margin-left:-5px; } -form.option>div.icon { font-size:26px; padding:0 5px; height:32px; display:none; } +form.option>div.icon { line-height:30px; font-size:26px; padding:0 5px; height:32px; display:none; } form.option>div.icon.refresh { line-height:28px; } +form.option>div.icon.goback { line-height:28px; } form.option>div.icon.lt { font-size:20px; line-height:30px; } form.option>div.icon:hover { background-color:white; } fieldset.float>form.option>div.item.button { display:none; } @@ -296,6 +297,8 @@ fieldset.plugin.inner.cmd>form.option { display:none; } fieldset.plugin.inner.cmd fieldset.story>form.option>div.icon { display:block; } fieldset.plugin.inner.cmd fieldset.story>form.option>div.item.button.list>input { display:none; } fieldset.plugin.inner.cmd fieldset.story>form.option>div.item.button.back>input { display:none; } +fieldset.plugin.inner.cmd fieldset.story>form.option>div.item.button.create>input { display:none; } +fieldset.plugin.inner.cmd fieldset.story>form.option>div.item.button.insert>input { display:none; } fieldset.plugin.inner.cmd fieldset.xterm>form.option>div.item.text>input { width:320px; } fieldset.plan div.output table.content { height:100%; width:100%; } fieldset.xterm div.toggle { display:none; } diff --git a/lib/core.js b/lib/core.js index b7f14b7f..66ea5b76 100644 --- a/lib/core.js +++ b/lib/core.js @@ -59,7 +59,7 @@ Volcanos("core", { } } return res } }, CallFunc: function(func, args, mod) { args = args||{}; var can = args["can"]||args[0], msg = args["msg"]||args[1], cb = args["cb"] - if (Array.isArray(args)) { this.List(args, function(arg) { if (arg.request && arg.run) { can = arg } else if (arg.Append && arg.Result) { msg = arg } else if (typeof arg == code.FUNCTION) { cb = arg } }) } + if (Array.isArray(args)) { this.List(args, function(arg) { if (!arg) { return } if (arg.request && arg.run) { can = arg } else if (arg.Append && arg.Result) { msg = arg } else if (typeof arg == code.FUNCTION) { cb = arg } }) } func = typeof func == lang.FUNCTION? func: typeof func == lang.OBJECT && func.length > 0? this.Value(func[0], this.Keys(func.slice(1))): typeof func == lang.STRING? this.Value(mod||can, func): null if (typeof func != lang.FUNCTION) { if (typeof cb == lang.FUNCTION) { cb() } return } var list = [], echo = false; args.length > 0? list = args: this.List(func.toString().split(")")[0].split("(")[1].split(ice.FS), function(item, index) { item = item.trim(); if (item == "") { return } diff --git a/lib/page.js b/lib/page.js index 8f00b66b..e9daa2c6 100644 --- a/lib/page.js +++ b/lib/page.js @@ -245,9 +245,10 @@ Volcanos("page", { width: function() { return window.innerWidth }, ismodkey: function(event) { return [lang.META, lang.ALT, lang.CONTROL, lang.SHIFT].indexOf(event.key) > -1 }, unicode: { + create: "+", menu: "☰", back: "◀", refresh: "↻", reback: "▶", delete: "✕", lt: "❮", gt: "❯", open: "▾", close: "▸", select: "▿", inner: "..", - push: "\u21C8", - pull: "\u21CA", + push: "\u21C8", pull: "\u21CA", + goback: "\u21BA", }, inputs: function(can, list, type) { var _list = []; for (var i = 0; i < list.length; i++) { switch (list[i]) { case "": _list.push(""); break diff --git a/plugin/input/key.js b/plugin/input/key.js index 6ae322e6..5137f91f 100644 --- a/plugin/input/key.js +++ b/plugin/input/key.js @@ -12,7 +12,7 @@ Volcanos(chat.ONFIGURE, {key: { msg.Option(ice.MSG_PROCESS) == ice.PROCESS_AGAIN && can.onmotion.delay(can, function() { can._load(event, can, cb, target, name, value) }) }} }), can.onappend._status(can, [mdb.TOTAL, mdb.INDEX]), can.Status(mdb.TOTAL, msg.Length()) - can.page.style(can, can._output, html.MAX_HEIGHT, can.page.height()/2, html.MAX_WIDTH, target.offsetWidth) + can.page.style(can, can._output, html.MAX_HEIGHT, can.page.height()/2, html.MIN_WIDTH, target.offsetWidth, html.MAX_WIDTH, can.page.width()/2) msg.append.length == 1 && can.page.ClassList.add(can, can._target, chat.SIMPLE), can.onlayout.figure({target: target}, can, can._target) }, onclick: function(event, can, meta, target, cbs) { can.onmotion.focus(can, target) }, diff --git a/plugin/local/code/inner.css b/plugin/local/code/inner.css index df3dd029..3af23554 100644 --- a/plugin/local/code/inner.css +++ b/plugin/local/code/inner.css @@ -12,7 +12,7 @@ fieldset.inner>div.output div.content td.text span.object { color:cyan; } fieldset.inner>div.output>div.layout>div.layout>div.content * { font-family:monospace; font-size:14px; outline:none; } fieldset.inner>div.output>div.layout>div.path { font-family:monospace; font-size:14px; } fieldset.inner>div.output>div.layout>div.tabs { font-family:monospace; font-size:14px; } -fieldset.inner>div.output>div.project { width:230px; border-right:solid 5px black; } +fieldset.inner>div.output>div.project { width:230px; } fieldset.inner>div.output>div.project * { font-family:monospace; font-size:14px; outline:none; } fieldset.inner>div.output>div.project div.action { width:100%; } fieldset.inner>div.output>div.project input[type=text] { box-shadow:none; } @@ -27,6 +27,9 @@ fieldset.inner>div.output>div.project>div.zone fieldset.plug { position:static; fieldset.inner>div.output>div.layout.flow { position:relative; } fieldset.inner>div.output>div.layout.flow>div.tabs { display:none; } fieldset.inner>div.output>div.layout.flow>div.path { display:none; } +fieldset.inner.cmd>div.output>div.project { border-right:solid 2px gray; } +fieldset.inner.cmd>div.output div.profile { border-left:solid 2px gray; } +fieldset.inner.cmd>div.output div.display { border-top:solid 2px gray; } fieldset.inner.cmd>div.output>div.project>div.zone>div.item { font-style:italic; font-weight:bold; line-height:32px; } fieldset.inner.cmd>div.output>div.project>div.zone>div.item>span.icon { font-style:normal; font-weight:normal; line-height:32px; } fieldset.inner.cmd>div.output>div.layout.flow>div.tabs { height:38px; display:block; overflow:hidden; } @@ -43,7 +46,7 @@ fieldset.inner.cmd>div.output>div.layout.flow>div.path { font-style:italic; padd fieldset.inner.cmd>div.output>div.layout.flow>div.path.hide { display:none; } fieldset.inner.cmd>div.output>div.layout.flow>div.path span.func { margin-left:20px; } fieldset.inner.cmd>div.output>div.layout.flow>div.path span.view { font-size:22px; line-height:12px; padding:0 4px; float:right; cursor:pointer; } -fieldset.inner.cmd>div.output>div.layout.flow>div.plug { height:32px; clear:both; } +fieldset.inner.cmd>div.output>div.layout.flow>div.plug { height:32px; clear:both; position:fixed; bottom:0; right:0; } fieldset.inner.cmd>div.output>div.layout.flow>div.plug>legend { font-size:1rem; padding:0 10px; float:right; } body.zh fieldset.inner>div.output>div.project>div.zone>div.item { letter-spacing:10px; } diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index 02942580..3ec129a7 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -164,12 +164,11 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl can.onmotion.toggle(can, can.ui.profile, true), can.db.profile_size[can.onexport.keys(can)] = 0.8, can.onimport.layout(can) } else { can.ui.profile = _msg._profile = can.ui._profile var height = can.ui.profile.offsetHeight||can.ui.content.offsetHeight - var per = 0.5 - if (msg.Append(ctx.INDEX) == web.WIKI_WORD) { - per = 0.6 - } + var per = 0.5; if (msg.Append(ctx.INDEX) == web.WIKI_WORD) { per = 0.6 } var width = can.onexport.size(can, can.db.profile_size[can.onexport.keys(can)]||per, can.ConfWidth()-can.ui.project.offsetWidth) - can.onimport.process(can, msg, can.ui.profile, height, width, function(sub) { var _width = can.base.Max(sub._target.offsetWidth, width) + can.onimport.process(can, msg, can.ui.profile, height, width, function(sub) { + can.page.style(can, sub._output, html.MAX_WIDTH, "") + var _width = can.base.Max(sub._target.offsetWidth, width-2) can.db.profile_size[can.onexport.keys(can)] = _width, can.onimport.layout(can), sub.onimport.size(sub, height, _width, true) can.ui.profile._plugin = can._msg._profile = sub }) @@ -181,21 +180,22 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl display: function(can, msg) { var width = can.ui.content.offsetWidth+can.ui.profile.offsetWidth||can.ConfWidth()-can.ui.project.offsetWidth var height = can.onexport.size(can, can.db.display_size[can.onexport.keys(can)]||0.5, can.ui.content.offsetHeight||can.ConfHeight()) can.page.style(can, can.ui.display, html.MAX_HEIGHT, can.ConfHeight()/2) - can.onimport.process(can, msg, can.ui.display, height, width, function(sub) { var _height = can.base.Max(sub._target.offsetHeight, height) - // can.page.style(can, sub._target, html.MIN_HEIGHT, _height = can.base.Min(_height, can.ConfHeight()/4)) + can.onimport.process(can, msg, can.ui.display, height, width, function(sub) { + if (sub.ConfHeight() < can.ui.content.offsetHeight-100) { can.page.style(can, sub._output, html.MAX_HEIGHT, "") } + var _height = can.base.Max(sub._target.offsetHeight, height) can.db.display_size[can.onexport.keys(can)] = _height, can.onimport.layout(can), sub.onimport.size(sub, _height, width, true) }) }, process: function(can, msg, target, height, width, cb) { can.onmotion.clear(can, target) if (msg.Option(ice.MSG_PROCESS) == ice.PROCESS_FIELD) { msg.Table(function(item) { item.type = chat.STORY, item.display = msg.Option(ice.MSG_DISPLAY), item.height = height-2*html.ACTION_HEIGHT, item.width = width - if (item.index == "web.code.xterm") { item.style = "output" } - if (item.index == "web.wiki.word") { item.style = "output" } + if (item.index == web.CODE_XTERM) { item.style = html.OUTPUT } + if (item.index == web.WIKI_WORD) { item.style = html.OUTPUT } can.onimport.plug(can, item, function(sub) { height && sub.ConfHeight(item.height), width && sub.ConfWidth(item.width) sub.onaction.close = function() { can.onmotion.hidden(can, target), can.onimport.layout(can) } - sub.onexport.output = function(_sub, _msg) { can.base.isFunc(cb) && cb(_sub, _msg) } + sub.onexport.output = function(_sub, _msg) { can.onmotion.delay(can, function() { can.base.isFunc(cb) && cb(_sub, _msg) }) } sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, can.Option()), item.index, cmds, function(msg) { - height && sub.ConfHeight(item.height), width && sub.ConfWidth(item.width), can.page.style(can, sub._output, html.MAX_HEIGHT, "", html.MAX_WIDTH, "") + height && sub.ConfHeight(item.height), width && sub.ConfWidth(item.width) can.base.isFunc(cb) && cb(msg) }) } }, target) diff --git a/plugin/local/code/xterm.js b/plugin/local/code/xterm.js index 8f0154a0..68b2e236 100644 --- a/plugin/local/code/xterm.js +++ b/plugin/local/code/xterm.js @@ -1,6 +1,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.onmotion.clear(can), can.onlayout._init(can) can.page.requireModules(can, ["xterm/css/xterm.css", "xterm", "xterm-addon-fit", "xterm-addon-web-links"], function() { - can._delay_cmds = function() { item.text && can.onimport._input(can, item.text+ice.NL), delete(can._delay_cmds) } + can._delay_cmds = function() { delete(can._delay_cmds), item.text && can.core.Next(item.text.split(ice.NL), function(item, next) { + can.onimport._input(can, item+ice.NL), can.onmotion.delay(can, next) + }) } var item = msg.TableDetail(); item.hash = item.hash||can.Option(mdb.HASH), item.text && can.onmotion.delay(can, function() { can._delay_cmds && can._delay_cmds() }, 1000) can.onimport._connect(can, item), can.onappend.tools(can, msg, function(sub) { sub.onexport.record = function(_, value, key, line) { can.onimport._input(can, value+ice.NL) } @@ -20,15 +22,12 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.onmotion.clear(can) term.onCursorMove(function() { can.onexport.term(can) }) can._current = term, term._item = item, term.open(can._output), term.focus() }, - _resize: function(can, size) { can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, "") + _resize: function(can, size) { // can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, "") can.runAction(can.request({}, size, can._current._item), "resize", [], function() { can.onexport.term(can) }) }, _input: function(can, data) { can._current && can.runAction(can.request({}, can._current._item), "input", [btoa(data)], function() {}) }, _theme: function(can, item) { return can.base.Obj(item.theme)||(can.getHeaderTheme() == html.LIGHT? {background: cli.WHITE, foreground: cli.BLACK, cursor: cli.BLUE}: {}) }, - grow: function(can, msg, _arg) { - can._delay_cmds && can._delay_cmds() - can._current.write(_arg) - }, + grow: function(can, msg, _arg) { can._current.write(_arg), can._delay_cmds && can._delay_cmds() }, }) Volcanos(chat.ONLAYOUT, {_init: function(can) { can.page.style(can, can._output, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth(), html.MAX_WIDTH, "") diff --git a/plugin/local/wiki/word.css b/plugin/local/wiki/word.css index a271af54..80c9d6ce 100644 --- a/plugin/local/wiki/word.css +++ b/plugin/local/wiki/word.css @@ -19,7 +19,10 @@ fieldset.word ul.story[data-type=endmenu] { clear:both; } fieldset.word p.story[data-name=inner] { background-color:#4b6c8a7a; padding:4px 10px; border-left:solid 4px blue; margin:10px 0px; } fieldset.word p.story[data-name=inner]:hover { background-color:#c10c8a; cursor:copy; } fieldset.word table.content { display:block; max-height:400px; } -fieldset.word>div.output>fieldset.story:not(.float):not(.full) { margin:10px; } +// fieldset.word>div.output>fieldset.story:not(.float):not(.full) { margin:10px; } +// fieldset.word>div.output>div.story { margin:10px; } +fieldset.word>div.output>p.story { margin:10px; } +fieldset.word>div.output { padding:10px; } // fieldset.word>div.output>fieldset.story { margin:10px; background-color:#58a4d37d; } fieldset.word fieldset.story.full { margin:0; } fieldset.word fieldset.story.float { margin:0; } diff --git a/plugin/local/wiki/word.js b/plugin/local/wiki/word.js index f4c205c5..f41bb6fa 100644 --- a/plugin/local/wiki/word.js +++ b/plugin/local/wiki/word.js @@ -83,8 +83,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( can.onappend._init(can, item, [chat.PLUGIN_STATE_JS], function(sub) { sub.run = function(event, cmds, cb, silent) { var msg = sub.request(event) if (msg.Option(nfs.PATH) == can.Option(nfs.PATH)) { msg.Option(nfs.PATH, "") } - can.runAction(event, chat.STORY, [meta.type, meta.name, meta.text].concat(cmds), cb||function(msg) { - if (msg._can == sub && can.core.CallFunc([sub, chat.ONIMPORT, ice.MSG_PROCESS], {can: sub, msg: msg})) { return } + can.runAction(event, chat.STORY, [meta.type, meta.name, meta.text].concat(cmds), function(msg) { + cb(msg), can.sup.onexport.output(can.sup, msg) }, true) }, can._plugins = (can._plugins||[]).concat([sub]) diff --git a/plugin/story/spide.js b/plugin/story/spide.js index 57ec16fc..7b344da7 100644 --- a/plugin/story/spide.js +++ b/plugin/story/spide.js @@ -21,8 +21,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { }, _color: function(can, tree) { return tree.meta.color || (tree.list == 0? cli.PURPLE: cli.YELLOW) }, layout: function(can) { can.page.style(can, can._output, html.MAX_HEIGHT, "") - can.svg.Val(svg.FONT_SIZE, can.size = parseInt(can.Action(html.SIZE))), can.margin = parseInt(can.Action(html.MARGIN)) - can.onaction[can.Action(ice.VIEW)](event, can, can.Action(ice.VIEW)) + can.svg && can.svg.Val(svg.FONT_SIZE, can.size = parseInt(can.Action(html.SIZE))), can.margin = parseInt(can.Action(html.MARGIN)) + can.core.CallFunc(can.onaction[can.Action(ice.VIEW)], [event, can, can.Action(ice.VIEW)]) }, }) Volcanos(chat.ONACTION, {list: [[ice.VIEW, "横向", "纵向"], [html.SIZE, 24, 32, 48], [html.MARGIN, 10, 30, 50]], diff --git a/plugin/story/trend.js b/plugin/story/trend.js index 6430bcbc..735d7796 100644 --- a/plugin/story/trend.js +++ b/plugin/story/trend.js @@ -37,7 +37,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.page.requireDraw(ca layout: function(can) { can.onmotion.toggle(can, can._option, !can.user.isMobile || !can.isFullMode()) can.Conf(ice.VIEW) && can.Action(ice.VIEW, can.Conf(ice.VIEW)) - can.onaction[can.Action(ice.VIEW)]({}, can) + can.core.CallFunc(can.onaction[can.Action(ice.VIEW)], [{}, can]) }, transform: function(can, target) { target.Value("transform", "translate(0, "+parseInt(can.ConfHeight())+") scale(1, -1)")