mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 12:07:59 +01:00
Crude source line linkification in :*usage.
This commit is contained in:
@@ -142,6 +142,11 @@ const Buffer = Module("buffer", {
|
||||
return Array.map(metaNodes, function (node) [(node.name || node.httpEquiv), template.highlightURL(node.content)])
|
||||
.sort(function (a, b) util.compareIgnoreCase(a[0], b[0]));
|
||||
});
|
||||
|
||||
dactyl.commands["buffer.viewSource"] = function (event) {
|
||||
let elem = event.originalTarget;
|
||||
buffer.viewSource([elem.getAttribute("href"), Number(elem.getAttribute("line"))])
|
||||
};
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
@@ -951,6 +956,19 @@ const Buffer = Module("buffer", {
|
||||
viewSource: function (url, useExternalEditor) {
|
||||
let doc = buffer.focusedFrame.document;
|
||||
|
||||
if (isArray(url)) {
|
||||
let chrome = "chrome://global/content/viewSource.xul";
|
||||
window.openDialog(chrome, "_blank", "all,dialog=no",
|
||||
url[0], null, null, url[1]);
|
||||
/* FIXME
|
||||
let win = dactyl.open(chrome)[0];
|
||||
while (win.document.documentURI != chrome)
|
||||
util.threadYield(false, true);
|
||||
win.arguments = [url[0], null, null, url[1]];
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
if (useExternalEditor)
|
||||
this.viewSourceExternally(url || doc);
|
||||
else {
|
||||
|
||||
@@ -451,10 +451,14 @@ const Commands = Module("commands", {
|
||||
repeat: null,
|
||||
|
||||
_addCommand: function (args, replace) {
|
||||
if (!args[3])
|
||||
args[3] = {};
|
||||
args[3].definedAt = Components.stack.caller.caller;
|
||||
|
||||
let names = array.flatten(Command.parseSpecs(args[0]));
|
||||
dactyl.assert(!names.some(function (name) name in this._exMap && !this._exMap[name].user, this),
|
||||
"E182: Can't replace non-user command: " + args[0][0]);
|
||||
if (!replace || !(args[3] && args[3].user))
|
||||
if (!replace || !args[3].user)
|
||||
dactyl.assert(!names.some(function (name) name in this._exMap, this),
|
||||
"Not replacing command " + args[0]);
|
||||
for (let name in values(names)) {
|
||||
|
||||
@@ -888,24 +888,23 @@ const Dactyl = Module("dactyl", {
|
||||
switch (where) {
|
||||
case dactyl.CURRENT_TAB:
|
||||
browser.loadURIWithFlags(url, flags, null, null, postdata);
|
||||
break;
|
||||
return browser.contentWindow;
|
||||
|
||||
case dactyl.NEW_TAB:
|
||||
if (!dactyl.has("tabs"))
|
||||
return open(urls, dactyl.NEW_WINDOW);
|
||||
|
||||
prefs.withContext(function () {
|
||||
return prefs.withContext(function () {
|
||||
prefs.set("browser.tabs.loadInBackground", true);
|
||||
browser.loadOneTab(url, null, null, postdata, background);
|
||||
return browser.loadOneTab(url, null, null, postdata, background).linkedBrowser.contentDocument;
|
||||
});
|
||||
break;
|
||||
|
||||
case dactyl.NEW_WINDOW:
|
||||
window.open();
|
||||
let win = services.windowMediator.getMostRecentWindow("navigator:browser");
|
||||
win.loadURI(url, null, postdata);
|
||||
browser = win.getBrowser();
|
||||
break;
|
||||
return win.content;
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
@@ -921,11 +920,12 @@ const Dactyl = Module("dactyl", {
|
||||
else if (!where)
|
||||
where = dactyl.CURRENT_TAB;
|
||||
|
||||
for (let [, url] in Iterator(urls)) {
|
||||
open(url, where);
|
||||
return urls.map(function (url) {
|
||||
let res = open(url, where);
|
||||
where = dactyl.NEW_TAB;
|
||||
background = true;
|
||||
}
|
||||
return res;
|
||||
});
|
||||
},
|
||||
|
||||
pluginFiles: {},
|
||||
|
||||
@@ -140,6 +140,7 @@ const Mappings = Module("mappings", {
|
||||
|
||||
_addMap: function (map) {
|
||||
let where = map.user ? this._user : this._main;
|
||||
map.definedAt = Components.stack.caller.caller;
|
||||
map.modes.forEach(function (mode) {
|
||||
if (!(mode in where))
|
||||
where[mode] = [];
|
||||
|
||||
@@ -642,6 +642,8 @@ const Options = Module("options", {
|
||||
if (!extraInfo)
|
||||
extraInfo = {};
|
||||
|
||||
extraInfo.definedAt = Components.stack.caller;
|
||||
|
||||
let name = names[0];
|
||||
if (name in this._optionMap) {
|
||||
dactyl.log("Warning: " + name.quote() + " already exists: replacing existing option.", 1);
|
||||
|
||||
@@ -294,7 +294,14 @@ const Template = Module("Template", {
|
||||
{
|
||||
this.map(iter, function (item)
|
||||
<tr>
|
||||
<td highlight="Title" style="padding-right: 20px">{item.name || item.names[0]}</td>
|
||||
<td highlight="Title" style="padding-right: 20px">{
|
||||
let (name = item.name || item.names[0], frame = item.definedAt)
|
||||
frame ? <a xmlns:dactyl={NS} dactyl:command="buffer.viewSource"
|
||||
href={frame.filename} line={frame.lineNumber}>
|
||||
<abbr title={"Defined at " + frame.filename + ":" + frame.lineNumber}>
|
||||
{name}</abbr></a>
|
||||
: name
|
||||
}</td>
|
||||
<td>{item.description}</td>
|
||||
</tr>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user