aboutsummaryrefslogtreecommitdiffstats
path: root/speeddial.js
blob: 7c7a134898ccd3d13a966c461a1ba44089b1a81a (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
// Vimperator plugin: "SpeedDial"
// Last Change: 22-Oct-2008. Jan 2008
// License: Creative Commons
// Maintainer: mattn <mattn.jp@gmail.com> - http://mattn.kaoriya.net/
//
// Commands:
//  :sd 1
//      open url registered as 1 in current tab.
//  :sd! 1
//      open url registered as 1 in new tab.
// Note:
//  you can able to complete urls with tab key.

(function() {
    const pref = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefBranch);
    var nsISupportsString = Components.interfaces.nsISupportsWString ||
                            Components.interfaces.nsISupportsString;
    liberator.modules.commands.addUserCommand(["sd", "speeddial"], "speeddial",
        function(arg, special){
            arg = arg.string;
            if (arg.match(/^[0-9]+$/))
                arg = pref.getComplexValue("extensions.speeddial.thumbnail-" + arg + "-url", nsISupportsString).data;
            else
            if (arg.length == 0)
                arg = "chrome://speeddial/content/speeddial.xul";
            liberator.open(arg, special ? liberator.NEW_TAB : liberator.CURRENT_TAB);
        }, {
            completer: function(filter) {
                candidates = [];
                for (var n = 1; n <= 9; n++) {
                    var url = pref.getComplexValue("extensions.speeddial.thumbnail-" + n + "-url", nsISupportsString).data;
                    var label = pref.getComplexValue("extensions.speeddial.thumbnail-" + n + "-label", nsISupportsString).data;
                    if (url && label) candidates.push([url, n + ":" + label]);
                }
                return [0,candidates];
            }
        }
    );
})();
// vim:sw=4 ts=4 et:
n class="mf">2.0pre</minVersion> <maxVersion>2.0pre</maxVersion> <detail><![CDATA[ == Commands == +mkcolor <FILENAME> ]]></detail> </VimperatorPlugin>; // }}} (function () { function rmrem (s) s.replace(/\s*\/\*.*\*\//g, ''); function pad (s, max) (s.length < max ? pad(s + ' ', max) : s); function getcolor () { let result = []; let max = 0; for (let h in highlight) max = Math.max(h.class.length, max); for (let h in highlight) result.push(h.value ? 'hi ' + pad(h.class, max) + ' ' + rmrem(h.value) : '// hi ' + h.class); return result.join("\n"); } commands.addUserCommand( ['mkco[lor]'], 'Write current highlights to the specified file', function (args) { let filename = args[0]; let file = io.getFile(filename); if (file.exists() && !args.bang) return liberator.echoerr(filename + ' already exists (add ! to override)'); io.writeFile(file, getcolor()); }, { argCount: '1', bang: true, completer: function (context) completion.file(context, true) }, true ); })(); // vim:sw=2 ts=2 et si fdm=marker: