diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/content/commandline.js | 2 | ||||
-rw-r--r-- | common/content/commands.js | 19 | ||||
-rw-r--r-- | common/content/dactyl.js | 9 | ||||
-rw-r--r-- | common/content/tabs.js | 2 | ||||
-rw-r--r-- | common/modules/base.jsm | 51 |
5 files changed, 50 insertions, 33 deletions
diff --git a/common/content/commandline.js b/common/content/commandline.js index 4b297915..76296218 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -160,7 +160,7 @@ var CommandWidgets = Class("CommandWidgets", { } }); - let fontSize = util.computedStyle(document.getElementById(config.mainWindowId)).fontSize; + let fontSize = util.computedStyle(document.documentElement).fontSize; styles.registerSheet("chrome://dactyl/skin/dactyl.css"); styles.system.add("font-size", "chrome://dactyl/content/buffer.xhtml", "body { font-size: " + fontSize + "; }"); diff --git a/common/content/commands.js b/common/content/commands.js index 9f1d2624..eb10a156 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -318,13 +318,15 @@ var Command = Class("Command", { }, { bindMacro: function (args, default_, params) { let process = util.identity; - let makeParams = function makeParams() - let (args = arguments) - params.map(function (name, i) [name, process(args[i])]).toObject(); + if (callable(params)) - makeParams = function makeParams(args) array(Iterator(params.apply(this, arguments))).map(function ([k, v]) [k, process(v)]).toObject(); + function makeParams(self, args) + array.toObject([[k, process(v)] + for ([k, v] in iter(params.apply(this, args)))]) else if (params) - params = array(params); + function makeParams(self, args) + array.toObject([[name, process(args[i])] + for ([i, name] in Iterator(params))]); let rhs = args.literalArg; let type = ["-builtin", "-ex", "-javascript", "-keys"].reduce(function (a, b) args[b] ? b : a, default_); @@ -335,18 +337,19 @@ var Command = Class("Command", { case "-keys": let silent = args["-silent"]; rhs = events.canonicalKeys(rhs, true); - var action = function action(args) events.feedkeys(action.macro(args), noremap, silent); + var action = function action() events.feedkeys(action.macro(makeParams(this, arguments)), + noremap, silent); action.macro = util.compileMacro(rhs, true); break; case "-ex": - action = function action() commands.execute(action.macro, makeParams.apply(this, arguments), + action = function action() commands.execute(action.macro, makeParams(this, arguments), false, null, action.sourcing); action.macro = util.compileMacro(rhs, true); action.sourcing = io.sourcing && update({}, io.sourcing); break; case "-javascript": if (callable(params)) - action = dactyl.userEval("(function action() { with (action.makeParams.apply(this, arguments)) {" + args.literalArg + "} })"); + action = dactyl.userEval("(function action() { with (action.makeParams(this, arguments)) {" + args.literalArg + "} })"); else action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg).array); process = function (param) isObject(param) && param.valueOf ? param.valueOf() : param; diff --git a/common/content/dactyl.js b/common/content/dactyl.js index e568c43d..e77d04a0 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -601,7 +601,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (context && context.INFO instanceof XML) { let info = context.INFO; if (info.*.@lang.length()) { - let langs = set([String(a) for each (a in info.*.@lang)]); + let langs = set(String(a) for each (a in info.*.@lang)); let lang = [window.navigator.language, window.navigator.language.replace(/-.*/, ""), "en", "en-US", info.*.@lang[0] @@ -1477,7 +1477,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { function () { dactyl.quit(true); }); }, - commands: function (_dactyl, _modules, _window) { + commands: function () { commands.add(["addo[ns]"], "Manage available Extensions and Themes", function () { @@ -1667,7 +1667,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { addon.userDisabled = false; }); }, - filter: function ({ item }) !item.userDisabled, + get filter() { + let ids = set(keys(JSON.parse(prefs.get("extensions.bootstrappedAddons", "{}")))); + return function ({ item }) !item.userDisabled && set.has(ids, item.id); + }, perm: "disable" }, { diff --git a/common/content/tabs.js b/common/content/tabs.js index 404f5969..0583c177 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -973,6 +973,8 @@ var Tabs = Module("tabs", { } if (value !== "multitab" || !dactyl.has("Gecko2")) config.tabStrip.collapsed = false; + if (config.tabbrowser.tabContainer._positionPinnedTabs) + config.tabbrowser.tabContainer._positionPinnedTabs(); return value; }, completer: function (context) [ diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 1da1247a..525c763b 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -333,9 +333,13 @@ function keys(obj) { * @returns {Generator} */ function values(obj) { - for (var k in obj) - if (hasOwnProperty.call(obj, k)) - yield obj[k]; + if (isinstance(obj, ["Generator", "Iterator"])) + for (let k in obj) + yield k; + else + for (var k in obj) + if (hasOwnProperty.call(obj, k)) + yield obj[k]; } /** @@ -372,8 +376,8 @@ function iterAll() { function set(ary) { let obj = {}; if (ary) - for (var i = 0; i < ary.length; i++) - obj[ary[i]] = true; + for (let val in values(ary)) + obj[val] = true; return obj; } /** @@ -456,49 +460,54 @@ set.remove = function (set, key) { * @returns {Generator} */ function iter(obj) { + let res = Iterator(obj); if (ctypes && ctypes.CData && obj instanceof ctypes.CData) { while (obj.constructor instanceof ctypes.PointerType) obj = obj.contents; if (obj.constructor instanceof ctypes.ArrayType) - return array.iterItems(obj); - if (obj.constructor instanceof ctypes.StructType) - return (function () { + res = array.iterItems(obj); + else if (obj.constructor instanceof ctypes.StructType) + res = (function () { for (let prop in values(obj.constructor.fields)) yield let ([name, type] = Iterator(prop).next()) [name, obj[name]]; })(); - obj = {}; + else + return iter({}); } - if (isinstance(obj, [Ci.nsIDOMHTMLCollection, Ci.nsIDOMNodeList])) - return array.iterItems(obj); - if (obj instanceof Ci.nsIDOMNamedNodeMap) - return (function () { + else if (isinstance(obj, [Ci.nsIDOMHTMLCollection, Ci.nsIDOMNodeList])) + res = array.iterItems(obj); + else if (obj instanceof Ci.nsIDOMNamedNodeMap) + res = (function () { for (let i = 0; i < obj.length; i++) yield [obj.name, obj]; })(); - if (obj instanceof Ci.mozIStorageStatement) - return (function (obj) { + else if (obj instanceof Ci.mozIStorageStatement) + res = (function (obj) { while (obj.executeStep()) yield obj.row; obj.reset(); })(obj); - if ("getNext" in obj) { + else if ("getNext" in obj) { if ("hasMoreElements" in obj) - return (function () { + res = (function () { while (obj.hasMoreElements()) yield obj.getNext(); })(); - if ("hasMore" in obj) - return (function () { + else if ("hasMore" in obj) + res = (function () { while (obj.hasMore()) yield obj.getNext(); })(); } - if ("enumerator" in obj) { + else if ("enumerator" in obj) { if (callable(obj.enumerator)) return iter(obj.enumerator()); return iter(obj.enumerator); } - return Iterator(obj); + res.__noSuchMethod__ = function __noSuchMethod__(meth, args) + let (ary = array(this)) + ary[meth] ? ary[meth].apply(ary, args) : ary.__noSuchMethod__(meth, args); + return res; } /** |