aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranekos2008-12-10 13:47:39 +0000
committeranekos2008-12-10 13:47:39 +0000
commit4dd0b7bfef72f78c754fef56bbc5eb14ca38b074 (patch)
treec2713e8e5c54553ad14a8f592a7b0e94f2ef4a19
parent34b1a8be8f4478752b393147ce60d3e1ea840d49 (diff)
downloadvimperator-plugins-4dd0b7bfef72f78c754fef56bbc5eb14ca38b074.tar.bz2
問題が起きにくいようにしたつもり。
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26323 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r--asdfghjkl.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/asdfghjkl.js b/asdfghjkl.js
index 75cbddf..b1b64fd 100644
--- a/asdfghjkl.js
+++ b/asdfghjkl.js
@@ -3,7 +3,7 @@
// @description Inputting numbers by asdfghjkl; keys in hint mode.
// @description-ja Hintモードで、asdfghjkl;キーを使って数字入力をする。
// @license Creative Commons 2.1 (Attribution + Share Alike)
-// @version 1.3
+// @version 1.4
// @minVersion 2.0pre
// @maxVersion 2.0pre
// @author anekos (anekos@snca.net)
@@ -45,12 +45,16 @@
let asdfghjkl_hintchars = liberator.globalVariables.asdfghjkl_hintchars || ";asdfghjkl";
let active = false;
- let original = {
- show: hints.show,
- onKeyPress: events.onKeyPress,
- };
+ function around (obj, name, func) {
+ let next = obj[name];
+ obj[name] = function ()
+ let (self = this, args = arguments)
+ func.call(self,
+ function () next.apply(self, args),
+ args);
+ }
- events.onKeyPress = function (event) {
+ around(events, 'onKeyPress', function (next, [event]) {
if (modes.extended & modes.HINTS) {
let act = active;
let key = events.toString(event);
@@ -76,12 +80,12 @@
}
}
}
- return original.onKeyPress.call(this, event);
- };
+ return next();
+ });
- hints.show = function () {
+ around(hints, 'show', function (next) {
active = asdfghjkl_default;
- return original.show.apply(this, arguments);
- };
+ return next();
+ });
})();