aboutsummaryrefslogtreecommitdiffstats
path: root/echopy.js
diff options
context:
space:
mode:
authoranekos2008-11-11 15:03:22 +0000
committeranekos2008-11-11 15:03:22 +0000
commit6541b24d979e9e04d4c769db0b23bb3a827140b6 (patch)
tree9bf3f94b04d9e3ffbe5f7ca3d3851248b7f9823d /echopy.js
parent0924c9ebbc03c13607c6bf06365b44f55a9c4138 (diff)
downloadvimperator-plugins-6541b24d979e9e04d4c769db0b23bb3a827140b6.tar.bz2
Initial release: echo しつつ黒髪ロングへコピー
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@23255 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'echopy.js')
-rw-r--r--echopy.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/echopy.js b/echopy.js
new file mode 100644
index 0000000..908f14b
--- /dev/null
+++ b/echopy.js
@@ -0,0 +1,61 @@
+// ==VimperatorPlugin==
+// @name echo and copy
+// @description echo and copy
+// @description-ja echo and copy
+// @license Creative Commons 2.1 (Attribution + Share Alike)
+// @version 1.0
+// @author anekos (anekos@snca.net)
+// @maxVersion 2.0pre
+// @minVersion 2.0pre
+// ==/VimperatorPlugin==
+//
+// Usage:
+// :echo <EXPRESSION>
+// echo with copy (to clipboard).
+//
+// Usage-ja:
+// :echo <EXPRESSION>
+// echo $B$9$k$7$FF1;~$K%/%j%C%W%\!<%I$K%3%T!<(B
+//
+// Links:
+// http://d.hatena.ne.jp/nokturnalmortum/20081111#1226414487
+
+(function () {
+
+ function neko (obj, useColor) {
+ switch (typeof obj) {
+ case 'object':
+ return liberator.modules.util.objectToString(obj, useColor);
+ case 'function':
+ return liberator.modules.util.escapeHTML(obj.toString());
+ case 'number':
+ case 'boolean':
+ return '' + obj;
+ case 'undefined':
+ return 'undefined';
+ }
+ return obj;
+ }
+
+ let echo = commands.get('echo');
+ let original_action = echo.action;
+
+ echo.action = function (arg, bang) {
+ if (bang) {
+ try {
+ if (arg.string == '')
+ return;
+ let obj = liberator.eval(arg.string);
+ liberator.echo(neko(obj, true));
+ liberator.modules.util.copyToClipboard(neko(obj, false));
+ } catch (e) {
+ liberator.echoerr(e);
+ }
+ } else {
+ original_action.apply(this, arguments);
+ }
+ };
+ echo.bang = true;
+
+
+})();