diff --git a/frame.js b/frame.js index 40d8b1c5..8d8ba456 100644 --- a/frame.js +++ b/frame.js @@ -498,9 +498,9 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }, target||can._output, field) }, _float: function(can, index, args, cb) { can.onappend.plugin(can, {index: index, args: args, mode: chat.FLOAT}, function(sub) { - can.getActionSize(function(left, top, width, height) { var offset = can.user.isMobile? 0: height/4 - sub.onimport.size(sub, sub.ConfHeight(height-offset), sub.ConfWidth(width*3/4), true) - can.onmotion.move(can, sub._target, {left: left||0, top: (top||0)+offset}), can.base.isFunc(cb) && cb(sub) + can.getActionSize(function(left, top, width, height) { + sub.onimport.size(sub, sub.ConfHeight(height*3/4), sub.ConfWidth(width/2), true) + can.onmotion.move(can, sub._target, {left: width/2, top: height/4}), can.base.isFunc(cb) && cb(sub) }), sub.onaction.close = function() { can.page.Remove(can, sub._target) } }, can._root._target) }, figure: function(can, meta, target, cb) { if (meta.type == html.SELECT || meta.type == html.BUTTON) { return } @@ -572,7 +572,16 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { story: { _hash: { spark: function(can, meta, target) { - meta[mdb.NAME] == html.INNER? can.onmotion.copy(can, target): can.page.Select(can, target, html.SPAN, function(item) { can.onmotion.copy(can, item) }) + meta[mdb.NAME] == html.INNER? can.onmotion.copy(can, target): can.page.Select(can, target, html.SPAN, function(item) { can.onmotion.copy(can, item, function(event) { + if (event.metaKey) { + if (item.innerText.indexOf(web.HTTP) == 0) { return can.user.open(item.innerText) } + if (item.innerText.indexOf("vim ") == 0) { + can.onappend._float(can, web.CODE_VIMER, can.misc.SplitPath(can, item.innerText.split(" ")[1]), function() {}) + } else { + meta.name == "shell" && can.onappend._float(can, web.CODE_XTERM, ["sh"], function() {}) + } + } + }) }) }, }, auto: function(can, target) { var that = this; target = target||can._output @@ -670,7 +679,7 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { focus: function(can, target, value) { if (!target) { return } if (!can.base.isUndefined(value)) { target.value = value } target.focus(), can.onmotion.selectRange(target) }, selectRange: function(target) { target && target.setSelectionRange && target.setSelectionRange(0, target.value.length) }, - copy: function(can, target, cb) { target.title = "点击复制", target.onclick = function(event) { + copy: function(can, target, cb) { target.title = "点击复制,或 Command + Click 打开应用", target.onclick = function(event) { can.user.copy(event, can, target.innerText), can.base.isFunc(cb) && cb(event) can.onkeymap.prevent(event) } }, diff --git a/panel/search.js b/panel/search.js index 24da1dc0..10287cb2 100644 --- a/panel/search.js +++ b/panel/search.js @@ -52,6 +52,7 @@ Volcanos(chat.ONACTION, {_init: function(can) { can.onmotion.hidden(can) }, list if (data.type == ssh.SHELL) { meta = {index: web.CODE_XTERM, args: [data.text]} } if (data.type == ctx.INDEX) { meta = {index: data.text.split(mdb.FS)[0], args: data.text.split(mdb.FS).slice(1) } } if (data.type == nfs.FILE) { meta = {index: web.CODE_VIMER, args: can.misc.SplitPath(can, data.text)} } + if (data.type == nfs.SHY) { meta = {index: web.WIKI_WORD, args: data.name} } can.onappend.plugin(can, meta, function(sub) { can._plugins = (can._plugins||[]).concat(sub), sub.onimport.size(sub, can.ConfHeight(), can.ConfWidth()-1, true), sub.Focus() }, can.ui.profile) }, }) diff --git a/plugin/local/wiki/word.css b/plugin/local/wiki/word.css index a6b3aaab..346739d4 100644 --- a/plugin/local/wiki/word.css +++ b/plugin/local/wiki/word.css @@ -22,4 +22,7 @@ fieldset.word.play.float div.content.grid div.page { background-color:#a4cbecb5; fieldset.word.play.float h1 { text-align:center; } fieldset.word.play.float h2 { text-align:center; } fieldset.word.play.float h3 { text-align:center; } -div.story[data-type=spark] label { user-select:none; } \ No newline at end of file +div.story[data-type=spark] label { user-select:none; } +div.story[data-type=spark_tabs]>div.tabs>div.item { font-style:italic; padding:5px 20px; height:32px; float:left; } +div.story[data-type=spark_tabs]>div.tabs>div.item.select { border-bottom:blue solid 2px; } +div.story[data-type=spark_tabs]>div.story:not(.select) { display:none; } diff --git a/plugin/local/wiki/word.js b/plugin/local/wiki/word.js index 3070c183..6e7f6f5b 100644 --- a/plugin/local/wiki/word.js +++ b/plugin/local/wiki/word.js @@ -27,7 +27,16 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( title: function(can, meta, target) { can.isCmdMode() && target.tagName == "H1" && can.user.title(meta.text) }, spark: function(can, meta, target) { if (meta[mdb.NAME] == html.INNER) { return can.onmotion.copy(can, target) } - can.page.Select(can, target, html.SPAN, function(item) { can.onmotion.copy(can, item) }) + can.page.Select(can, target, html.SPAN, function(item) { can.onmotion.copy(can, item, function() { + meta.type == "shell" && can.onappend.float(can, {index: web.CODE_XTERM, args: ["sh"]}) + }) }) + }, + spark_tabs: function(can, meta, target) { var select + can.page.Select(can, target, "div.tabs>div.item", function(tabs, index) { + (index == 0 || can.user.isMacOSX && can.base.isIn(tabs.innerText, cli.DARWIN, "macos") || can.user.isWindows && tabs.innerText == cli.WINDOWS) && (select = tabs) + tabs.onclick = function() { can.onmotion.select(can, tabs.parentNode, "div.tabs>div.item", tabs), can.onmotion.select(can, target, "div.story", index) } + return tabs + }); select && select.click() }, field: function(can, meta, target, width) { var item = can.base.Obj(meta.meta); item.inputs = item.list, item.feature = item.meta can.onappend._init(can, item, [chat.PLUGIN_STATE_JS], function(sub) { diff --git a/proto.js b/proto.js index 1eaf9184..89583cc4 100644 --- a/proto.js +++ b/proto.js @@ -123,7 +123,7 @@ var nfs = { CONTENT: "content", RECENT: "recent", SCRIPT: "script", MODULE: "module", SOURCE: "source", TARGET: "target", REPOS: "repos", MASTER: "master", PATH: "path", FILE: "file", LINE: "line", SIZE: "size", OPENS: "opens", REPLACE: "replace", FROM: "from", TO: "to", - SVG: "svg", HTML: "html", CSS: "css", JS: "js", SH: "sh", GO: "go", CSV: "csv", JSON: "json", + SVG: "svg", HTML: "html", CSS: "css", JS: "js", SH: "sh", GO: "go", CSV: "csv", JSON: "json", SHY: "shy", TXT: "txt", PNG: "png", WEBM: "webm", _CSS: ".css", _JS: ".js", DF: ice.DF, PS: ice.PS, PT: ice.PT, @@ -140,6 +140,7 @@ var cli = { MAKE: "make", MAIN: "main", EXEC: "exec", DONE: "done", COST: "cost", FROM: "from", CLEAR: "clear", PLAY: "play", OPENS: "opens", + LINUX: "linux", DARWIN: "darwin", WINDOWS: "windows", } var log = { INFO: "info", WARN: "warn", ERROR: "error", DEBUG: "debug", TRACE: "trace",