aboutsummaryrefslogtreecommitdiffstats
path: root/notifier/subject_liberator_echomsg.js
blob: b77f2ab5eef6226ca5caefa823085e791dca9c89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*** BEGIN LICENSE BLOCK {{{
    Copyright (c) 2009 suVene<suvene@zeromemory.info>

    distributable under the terms of an MIT-style license.
    http://www.opensource.jp/licenses/mit-license.html
}}}  END LICENSE BLOCK ***/
// PLUGIN_INFO//{{
var PLUGIN_INFO =
<VimperatorPlugin>
    <name>{NAME}</name>
    <description>liberator.echomsg notice.</description>
    <description lang="ja">liberator.echomsg 通知</description>
    <author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
    <version>0.1.1</version>
    <license>MIT</license>
    <minVersion>2.0pre</minVersion>
    <maxVersion>2.0pre</maxVersion>
    <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/subject_liberator_echomsg.js</updateURL>
    <detail><![CDATA[
== Settings ==
>||
liberator.globalVariables.subject_liberator_echomsg_filter = [
    'Auto commands for',
    '^autocommand'
];
||<
    ]]></detail>
</VimperatorPlugin>;
//}}}
(function() {

var notifier = liberator.plugins.notifier;
if (!notifier) return;

var libly = notifier.libly;
var $U = libly.$U;
var logger = $U.getLogger('subject_liberator_echomsg');

notifier.subject.register(notifier.Subject, {
    interval: 5,
    initialize: function() {
        this.original = liberator.echomsg;
        this.__updating__ = false;
        this.messages = [];
        this.filter = liberator.globalVariables.subject_liberator_echomsg_filter || [];

        var self = this;

        liberator.echomsg = function(message) {
            while (self.waiting)
                liberator.sleep(100);

            self.messages.push(message);
            return self.original.apply(null, arguments);
        };
    },
    check: function() {
        try {
            this.__updating__ = true;
            this.messages = this.messages.filter(function(m) !this.filter.some(function(f) m.indexOf(f) > -1 || m.match(f) ? true : false), this);
            if (!this.messages.length) return;

            let msg = '<ul><li>' + this.messages.join('</li><li>') + '</li></ul>';
            this.messages = [];

            this.notify(new notifier.Message('liberator.echomsg', msg));

        } finally {
            this.__updating__ = false;
        }
    },
    shutdown: function() {
        liberator.echomsg = this.original;
        this.__updating__ = false;
    }

});

})();
// vim: set fdm=marker sw=4 ts=4 sts=0 et:

n class="p">.call(target, {button:1, ctrlKey:true}); } else { liberator.open(target.node.uri, where); } closeMenus(target); liberator.modules.options.guioptions = manager.go; } function folderOpen(target){ target.firstChild.showPopup(); manager.quit(); manager.show(target.firstChild); } function toolbarOpen(target){ if (target.getAttribute('container') == 'true'){ folderOpen(target); return true; } else { itemOpen(target); } return false; } var hints = []; var toolbar; var current; var currentNum = 0; var useShift = false; var where = liberator.CURERNT_TAB; var manager = { get toolbar() getToolbar(), go: null, get where(){ return where; }, set where(value){ where = value; }, startup: function(where){ this.go = options.guioptions; options.guioptions += "b"; this.where = where; liberator.modules.modes.setCustomMode('BookmarksToolbar-Hint', function(){return;}, this.quit); this.show(); }, show:function(node){ liberator.modules.modes.set(liberator.modules.modes.CUSTOM,liberator.modules.modes.QUICK_HINT); hints = []; window.addEventListener('keypress',onKeyPress,true); current = node || getToolbar(); for (let i=0,l=current.childNodes.length; i<l; i++){ let button = current.childNodes[i]; if (button.localName == "menuseparator") continue; hints.push(button); let tooltip = createTooltip(); tooltip.showPopup(button, -1, -1,"tooltip","topleft","topright"); } updateSelector(); }, onEvent: function(event){ var key = liberator.modules.events.toString(event); switch(key){ case "<Esc>": case "<C-[>": closeMenus(current); liberator.modules.options.guioptions = this.go; break; case "<Return>": case "<Right>": if (toolbarOpen(hints[currentNum])) return; break; case "f": this.where = liberator.CURRENT_TAB; return; case "F": case "t": this.where = liberator.NEW_TAB; return; case "<Tab>": case "j": case "<Down>": case "<S-Tab>": case "k": case "<Up>": if (key == "j" || key == "<Tab>" || key == "<Down>"){ currentNum = hints.length -1 == currentNum ? 0 : currentNum + 1; } else { currentNum = currentNum == 0 ? hints.length -1 : currentNum - 1; } useShift = true; updateSelector(); return; case "l": if (hints[currentNum].getAttribute("container") == "true"){ folderOpen(hints[currentNum]); } return; case "<BS>": if (key == "<BS>" && currentNum > 0){ currentNum = Math.floor(currentNum / 10); updateSelector(); return; } case "h": if (current == this.toolbar){ closeMenus(current); liberator.modules.options.guioptions = this.go; this.quit(); } else { current.hidePopup(); clearTooltips(); this.show(current.parentNode.parentNode); } return; default: if (/^[0-9]$/.test(key)){ let num = parseInt(key,10); if (!useShift && currentNum) num += currentNum * 10; if (hints.length >= num*10){ currentNum = num - 1; updateSelector(); return; } if (hints[num-1]){ if (toolbarOpen(hints[num-1])) return; } } } liberator.plugins.bookmarkToolbarHints.quit(); }, quit: function(){ currentNum = 0; useShift = false; window.removeEventListener('keypress',onKeyPress,true); liberator.modules.modes.reset(true); while (tooltipbox.hasChildNodes()){ tooltipbox.firstChild.hidePopup(); tooltipbox.removeChild(tooltipbox.firstChild); } } }; var tooltipbox = document.createElement('box'); tooltipbox.setAttribute('id','liberator-tooltip-container'); //document.getElementById('liberator-container').appendChild(tooltipbox); document.getElementById('browser').appendChild(tooltipbox); return manager; })(); liberator.modules.mappings.addUserMap([liberator.modules.modes.NORMAL], ['<Leader>f'], 'Start Toolbar-HINTS (open current tab)', function(){ liberator.plugins.bookmarkToolbarHints.startup(liberator.CURRENT_TAB); }, { rhs: 'Bookmarks Toolbar-HINTS (current-tab)'} ); liberator.modules.mappings.addUserMap([liberator.modules.modes.NORMAL], ['<Leader>F'], 'Start Toolbar-HINTS (open new tab)', function(){ liberator.plugins.bookmarkToolbarHints.startup(liberator.NEW_TAB); }, { rhs: 'Bookmarks Toolbar-HINTS (new-tab)' } );