From 0ad3e4ca3d63caee9e5a30b966ae9f399f345b84 Mon Sep 17 00:00:00 2001 From: shylinux Date: Thu, 20 Apr 2023 21:00:49 +0800 Subject: [PATCH] opt vimer.js --- frame.js | 20 +++-- lib/core.js | 3 +- panel/action.js | 2 +- plugin/local/code/inner.css | 7 +- plugin/local/code/inner.js | 158 +++++++++++++++--------------------- plugin/local/code/vimer.css | 2 - plugin/local/code/vimer.js | 7 +- plugin/local/team/plan.js | 1 + plugin/state.js | 7 +- proto.js | 2 +- 10 files changed, 94 insertions(+), 115 deletions(-) diff --git a/frame.js b/frame.js index 868e37a7..84cf3682 100644 --- a/frame.js +++ b/frame.js @@ -243,7 +243,8 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { action === false || sub.onappend._status(sub, sub.onexport&&sub.onexport.list||msg.Option(ice.MSG_STATUS)), can.user.isMobile || sub.onappend.tools(sub, msg) can.isCmdMode() && can.onappend.style(can, can.misc.Search(can, ctx.STYLE), can._target) can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, "") - if (can.isCmdMode()) { can.onimport.size(can, can.page.height(), can.page.width(), true) } + can.onappend.style(sub, sub.Conf(ctx.STYLE)) + // if (can.isCmdMode()) { can.onimport.size(can, can.page.height(), can.page.width(), true) } can.core.List([chat.FLOAT, chat.FULL, chat.CMD], function(mode) { can.page.ClassList.has(can, can._target, mode) && sub.onlayout[mode](sub) }) can.onmotion.story.auto(can, can._output), can.onexport.output(can, msg), can.base.isFunc(cb) && cb(msg) }, target: output}) @@ -414,13 +415,14 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { 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) { if (can.base.isArray(item)) { return } - if (can.base.isObject(item)) { var meta = item; item = item._index } if (item == "plug") { return } + if (can.base.isObject(item)) { var meta = item; item = item._index } + // if (item == "plug") { return } var target = ui[item]; if (!can.page.isDisplay(target)) { return } if (item == html.CONTENT) { return defer.push(function() { can.page.style(can, target, html.HEIGHT, content_height = height, html.WIDTH, content_width = width) }) } - if (item == html.PROFILE) { width -= 1 } - if (item == html.PROJECT) { width -= 1 } + // if (item == html.PROFILE) { width -= 1 } + // if (item == html.PROJECT) { width -= 1 } if (type == FLOW) { var h = calc(item, target.offsetHeight, height) - if (can.base.isObject(meta)) { meta.layout(h, width) } + if (can.base.isObject(meta) && meta.layout) { meta.layout(h, width) } 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) } @@ -606,7 +608,13 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { } can.core.Item(list, function(key) { delete(list[key]) }) var key = can.base.Time(null, "%H:%M:%S.%s"); can.onmotion.delay(can, list[key] = function() { list[key] && cb() }, interval) }, - delay: function(can, cb, interval, key) { if (!key) { return can.core.Timer(interval||30, cb) } + delay: function(can, cb, interval, key) { + if (!key) { + if (interval === 0) { + return cb() + } + return can.core.Timer(interval||30, cb) + } can._delay_list = can._delay_list||shy({}, []) var last = can._delay_list.meta[key]||0, self = can._delay_list.meta[key] = can._delay_list.list.push(cb) can.core.Timer(interval||30, function() { cb(self, last, can._delay_list.meta[key]) }) diff --git a/lib/core.js b/lib/core.js index 6b81babb..4c5cf3a9 100644 --- a/lib/core.js +++ b/lib/core.js @@ -119,6 +119,7 @@ Volcanos("core", { function loop(i) { timer.stop || i >= interval.length && interval.length >= 0 || cb(timer, interval.interval||interval[i], i, interval)? typeof cbs == lang.FUNCTION && cbs(timer, interval): setTimeout(function() { loop(i+1) }, interval.interval||interval[i+1]) } interval = typeof interval == lang.OBJECT? interval: [interval]; if (interval.interval == 0) { return cb(), timer } - return typeof cb == lang.FUNCTION && setTimeout(function() { loop(0) }, interval.delay||interval.interval/2||interval[0]), timer + var delay = interval.delay||interval.interval/2||interval[0] + return typeof cb == lang.FUNCTION && setTimeout(function() { loop(0) }, delay), timer }), }) diff --git a/panel/action.js b/panel/action.js index 884adae6..8fc2c9e0 100644 --- a/panel/action.js +++ b/panel/action.js @@ -42,7 +42,7 @@ Volcanos(chat.ONACTION, {_init: function(can, target) { }); if (!can.Conf(chat.TOOL) && !can.user.mod.isCmd) { return } can._names = location.pathname can.Conf(chat.TOOL)? can.onappend.layout(can, can.core.List(can.Conf(chat.TOOL), function(item, index, list) { item.type = chat.PLUGIN if (list.length == 1) { - item.height = can.page.height()-2*html.ACTION_HEIGHT, item.width = can.page.width() + item.height = can.page.height(), item.width = can.page.width() can.user.title(item.index), can.onaction._onaction_cmd(can), item.mode = chat.CMD, item.opts = can.misc.Search(can) } return item }), FLOW).layout(window.innerHeight, window.innerWidth): can.runAction(can.request(), ctx.COMMAND, [], function(msg) { diff --git a/plugin/local/code/inner.css b/plugin/local/code/inner.css index eea59fb8..8eed21df 100644 --- a/plugin/local/code/inner.css +++ b/plugin/local/code/inner.css @@ -77,11 +77,10 @@ div.path span.item { padding:5px; } div.carte.path.float { font-size:14px; border-radius:0; } div.carte.path.float div.item { padding:5px; } div.carte.cmd.float { font-size:14px; border-radius:0; } div.cmd.path.float div.item { padding:5px; } div.vimer.open.float td:first-child { display:none; } +div.layout.flex>input.current { clear:both; } tr.line>td.line { user-select:none; } tr.line>td.line { text-align:right; padding:0 10px; position:sticky; left:0; } -tr.line>td.text { line-height:20px; white-space:pre; padding-left:10px; cursor:text; } +tr.line>td.text { line-height:20px; white-space:pre; padding-left:10px; width:100%; cursor:text; } tr.line.delete { background-color:#ff000036; color:gray; } tr.line.insert { background-color:#00800036; } -fieldset.inner>div.output>div.project div.item.modify { background-color:#00800036; } -body.black tr.line.select { background-color:darkblue; } body.black tr.line:hover { background-color:darkblue; } -body.white tr.line.select { background-color:dimgray; } body.white tr.line:hover { background-color:dimgray; } +fieldset.inner>div.output>div.project div.item.modify { background-color:#00800036; } \ No newline at end of file diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index ddd3b6fe..7ec1d6a3 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -121,7 +121,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { var paths = can.core.Sp }), can.ui.content._plugin = msg._plugin, can.ui.profile._plugin = msg._profile can.page.SelectChild(can, can.ui._profile.parentNode, can.page.Keys(html.DIV_PROFILE, [[[html.IFRAME, html.PROFILE]]]), function(target) { if (can.onmotion.toggle(can, target, target == msg._profile)) { can.ui.profile = msg._profile } - }), can.onimport.layout(can), can.ui.current && can.onmotion.toggle(can, can.ui.current, !isIndex() && !isSpace()) + }) + can.onimport.layout(can), can.ui.current && can.onmotion.toggle(can, can.ui.current, !isIndex() && !isSpace()) skip || can.onmotion.delay(can, function() { can.onaction.selectLine(can, can.Option(nfs.LINE), true) }), can.base.isFunc(cb) && cb(), cb = null var ls = can.onexport.path(can).split(nfs.PS); if (ls.length > 4) { ls = [ls.slice(0, 2).join(nfs.PS)+"/.../"+ls.slice(-2).join(nfs.PS)] } can.Status(kit.Dict(nfs.FILE, ls.join(nfs.PS))) @@ -144,9 +145,13 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { var paths = can.core.Sp history: function(can, record) { can.base.Eq(record, can.db.history[can.db.history.length-1], mdb.TEXT) || can.db.history.push(record) return can.Status(ice.BACK, can.db.history.length), record }, - project: function(can, path) { can.onmotion.clear(can, can.ui.project), can.onimport.zone(can, can.core.Item(can.onfigure, function(name, cb) { - if (can.base.isFunc(cb)) { return {name: name, _trans: can.onfigure._trans? can.onfigure._trans[name]||"": "", _init: function(target, zone) { return cb(can, target, zone, path) }} } - }), can.ui.project) }, + project: function(can, path) { + can.page.style(can, can.ui.project, "visibility", "hidden") + can.onmotion.clear(can, can.ui.project), can.onimport.zone(can, can.core.Item(can.onfigure, function(name, cb) { + if (can.base.isFunc(cb)) { return {name: name, _trans: can.onfigure._trans? can.onfigure._trans[name]||"": "", _init: function(target, zone) { return cb(can, target, zone, path) }} } + }), can.ui.project) + can.page.style(can, can.ui.project, "visibility", "visible") + }, profile: function(can, msg) { var _msg = can.db.tabview[can.onexport.keys(can)]; _msg.Option(html.WIDTH, msg.Option(html.WIDTH)||0.5) if (msg.Result().indexOf("