Skip to content

Instantly share code, notes, and snippets.

@uchida
Created July 14, 2014 21:56
Show Gist options
  • Save uchida/a17d54daf130669da52f to your computer and use it in GitHub Desktop.
Save uchida/a17d54daf130669da52f to your computer and use it in GitHub Desktop.
// ========================== KeySnail Init File =========================== //
// この領域は, GUI により設定ファイルを生成した際にも引き継がれます
// 特殊キー, キーバインド定義, フック, ブラックリスト以外のコードは, この中に書くようにして下さい
// ========================================================================= //
//{{%PRESERVE%
plugins.options["ldrnail.keybind"] = {
'j': 'next',
'k': 'prev',
'p': 'pin',
'l': 'list',
'f': 'focus',
'v': 'view',
'o': 'open',
's': 'siteinfo',
};
//}}%PRESERVE%
// ========================================================================= //
// ========================= Special key settings ========================== //
key.quitKey = "undefined";
key.helpKey = "undefined";
key.escapeKey = "C-v";
key.macroStartKey = "undefined";
key.macroEndKey = "undefined";
key.universalArgumentKey = "undefined";
key.negativeArgument1Key = "undefined";
key.negativeArgument2Key = "undefined";
key.negativeArgument3Key = "undefined";
key.suspendKey = "C-z";
// ================================= Hooks ================================= //
// ============================= Key bindings ============================== //
key.setViewKey('j', function (ev) {
key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_DOWN, true);
}, '一行スクロールダウン');
key.setViewKey('k', function (ev) {
key.generateKey(ev.originalTarget, KeyEvent.DOM_VK_UP, true);
}, '一行スクロールアップ');
key.setViewKey('C-u', function (ev) {
goDoCommand("cmd_scrollPageUp");
}, '一画面分スクロールアップ');
key.setViewKey('C-d', function (ev) {
goDoCommand("cmd_scrollPageDown");
}, '一画面スクロールダウン');
key.setViewKey(['g', 'g'], function (ev) {
goDoCommand("cmd_scrollTop");
}, 'ページ先頭へ移動', true);
key.setViewKey('.', function (ev) {
getBrowser().mTabContainer.advanceSelectedTab(1, true);
}, 'ひとつ右のタブへ');
key.setViewKey(',', function (ev) {
getBrowser().mTabContainer.advanceSelectedTab(-1, true);
}, 'ひとつ左のタブへ');
key.setViewKey('G', function (ev) {
goDoCommand("cmd_scrollBottom");
}, 'ページ末尾へ移動', true);
key.setViewKey(':', function (ev, arg) {
shell.input(null, arg);
}, 'コマンドの実行', true);
key.setViewKey('f', function (ev, arg) {
ext.exec("hok-start-foreground-mode", arg);
}, 'Start foreground hint mode', true);
key.setViewKey('F', function (ev, arg) {
ext.exec("hok-start-background-mode", arg);
}, 'Start background hint mode', true);
key.setViewKey(';', function (ev, arg) {
ext.exec("hok-start-extended-mode", arg);
}, 'Start extended hint mode', true);
key.setViewKey('C-i', function (ev, arg) {
util.setBoolPref("accessibility.browsewithcaret", !util.getBoolPref("accessibility.browsewithcaret"));
}, 'Toggle caret mode', true);
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('p', function (ev, arg) {
let url = command.getClipboardText();
if (url.match(/\s/) || url.indexOf("://") === -1) {
url = "http://www.google.com/search?q=" + encodeURIComponent(url) + "&ie=utf-8&oe=utf-8&aq=t";
}
gBrowser.loadOneTab(url, null, null, null, false);
}, 'Open yanked address or google it', true);
key.setEditKey('C-h', function (ev) {
goDoCommand("cmd_deleteCharBackward");
}, '前の一文字を削除');
key.setCaretKey('^', function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectBeginLine") : goDoCommand("cmd_beginLine");
}, 'キャレットを行頭へ移動');
key.setCaretKey([['$'], ['G']], function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectEndLine") : goDoCommand("cmd_endLine");
}, 'キャレットを行末へ移動');
key.setCaretKey('j', function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectLineNext") : goDoCommand("cmd_scrollLineDown");
}, 'キャレットを一行下へ');
key.setCaretKey('k', function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectLinePrevious") : goDoCommand("cmd_scrollLineUp");
}, 'キャレットを一行上へ');
key.setCaretKey('l', function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectCharNext") : goDoCommand("cmd_scrollRight");
}, 'キャレットを一文字右へ移動');
key.setCaretKey([['C-h'], ['h']], function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectCharPrevious") : goDoCommand("cmd_scrollLeft");
}, 'キャレットを一文字左へ移動');
key.setCaretKey('w', function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectWordNext") : goDoCommand("cmd_wordNext");
}, 'キャレットを一単語右へ移動');
key.setCaretKey('W', function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectWordPrevious") : goDoCommand("cmd_wordPrevious");
}, 'キャレットを一単語左へ移動');
key.setCaretKey('SPC', function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectPageNext") : goDoCommand("cmd_movePageDown");
}, 'キャレットを一画面分下へ');
key.setCaretKey('b', function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectPagePrevious") : goDoCommand("cmd_movePageUp");
}, 'キャレットを一画面分上へ');
key.setCaretKey(['g', 'g'], function (ev) {
ev.target.ksMarked ? goDoCommand("cmd_selectTop") : goDoCommand("cmd_scrollTop");
}, 'キャレットをページ先頭へ移動');
key.setCaretKey('.', function (ev) {
getBrowser().mTabContainer.advanceSelectedTab(1, true);
}, 'ひとつ右のタブへ');
key.setCaretKey(',', function (ev) {
getBrowser().mTabContainer.advanceSelectedTab(-1, true);
}, 'ひとつ左のタブへ');
key.setCaretKey('C-d', function (ev) {
util.getSelectionController().scrollLine(true);
}, '画面を一行分下へスクロール');
key.setCaretKey('C-u', function (ev) {
util.getSelectionController().scrollLine(false);
}, '画面を一行分上へスクロール');
key.setCaretKey(':', function (ev, arg) {
shell.input(null, arg);
}, 'コマンドの実行', true);
key.setCaretKey('f', function (ev, arg) {
ext.exec("hok-start-foreground-mode", arg);
}, 'Start foreground hint mode', true);
key.setCaretKey('F', function (ev, arg) {
ext.exec("hok-start-background-mode", arg);
}, 'Start background hint mode', true);
key.setCaretKey(';', function (ev, arg) {
ext.exec("hok-start-extended-mode", arg);
}, 'Start extended hint mode', true);
key.setCaretKey('C-i', function (ev, arg) {
util.setBoolPref("accessibility.browsewithcaret", !util.getBoolPref("accessibility.browsewithcaret"));
}, 'Toggle caret mode', true);
key.setCaretKey('y', function (ev, arg) {
command.setClipboardText(content.document.location.href);
display.echoStatusBar("Yanked " + content.document.location.href);
}, 'Yank current page address', true);
key.setCaretKey('p', function (ev, arg) {
let url = command.getClipboardText();
if (url.match(/\s/) || url.indexOf("://") === -1) {
url = "http://www.google.com/search?q=" + encodeURIComponent(url) + "&ie=utf-8&oe=utf-8&aq=t";
}
gBrowser.loadOneTab(url, null, null, null, false);
}, 'Open yanked address or google it', true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment