X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fmodules%2Fcontexts.jsm;h=c34d2dded318ad56c02ee56b595b86b86768366c;hb=8b6fcae7eaa413bc62d645d2d0c99835c47265e6;hp=468193659893eb51ef2d84fead71f676b2ba1c92;hpb=9044153cb63835e39b9de8ec4ade237c03e3888a;p=dactyl.git diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index 4681936..c34d2dd 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -1,16 +1,19 @@ -// Copyright (c) 2010-2011 by Kris Maglione +// Copyright (c) 2010-2012 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; -Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("contexts", { exports: ["Contexts", "Group", "contexts"], require: ["services", "util"] -}, this); +}); -this.lazyRequire("overlay", ["overlay"]); +lazyRequire("commands", ["ArgType", "CommandOption", "commands"]); +lazyRequire("options", ["Option"]); +lazyRequire("overlay", ["overlay"]); +lazyRequire("storage", ["File"]); +lazyRequire("template", ["template"]); var Const = function Const(val) Class.Property({ enumerable: true, value: val }); @@ -75,10 +78,11 @@ var Group = Class("Group", { return update(siteFilter, { toString: function () this.filters.join(","), - toXML: function (modules) let (uri = modules && modules.buffer.uri) + toJSONXML: function (modules) let (uri = modules && modules.buffer.uri) template.map(this.filters, - function (f) {f}, - <>,), + function (f) ["span", { highlight: uri && f(uri) ? "Filter" : "" }, + "toJSONXML" in f ? f.toJSONXML() : String(f)], + ","), filters: Option.parse.sitelist(patterns) }); @@ -222,7 +226,10 @@ var Contexts = Module("contexts", { util.trapErrors("onUnload", self); } else { - self = args && !isArray(args) ? args : newContext.apply(null, args || [userContext]); + let params = Array.slice(args || [userContext]); + params[2] = params[2] || File(file).URI.spec; + + self = args && !isArray(args) ? args : newContext.apply(null, params); update(self, { NAME: Const(id), @@ -371,7 +378,7 @@ var Contexts = Module("contexts", { return { __proto__: frame, filename: this.context.file[0] == "[" ? this.context.file - : services.io.newFileURI(File(this.context.file)).spec, + : File(this.context.file).URI.spec, lineNumber: this.context.line }; return frame; @@ -477,10 +484,12 @@ var Contexts = Module("contexts", { getDocs: function getDocs(context) { try { if (isinstance(context, ["Sandbox"])) { - let info = "INFO" in context && Cu.evalInSandbox("this.INFO instanceof XML && INFO.toXMLString()", context); - return info && XML(info); + let info = "INFO" in context && Cu.evalInSandbox("this.INFO instanceof XML ? INFO.toXMLString() : this.INFO", context); + return /^{g.filter.toXML ? g.filter.toXML(modules) + <>  : ""}{g.description || ""} + description: function (g) ["", g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "", g.description || ""] }; context.completions = (active === undefined ? contexts.groupList : contexts.initializedGroups(active)) .slice(0, -1);