From 2c461a86ca2e64548750857976176272814082ac Mon Sep 17 00:00:00 2001 From: snaka Date: Sun, 12 Apr 2009 14:57:55 +0000 Subject: Remove jsh.js. Because it is premature work. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@32317 d0d07461-0603-4401-acd4-de1884942a52 --- jsh.js | 156 ----------------------------------------------------------------- 1 file changed, 156 deletions(-) delete mode 100644 jsh.js diff --git a/jsh.js b/jsh.js deleted file mode 100644 index 1c1d78e..0000000 --- a/jsh.js +++ /dev/null @@ -1,156 +0,0 @@ -// -// jsh.js -// -// LICENSE: {{{ -// Copyright (c) 2009 snaka -// -// Distributable under the terms of an MIT-style license. -// http://www.opensource.jp/licenses/mit-license.html -// }}} -// PLUGIN_INFO {{{ -var PLUGIN_INFO = - jsh - Simple javascript shell - 簡易Javascriptシェル - 2.0pre - 2.0 - http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/jsh.js - snaka - MIT style license - 0.1 - || - :jsh - ||< - - == Global variables == - - == Options == - - == ToDo == - - ]]> - || - :jsh - ||< - - == Global variables == - - == Options == - - == ToDo == - - ]]> -; -// }}} - -liberator.plugins.jsh = (function() { - // PUBLIC {{{ - const self = { - start: function() { - liberator.echo("*** Javascript SHell - Commands : quit() / cls() ***"); - waitForInput(); - } - }; - // }}} - // COMMAND {{{ - commands.addUserCommand( - ["jsh"], - "Simple javascript shell", - function() self.start(), - null, - true // for DEBUG - ); - // }}} - // PRIVATE {{{ - let shellContext = libly.$U.extend({ - quit : cmdQuit, - exit : cmdQuit, // alias as 'quit()' - cls : cmdCls, - echo : liberator.echo, - $LXs : plugins.libly.$U.getNodesFromXPath, - $LX : plugins.libly.$U.getFirstNodeFromXPath - }, liberator); - - const STATUS = { - NORMAL: '__JAVASCRIPT_SHELL_NORMAL__', - QUIT : '__JAVASCRIPT_SHELL_QUIT__' - }; - - let lastStatus = STATUS.NORMAL; - - function waitForInput() { - commandline.open("js:", "", modes.JSH); - } - - function cmdCls() { - // TODO Is this correct? - commandline.close(); - waitForInput(); - } - - function cmdQuit() { - commandline.close(); - throw STATUS.QUIT; - } - - // TODO:Should move to _libly.js ? - function pp(value) { - let result; - - if (!value) - return ''; - - if (typeof value === 'object') { - result = util.objectToString(value, true); - } else if (typeof value === 'function') { - result =
{value.toString()}
; - } else if (typeof value === 'string' && /\n/.test(value)) { - result = {value}; - } else { - result = String(value); - } - - liberator.echo(result, commandline.FORCE_MULTILINE); - } - - // }}} - // MODE {{{ - modules.modes.addMode("JSH", true); - liberator.registerCallback("cancel", modes.JSH, function(str) { - liberator.echo("CANCELED."); - }); - - liberator.registerCallback("submit", modes.JSH, function(str) { - try { - var result = liberator.eval(str, shellContext); - pp(result); - } catch(e) { - if (e == STATUS.QUIT) - return; - liberator.echoerr(e); - } - (function waitForOutput() { - setTimeout( function() modes.main == modes.NORMAL - ? waitForInput() - : waitForOutput(), - 500 ); - })(); - }); - - liberator.registerCallback("complete", modes.JSH, function(context) { - context.fork("jsh", 0, liberator.modules.completion, "javascript"); - }); - // }}} - return self; -})(); -// vim: sw=2 ts=2 et si fdm=marker: -- cgit v1.2.3