diff options
Diffstat (limited to 'vimperator/.vimperator/plugin')
-rw-r--r-- | vimperator/.vimperator/plugin/PDF.js.js | 250 | ||||
-rw-r--r-- | vimperator/.vimperator/plugin/_smooziee.js | 171 |
2 files changed, 0 insertions, 421 deletions
diff --git a/vimperator/.vimperator/plugin/PDF.js.js b/vimperator/.vimperator/plugin/PDF.js.js deleted file mode 100644 index 0f04981..0000000 --- a/vimperator/.vimperator/plugin/PDF.js.js +++ /dev/null @@ -1,250 +0,0 @@ -/* NEW BSD LICENSE {{{ -Copyright (c) 2012, anekos. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. - - -################################################################################### -# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license # -# に参考になる日本語訳がありますが、有効なのは上記英文となります。 # -################################################################################### - -}}} */ - -// INFO {{{ -let INFO = xml` -<plugin name="PDF.js.js" version="1.0.0" - href="http://vimpr.github.com/" - summary="PDF.js controller." - lang="en-US" - xmlns="http://vimperator.org/namespaces/liberator"> - <author email="anekos@snca.net">anekos</author> - <license>New BSD License</license> - <project name="Vimperator" minVersion="3.0"/> - <p></p> - <item> - <tags>:pdfjs-mapping-sample</tags> - <description><p>mapping sample</p><code><![CDATA[ - nnoremap -urls ^\\.pdf$ i :<C-u>pdfjs index<Space> - nnoremap -urls ^\\.pdf$ z :<C-u>pdfjs zoom<Space> - ]]></code></description> - </item> -</plugin>`; -// }}} - -(function () { - - let scrollCount = 1; - - // Functions {{{ - - function getScrollHeight (count) { - let base = content.innerHeight / 10; - if (count > 0) - scrollCount = count; - return base * scrollCount; - } - - function addMap (keys, desc, action) { - mappings.addUserMap( - [modes.NORMAL], - keys, - desc + ' - PDF.js.js', - action, - { - count: true, - matchingUrls: /\.pdf$/ - } - ); - } - - function getOutline () { - return Array.slice(content.document.querySelector('#outlineView').querySelectorAll('.outlineItem > a')); - } - - function getOutlineLevel (node) { - let level = 0; - while (node && (node.getAttribute('id') != 'outlineView')) { - node = node.parentNode; - level++; - } - return node ? (level / 2): 0; - } - - function nSpace (level) { - let res = ''; - for (i = 0; i < level; i++) - res += ' '; - return res; - } - - // }}} - - // Mappings {{{ - - addMap( - ['j'], - 'Scroll Down', - function (count) { - content.document.querySelector('#viewerContainer').scrollTop += getScrollHeight(count); - } - ); - - addMap( - ['k'], - 'Scroll up', - function (count) { - content.document.querySelector('#viewerContainer').scrollTop -= getScrollHeight(count); - } - ); - - addMap( - ['n'], - 'Next page', - function (count) { - content.window.wrappedJSObject.PDFView.page += (count > 0 ? count : 1); - } - ); - - addMap( - ['p'], - 'Previous page', - function (count) { - content.window.wrappedJSObject.PDFView.page -= (count > 0 ? count : 1); - } - ); - - addMap( - ['gg'], - 'Go to page top or N page.', - function (count) { - if (count > 0) - content.window.wrappedJSObject.PDFView.page = count; - else - content.window.wrappedJSObject.PDFView.page = 1; - } - ); - - addMap( - ['zh'], - 'Fit to page.', - function (count) { - liberator.execute('pdfjs zoom page-fit'); - } - ); - - addMap( - ['zw'], - 'Fit to page to width.', - function (count) { - liberator.execute('pdfjs zoom page-width'); - } - ); - - addMap( - ['za'], - 'Fit to page to width.', - function (count) { - liberator.execute('pdfjs zoom auto'); - } - ); - - addMap( - ['zz'], - 'Fit to page to width.', - function (count) { - commandline.open('', 'pdfjs zoom ', modes.EX); - } - ); - - // }}} - - commands.addUserCommand( // {{{ - ['pdfjs'], - 'PDF.js', - function () void 'Meow is best', - { - subCommands: [ - new Command( - ['i[ndex]'], - 'Jump page by index', - function (args) { - let index = args.literalArg.match(/^#(\d+)$/); - if (index) { - let os = getOutline(); - buffer.followLink(os[parseInt(index[1], 10)], liberator.CURRENT_TAB); - } else { - content.window.wrappedJSObject.PDFView.page = parseInt(args.literalArg, 10); - } - }, - { - literal: 0, - completer: function (context, args) { - function desc (o) { - const PageRE = /#page=(\d+)\&/; - if (o.href && PageRE.test(o.href)) { - return `${nSpace(getOutlineLevel(o))} ${o.textContent} (p${o.href.match(PageRE)[1]})`; - } else { - return `${nSpace(getOutlineLevel(o))} ${o.textContent}`; - } - } - - let os = getOutline(); - context.compare = void 0; - context.filters = [CompletionContext.Filter.textDescription]; - context.completions = [ - [ - '#' + i, desc(o) - ] - for ([i, o] in Iterator(os)) - ]; - } - } - ), - - new Command( - ['z[oom]'], - 'Zoom', - function (args) { - content.window.wrappedJSObject.PDFView.parseScale(args.literalArg); - }, - { - literal: 0, - completer: function (context, args) { - let os = Array.slice(content.document.querySelector('#scaleSelect').querySelectorAll('option')); - context.completions = [ - [o.value, o.textContent] - for ([, o] in Iterator(os)) - ]; - } - } - ) - ] - }, - true - ); // }}} - -})(); - -// vim:sw=2 ts=2 et si fdm=marker: diff --git a/vimperator/.vimperator/plugin/_smooziee.js b/vimperator/.vimperator/plugin/_smooziee.js deleted file mode 100644 index a8af10d..0000000 --- a/vimperator/.vimperator/plugin/_smooziee.js +++ /dev/null @@ -1,171 +0,0 @@ -// -// _smooziee.js -// -// LICENSE: {{{ -// Copyright (c) 2009 snaka<snaka.gml@gmail.com> -// -// distributable under the terms of an MIT-style license. -// http://www.opensource.jp/licenses/mit-license.html -// }}} -// -// INFO: {{{ -var INFO = xml` -<plugin name="smooziee" version="0.10.2" - href="https://github.com/vimpr/vimperator-plugins/raw/master/_smooziee.js" - summary="j,kキーでのスクロールをスムースに" - lang="en_US" - xmlns="http://vimperator.org/namespaces/liberator"> - <author email="snaka.gml@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/snaka72/">snaka</author> - <project name="Vimperator" minVersion="3.6"/> - <license>MIT style license</license> - <p>j,k key scrolling to be smoothly.</p> - <h3 tag="smooziee_global_variables">Global vriables</h3> - <p>You can configure following variable as you like.</p> - <dl> - <dt>smooziee_scroll_amount</dt><dd>Scrolling amount(unit:px). Default value is 400px.</dd> - <dt>smooziee_interval</dt><dd>Scrolling interval(unit:ms). Default value is 20ms.</dd> - </dl> - <h3 tag="smooziee_example">Example</h3> - <p>Set scroll amount is 300px and interval is 10ms.</p> - <code><ex><![CDATA[ - let g:smooziee_scroll_amount="300" - let g:smooziee_scroll_interval="10" - ]]></ex></code> - <h3 tag="smooziee_API">API</h3> - <code>smooziee.smoothScrollBy(amount);</code> - <p>Example</p> - <code><ex><![CDATA[ - :js liberator.plugins.smooziee.smoothScrollBy(600) - :js liberator.plugins.smooziee.smoothScrollBy(-600) - ]]></ex></code> -</plugin> -<plugin name="smooziee" version="0.10.2" - href="https://github.com/vimpr/vimperator-plugins/raw/master/_smooziee.js" - summary="j,kキーでのスクロールをスムースに" - lang="ja" - xmlns="http://vimperator.org/namespaces/liberator"> - <author email="snaka.gml@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/snaka72/">snaka</author> - <project name="Vimperator" minVersion="3.6"/> - <license>MIT style license</license> - <p>普段のj,kキーのスクロールをLDRizeライクにスムースにします。</p> - <h3 tag="smooziee_global_variables">グローバル変数</h3> - <p>以下の変数を.vimperatorrcなどで設定することで動作を調整することができます。</p> - <dl> - <dt>smooziee_scroll_amount</dt> - <dd>1回にスクロールする幅です(単位:ピクセル)。デフォルトは"400"です。</dd> - <dt>smooziee_interval</dt> - <dd>スクロール時のアニメーションのインターバルです(単位:ミリ秒)。 - "1"以上の値を設定します。デフォルトは"20"です。</dd> - </dl> - <h3 tag="smooziee_example">設定例</h3> - <p>スクロール量を300pxに、インターバルを10msに設定します。</p> - <code><ex><![CDATA[ - let g:smooziee_scroll_amount="300" - let g:smooziee_scroll_interval="10" - ]]></ex></code> - <h3 tag="smooziee_API">API</h3> - <p>他のキーにマップする場合やスクリプトから呼び出せるようAPIを用意してます。</p> - <code>smooziee.smoothScrollBy(amount);</code> - <p>Example</p> - <code><ex><![CDATA[ - :js liberator.plugins.smooziee.smoothScrollBy(600) - :js liberator.plugins.smooziee.smoothScrollBy(-600) - ]]></ex></code> - <h3 tag="soomziee_ToDo">ToDo</h3> - <ul> - <li>読み込みの順番によっては他のプラグインと競合する可能性があるのをなんとかしたい。</li> - </ul> -</plugin>`; -// }}} - -let self = liberator.plugins.smooziee = (function(){ - - // Mappings {{{ -/* mappings.addUserMap( - [modes.NORMAL], - ["j"], - "Smooth scroll down", - function(count){ - self.smoothScrollBy(getScrollAmount() * (count || 1)); - }, - { - count: true - } - ); - mappings.addUserMap( - [modes.NORMAL], - ["k"], - "Smooth scroll up", - function(count){ - self.smoothScrollBy(getScrollAmount() * -(count || 1)); - }, - { - count: true - } - ); -*/ - - mappings.addUserMap( - [modes.NORMAL], - ["d"], - "Smooth scroll down page", - function(count){ - self.smoothScrollBy(getScrollAmount() * 3.5 * (count || 1)); - }, - { - count: true - } - ); - mappings.addUserMap( - [modes.NORMAL], - ["u"], - "Smooth scroll up page", - function(count){ - self.smoothScrollBy(getScrollAmount() * 3.5 * -(count || 1)); - }, - { - count: true - } - ); - // }}} - // PUBLIC {{{ - var PUBLICS = { - smoothScrollBy: function(moment) { - win = Buffer.findScrollableWindow(); - interval = window.eval(liberator.globalVariables.smooziee_scroll_interval || '20'); - destY = win.scrollY + moment; - clearTimeout(next); - smoothScroll(moment); - } - } - - // }}} - // PRIVATE {{{ - var next; - var destY; - var win; - var interval; - - function getScrollAmount() window.eval(liberator.globalVariables.smooziee_scroll_amount || '400'); - - function smoothScroll(moment) { - if (moment > 0) - moment = Math.floor(moment / 2); - else - moment = Math.ceil(moment / 2); - - win.scrollBy(0, moment); - - if (Math.abs(moment) < 1) { - setTimeout(makeScrollTo(win.scrollX, destY), interval); - destY = null; - return; - } - next = setTimeout(function() smoothScroll(moment), interval); - } - - function makeScrollTo(x, y) function() win.scrollTo(x, y); - // }}} - return PUBLICS; -})(); -// vim: sw=2 ts=2 et si fdm=marker: |