aboutsummaryrefslogtreecommitdiffstats
path: root/uuid.js
blob: 4eea7be6f0bbef6a1ba4d20c172e637011d08db5 (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
// PLUGIN_INFO//{{{
var PLUGIN_INFO =
<VimperatorPlugin>
    <name>{NAME}</name>
    <description>UUID generator</description>
    <author mail="konbu.komuro@gmail.com" homepage="http://d.hatena.ne.jp/hogelog/">hogelog</author>
    <version>0.1</version>
    <minVersion>2.0pre</minVersion>
    <maxVersion>2.0pre</maxVersion>
    <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/uuid.js</updateURL>
    <detail><![CDATA[

== COMMANDS ==
uuid:
    generate and copy UUID

== THANKS ==
http://moz-addon.g.hatena.ne.jp/ZIGOROu/20080417/1208413079
]]></detail>
</VimperatorPlugin>;
//}}}

(function() {
    const Ci = Components.interfaces;
    services.add("uuid", "@mozilla.org/uuid-generator;1", Ci.nsIUUIDGenerator);
    const UUID = services.get("uuid");

    commands.add(['uuid'], 'generate and copy UUID',
        function(args)
        {
            let uuid = UUID.generateUUID().number;
            util.copyToClipboard(uuid);
            liberator.echo("generate "+uuid);
        },
        {
            argCount: '0',
        });
})();
// vim: fdm=marker sw=4 ts=4 et:
1">'<C-r>']; ||< ]]></detail> </VimperatorPlugin>; (function() { let p = function(msg) { Application.console.log(''+msg); } let evalWithContext = function(func, context) { let str; let fstr = func.toString(); if (fstr.indexOf('function () {') == 0) { str = fstr.replace(/.*?{([\s\S]+)}.*?/m, "$1"); } else { str = '(' + fstr + ')()'; } return liberator.eval(str, context); } let showCompletions = function() { if (!options.get('wildoptions').has('auto')) { evalWithContext(function() { completions.complete(true, false); completions.itemList.show(); }, commandline.input); } } let next = function() { evalWithContext(function() completions.tab(false), commandline.input); } let prev = function() { evalWithContext(function() completions.tab(true), commandline.input); } const commandlineWidget = document.getElementById("liberator-commandline"); mappings.addUserMap([modes.COMMAND_LINE], liberator.globalVariables.history_search_backward_map || ['<C-r>'], 'History incremental search backward.', function() { if (evalWithContext(function() completions.itemList.visible(), commandline.input)) { next(); return; } let command = commandline.command || ''; let completionsList = [[key, i] for ([i, key] in storage['history-command'])]. filter(function([key, i]) key).reverse(); commandline.input('bck-i-search: ', function(str) { try { liberator.execute(str); } catch(e) {}; modes.pop(); return; }, { completer: function(context) { context.title = ['CommandLine History', 'INDEX']; context.completions = completionsList; }, onChange: function() { showCompletions(); }, default: command, }); showCompletions(); } ); })();