Newer
Older
casp / NetBSD8 / etc / skel / .keysnail.js
@HIROSE Yuuji HIROSE Yuuji on 17 Sep 2019 4 KB Required files located
// ========================== KeySnail Init File =========================== //

// You can preserve your code in this area when generating the init file using GUI.
// Put all your code except special key, set*key, hook, blacklist.
// ========================================================================= //
//{{%PRESERVE%
// Put your codes here
//}}%PRESERVE%
// ========================================================================= //

// ========================= Special key settings ========================== //

key.quitKey              = "undefined";
key.helpKey              = "undefined";
key.escapeKey            = "undefined";
key.macroStartKey        = "undefined";
key.macroEndKey          = "undefined";
key.universalArgumentKey = "undefined";
key.negativeArgument1Key = "undefined";
key.negativeArgument2Key = "undefined";
key.negativeArgument3Key = "undefined";
key.suspendKey           = "undefined";

// ================================= Hooks ================================= //



// ============================= Key bindings ============================== //

key.setGlobalKey('C-m', function (ev) {
    key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RETURN, true);
}, 'Generate the return key code');

key.setViewKey([['x', 'l'], ['<']], function (ev) {
    var browser = getBrowser();
    if (browser.mCurrentTab.previousSibling) {
        browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos - 1);
    } else {
        browser.moveTabTo(browser.mCurrentTab, browser.mTabContainer.childNodes.length - 1);
    }
}, 'Move selected tab to left');

key.setViewKey([['x', 'h'], ['>']], function (ev) {
    var browser = getBrowser();
    if (browser.mCurrentTab.nextSibling) {
        browser.moveTabTo(browser.mCurrentTab, browser.mCurrentTab._tPos + 1);
    } else {
        browser.moveTabTo(browser.mCurrentTab, 0);
    }
}, 'Move selected tab to right');

key.setGlobalKey(['C-[', 'C-x'], function (ev) {
    userscript.reload();
}, 'Reload the initialization file');

key.setGlobalKey(['C-[', 'x'], function (ev, arg) {
    shell.input(null, arg);
}, 'List and execute commands', true);

key.setViewKey('L', function (ev) {
    getBrowser().mTabContainer.advanceSelectedTab(1, true);
}, 'Select next tab');

key.setViewKey('H', function (ev) {
    getBrowser().mTabContainer.advanceSelectedTab(-1, true);
}, 'Select previous tab');

key.setViewKey('b', function (ev) {
    BrowserBack();
}, 'Back');

key.setViewKey('f', function (ev) {
    BrowserForward();
}, 'Forward');

key.setViewKey('q', function (ev) {
    document.getElementById("Browser:Stop").doCommand();
}, 'Stop content loading');

key.setViewKey('u', function (ev) {
    var uri = getBrowser().currentURI;
    if (uri.path == "/") {
        return;
    }
    var pathList = uri.path.split("/");
    if (!pathList.pop()) {
        pathList.pop();
    }
    loadURI(uri.prePath + pathList.join("/") + "/");
}, 'Go upper directory');

key.setViewKey('Y', function (ev, arg) {
    command.setClipboardText(content.location.href);
}, 'copy_document_url');

key.setViewKey(['C-x', '1'], function (ev) {
    window.loadURI(ev.target.ownerDocument.location.href);
}, 'Show current frame only');

key.setViewKey(['C-x', 'u'], function (ev) {
    undoCloseTab();
}, 'Undo closed tab');

key.setViewKey('h', function (ev) {
    key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_LEFT, true);
}, 'Scroll left');

key.setViewKey('j', function (ev) {
    key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
}, 'Scroll line down');

key.setViewKey('k', function (ev) {
    key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
}, 'Scroll line up');

key.setViewKey('l', function (ev) {
    key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_RIGHT, true);
}, 'Scroll right');

key.setViewKey('C-h', function (ev) {
    goDoCommand("cmd_scrollPageUp");
}, 'Scroll page up');

key.setViewKey('g', function (ev) {
    goDoCommand("cmd_scrollTop");
}, 'Scroll to the top of the page');

key.setViewKey('G', function (ev) {
    goDoCommand("cmd_scrollBottom");
}, 'Scroll to the bottom of the page');

key.setViewKey('y', function (ev, arg) {
    command.setClipboardText(content.document.location.href);
    display.echoStatusBar("Yanked " + content.document.location.href);
}, 'Yank current page address', true);

key.setViewKey('R', function (ev) {
    BrowserReloadSkipCache();
}, 'Reload (Skip cache)');