diff options
author | anekos | 2010-03-02 19:37:18 +0000 |
---|---|---|
committer | anekos | 2010-03-02 19:37:18 +0000 |
commit | 61f69f4434273a94fbcb59d53d9bb8c8a7a0d0f9 (patch) | |
tree | cf06ee756b4ec1b6d6352aa55f64a09b1ef435f8 /feedSomeKeys_3.js | |
parent | 581303a74e5ffa2990a59ee5f8474ac5fc233a93 (diff) | |
download | vimperator-plugins-61f69f4434273a94fbcb59d53d9bb8c8a7a0d0f9.tar.bz2 |
fmapc の機能追加 && funmap 実装
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36908 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'feedSomeKeys_3.js')
-rwxr-xr-x | feedSomeKeys_3.js | 92 |
1 files changed, 70 insertions, 22 deletions
diff --git a/feedSomeKeys_3.js b/feedSomeKeys_3.js index 29772d4..f0285ee 100755 --- a/feedSomeKeys_3.js +++ b/feedSomeKeys_3.js @@ -39,7 +39,7 @@ let PLUGIN_INFO = <name lang="ja">feedSomeKeys 3</name> <description>feed some defined key events into the Web content</description> <description lang="ja">キーイベントをWebコンテンツ側に送る</description> - <version>1.3.0</version> + <version>1.4.0</version> <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> <license>new BSD License (Please read the source code comments of this plugin)</license> <license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license> @@ -79,7 +79,7 @@ lazy fmaps -u='http://code.google.com/p/vimperator-labs/issues/detail' u // }}} // INFO {{{ let INFO = -<plugin name="feedSomeKeys" version="1.3.0" +<plugin name="feedSomeKeys" version="1.4.0" href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/feedSomeKeys_3.js" summary="Feed some defined key events into the Web content" xmlns="http://vimperator.org/namespaces/liberator"> @@ -277,12 +277,28 @@ let INFO = function (values) (values && !values.some(function (value) !list.some(function (event) event === value))); - function clear (filter) { + function clear (patternOrUrl) { let mode = modes.NORMAL; mappings._user[mode] = [ map for each (map in mappings._user[mode]) - if (!map.feedSomeKeys) + if ( + !map.feedSomeKeys || + (patternOrUrl && !mappings._matchingUrlsTest(map, patternOrUrl)) + ) + ]; + } + + function unmap (filter, patternOrUrl) { + let mode = modes.NORMAL; + mappings._user[mode] = [ + map + for each (map in mappings._user[mode]) + if ( + !map.feedSomeKeys || + (filter && filter !== map.names[0]) || + (!mappings._matchingUrlsTest(map, patternOrUrl)) + ) ]; } @@ -319,6 +335,29 @@ let INFO = commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); } + function fmapCompleter (context, args) { + context.title = ['name', 'rhs & url']; + context.completions = [ + [ + map.names[0], + map.feedSomeKeys.rhs + ' for ' + (map.matchingUrls ? map.matchingUrls : 'Global') + ] + for each (map in gets()) + ]; + } + + function urlCompleter (context, args) { + let maps = gets(); + let uniq = {}; + return [ + (uniq[map.matchingUrls] = 1, [map.matchingUrls.source, map.names]) + for each (map in maps) + if (map.matchingUrls && !uniq[map.matchingUrls]) + ]; + } + + + 'fmap fmaps'.split(/\s+/).forEach(function (cmd) { let multi = cmd === 'fmaps'; @@ -379,7 +418,7 @@ let INFO = { literal: 0, options: [ - [['-urls', '-u'], commands.OPTION_STRING, regexpValidator], + [['-urls', '-u'], commands.OPTION_STRING, regexpValidator, urlCompleter], [['-desc', '-description'], commands.OPTION_STRING], [['-frame', '-f'], commands.OPTION_INT], [ @@ -392,20 +431,7 @@ let INFO = multi ? [[['-separator', '-s'], commands.OPTION_STRING]] : [] ), - completer: function (context, args) { - if (multi) - return; - if (args.length > 1) - return; - context.title = ['name', 'rhs & url']; - context.completions = [ - [ - map.names[0], - map.feedSomeKeys.rhs + ' for ' + (map.matchingUrls ? map.matchingUrls : 'Global') - ] - for each (map in gets()) - ]; - } + completer: multi ? null : fmapCompleter }, true ); @@ -414,10 +440,32 @@ let INFO = commands.addUserCommand( ['fmapc'], 'Clear fmappings', - function () { - clear(); + function (args) { + let urls = args['-urls']; + clear(urls && RegExp(urls)); + }, + { + options: [ + [['-urls', '-u'], commands.OPTION_STRING, regexpValidator, urlCompleter] + ] + }, + true + ); + + commands.addUserCommand( + ['funmap'], + 'Remove fmappings', + function (args) { + let urls = args['-urls']; + unmap(args.literalArg, urls && RegExp(urls)); + }, + { + literal: 0, + options: [ + [['-urls', '-u'], commands.OPTION_STRING, regexpValidator, urlCompleter] + ], + completer: fmapCompleter }, - {}, true ); |