This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "rios/easy" | |
# http://ascii-table.com/ansi-escape-sequences.php | |
key_remaps = { | |
"j" => "\e[B", # down | |
"k" => "\e[A", # up | |
"o" => "\r\n", # enter | |
"u" => "\e[D", # left |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my:byte-to-various-units (size-byte) | |
"Display `size-byte' in various units." | |
(interactive "nBytes: ") | |
(let ((size size-byte) | |
(size-kib size-byte)) | |
(with-output-to-temp-buffer "*unit*" | |
(princ (format "%d B\n-----------\n" size-byte)) | |
(dolist (unit '("K" "M" "G" "T" "P")) | |
(setq size (/ size 1000.0)) | |
(setq size-kib (/ size-kib 1024.0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load rbindkeys-helper | |
require "path-to-rbindkeys-helper" | |
# Emacs-like settings | |
def define_emacs_keys() | |
bind "C-g", "ESC" | |
# cursor move | |
bind "C-f", "<right>" | |
bind "C-b", "<left>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==================== set global keys ==================== // | |
key.setGlobalKey("C-M-r", | |
function () { userscript.reload(); }, | |
"設定ファイルを再読み込み"); | |
// -------------------- help command -------------------- // | |
key.setGlobalKey([key.helpKey, "b"], function () { | |
key.listKeyBindings(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key.setGlobalKey(["C-c", "C-w", "C-a"], | |
function () { | |
window.alert("Hello!"); | |
}, | |
"Hello Dialog"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key.setGlobalKey(["C-c", "C-w", "C-a"], | |
function (event, arg) { | |
window.alert("Hello! Prefix argument is " + arg); | |
}, | |
"Hello Dialog", | |
true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key.helpKey = "<tab>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key.isControlKey = function (aEvent) { | |
return aEvent.ctrlKey; | |
}; | |
key.isMetaKey = function (aEvent) { | |
return aEvent.altKey || aEvent.commandKey; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key.isControlKey = function (aEvent) { | |
return aEvent.ctrlKey | |
|| aEvent.keyCode == KeyEvent.DOM_VK_CAPS_LOCK; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key.setGlobalKey(["C-c", "C-w", "C-a"], | |
function (event, arg) { | |
window.alert("Hello! Prefix argument is " + arg); | |
}, | |
"Hello Dialog"); |
OlderNewer