1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 04:07:59 +01:00

Decent filtering for :extrehash. Fix tab bar layout after rehash with go+=n. Cleanup.

This commit is contained in:
Kris Maglione
2010-12-31 02:11:48 -05:00
parent 3f3e89e270
commit 012732edc7
5 changed files with 50 additions and 33 deletions

View File

@@ -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.registerSheet("chrome://dactyl/skin/dactyl.css");
styles.system.add("font-size", "chrome://dactyl/content/buffer.xhtml", styles.system.add("font-size", "chrome://dactyl/content/buffer.xhtml",
"body { font-size: " + fontSize + "; }"); "body { font-size: " + fontSize + "; }");

View File

@@ -318,13 +318,15 @@ var Command = Class("Command", {
}, { }, {
bindMacro: function (args, default_, params) { bindMacro: function (args, default_, params) {
let process = util.identity; let process = util.identity;
let makeParams = function makeParams()
let (args = arguments)
params.map(function (name, i) [name, process(args[i])]).toObject();
if (callable(params)) 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) 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 rhs = args.literalArg;
let type = ["-builtin", "-ex", "-javascript", "-keys"].reduce(function (a, b) args[b] ? b : a, default_); 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": case "-keys":
let silent = args["-silent"]; let silent = args["-silent"];
rhs = events.canonicalKeys(rhs, true); 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); action.macro = util.compileMacro(rhs, true);
break; break;
case "-ex": 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); false, null, action.sourcing);
action.macro = util.compileMacro(rhs, true); action.macro = util.compileMacro(rhs, true);
action.sourcing = io.sourcing && update({}, io.sourcing); action.sourcing = io.sourcing && update({}, io.sourcing);
break; break;
case "-javascript": case "-javascript":
if (callable(params)) 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 else
action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg).array); action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg).array);
process = function (param) isObject(param) && param.valueOf ? param.valueOf() : param; process = function (param) isObject(param) && param.valueOf ? param.valueOf() : param;

View File

@@ -601,7 +601,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
if (context && context.INFO instanceof XML) { if (context && context.INFO instanceof XML) {
let info = context.INFO; let info = context.INFO;
if (info.*.@lang.length()) { 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, let lang = [window.navigator.language,
window.navigator.language.replace(/-.*/, ""), window.navigator.language.replace(/-.*/, ""),
"en", "en-US", info.*.@lang[0] "en", "en-US", info.*.@lang[0]
@@ -1477,7 +1477,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
function () { dactyl.quit(true); }); function () { dactyl.quit(true); });
}, },
commands: function (_dactyl, _modules, _window) { commands: function () {
commands.add(["addo[ns]"], commands.add(["addo[ns]"],
"Manage available Extensions and Themes", "Manage available Extensions and Themes",
function () { function () {
@@ -1667,7 +1667,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
addon.userDisabled = false; 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" perm: "disable"
}, },
{ {

View File

@@ -973,6 +973,8 @@ var Tabs = Module("tabs", {
} }
if (value !== "multitab" || !dactyl.has("Gecko2")) if (value !== "multitab" || !dactyl.has("Gecko2"))
config.tabStrip.collapsed = false; config.tabStrip.collapsed = false;
if (config.tabbrowser.tabContainer._positionPinnedTabs)
config.tabbrowser.tabContainer._positionPinnedTabs();
return value; return value;
}, },
completer: function (context) [ completer: function (context) [

View File

@@ -333,9 +333,13 @@ function keys(obj) {
* @returns {Generator} * @returns {Generator}
*/ */
function values(obj) { function values(obj) {
for (var k in obj) if (isinstance(obj, ["Generator", "Iterator"]))
if (hasOwnProperty.call(obj, k)) for (let k in obj)
yield obj[k]; 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) { function set(ary) {
let obj = {}; let obj = {};
if (ary) if (ary)
for (var i = 0; i < ary.length; i++) for (let val in values(ary))
obj[ary[i]] = true; obj[val] = true;
return obj; return obj;
} }
/** /**
@@ -456,49 +460,54 @@ set.remove = function (set, key) {
* @returns {Generator} * @returns {Generator}
*/ */
function iter(obj) { function iter(obj) {
let res = Iterator(obj);
if (ctypes && ctypes.CData && obj instanceof ctypes.CData) { if (ctypes && ctypes.CData && obj instanceof ctypes.CData) {
while (obj.constructor instanceof ctypes.PointerType) while (obj.constructor instanceof ctypes.PointerType)
obj = obj.contents; obj = obj.contents;
if (obj.constructor instanceof ctypes.ArrayType) if (obj.constructor instanceof ctypes.ArrayType)
return array.iterItems(obj); res = array.iterItems(obj);
if (obj.constructor instanceof ctypes.StructType) else if (obj.constructor instanceof ctypes.StructType)
return (function () { res = (function () {
for (let prop in values(obj.constructor.fields)) for (let prop in values(obj.constructor.fields))
yield let ([name, type] = Iterator(prop).next()) [name, obj[name]]; yield let ([name, type] = Iterator(prop).next()) [name, obj[name]];
})(); })();
obj = {}; else
return iter({});
} }
if (isinstance(obj, [Ci.nsIDOMHTMLCollection, Ci.nsIDOMNodeList])) else if (isinstance(obj, [Ci.nsIDOMHTMLCollection, Ci.nsIDOMNodeList]))
return array.iterItems(obj); res = array.iterItems(obj);
if (obj instanceof Ci.nsIDOMNamedNodeMap) else if (obj instanceof Ci.nsIDOMNamedNodeMap)
return (function () { res = (function () {
for (let i = 0; i < obj.length; i++) for (let i = 0; i < obj.length; i++)
yield [obj.name, obj]; yield [obj.name, obj];
})(); })();
if (obj instanceof Ci.mozIStorageStatement) else if (obj instanceof Ci.mozIStorageStatement)
return (function (obj) { res = (function (obj) {
while (obj.executeStep()) while (obj.executeStep())
yield obj.row; yield obj.row;
obj.reset(); obj.reset();
})(obj); })(obj);
if ("getNext" in obj) { else if ("getNext" in obj) {
if ("hasMoreElements" in obj) if ("hasMoreElements" in obj)
return (function () { res = (function () {
while (obj.hasMoreElements()) while (obj.hasMoreElements())
yield obj.getNext(); yield obj.getNext();
})(); })();
if ("hasMore" in obj) else if ("hasMore" in obj)
return (function () { res = (function () {
while (obj.hasMore()) while (obj.hasMore())
yield obj.getNext(); yield obj.getNext();
})(); })();
} }
if ("enumerator" in obj) { else if ("enumerator" in obj) {
if (callable(obj.enumerator)) if (callable(obj.enumerator))
return iter(obj.enumerator()); return iter(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;
} }
/** /**