From 4dd0b7bfef72f78c754fef56bbc5eb14ca38b074 Mon Sep 17 00:00:00 2001 From: anekos Date: Wed, 10 Dec 2008 13:47:39 +0000 Subject: 問題が起きにくいようにしたつもり。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26323 d0d07461-0603-4401-acd4-de1884942a52 --- asdfghjkl.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'asdfghjkl.js') 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(); + }); })(); -- cgit v1.2.3