1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 16:47:58 +01:00

Crude source line linkification in :*usage.

This commit is contained in:
Kris Maglione
2010-12-03 18:11:05 -05:00
parent 4f696a4a2e
commit 252e7450f1
6 changed files with 42 additions and 10 deletions

View File

@@ -142,6 +142,11 @@ const Buffer = Module("buffer", {
return Array.map(metaNodes, function (node) [(node.name || node.httpEquiv), template.highlightURL(node.content)]) return Array.map(metaNodes, function (node) [(node.name || node.httpEquiv), template.highlightURL(node.content)])
.sort(function (a, b) util.compareIgnoreCase(a[0], b[0])); .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 () { destroy: function () {
@@ -951,6 +956,19 @@ const Buffer = Module("buffer", {
viewSource: function (url, useExternalEditor) { viewSource: function (url, useExternalEditor) {
let doc = buffer.focusedFrame.document; 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) if (useExternalEditor)
this.viewSourceExternally(url || doc); this.viewSourceExternally(url || doc);
else { else {

View File

@@ -451,10 +451,14 @@ const Commands = Module("commands", {
repeat: null, repeat: null,
_addCommand: function (args, replace) { _addCommand: function (args, replace) {
if (!args[3])
args[3] = {};
args[3].definedAt = Components.stack.caller.caller;
let names = array.flatten(Command.parseSpecs(args[0])); let names = array.flatten(Command.parseSpecs(args[0]));
dactyl.assert(!names.some(function (name) name in this._exMap && !this._exMap[name].user, this), 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]); "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), dactyl.assert(!names.some(function (name) name in this._exMap, this),
"Not replacing command " + args[0]); "Not replacing command " + args[0]);
for (let name in values(names)) { for (let name in values(names)) {

View File

@@ -888,24 +888,23 @@ const Dactyl = Module("dactyl", {
switch (where) { switch (where) {
case dactyl.CURRENT_TAB: case dactyl.CURRENT_TAB:
browser.loadURIWithFlags(url, flags, null, null, postdata); browser.loadURIWithFlags(url, flags, null, null, postdata);
break; return browser.contentWindow;
case dactyl.NEW_TAB: case dactyl.NEW_TAB:
if (!dactyl.has("tabs")) if (!dactyl.has("tabs"))
return open(urls, dactyl.NEW_WINDOW); return open(urls, dactyl.NEW_WINDOW);
prefs.withContext(function () { return prefs.withContext(function () {
prefs.set("browser.tabs.loadInBackground", true); 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: case dactyl.NEW_WINDOW:
window.open(); window.open();
let win = services.windowMediator.getMostRecentWindow("navigator:browser"); let win = services.windowMediator.getMostRecentWindow("navigator:browser");
win.loadURI(url, null, postdata); win.loadURI(url, null, postdata);
browser = win.getBrowser(); browser = win.getBrowser();
break; return win.content;
} }
} }
catch (e) {} catch (e) {}
@@ -921,11 +920,12 @@ const Dactyl = Module("dactyl", {
else if (!where) else if (!where)
where = dactyl.CURRENT_TAB; where = dactyl.CURRENT_TAB;
for (let [, url] in Iterator(urls)) { return urls.map(function (url) {
open(url, where); let res = open(url, where);
where = dactyl.NEW_TAB; where = dactyl.NEW_TAB;
background = true; background = true;
} return res;
});
}, },
pluginFiles: {}, pluginFiles: {},

View File

@@ -140,6 +140,7 @@ const Mappings = Module("mappings", {
_addMap: function (map) { _addMap: function (map) {
let where = map.user ? this._user : this._main; let where = map.user ? this._user : this._main;
map.definedAt = Components.stack.caller.caller;
map.modes.forEach(function (mode) { map.modes.forEach(function (mode) {
if (!(mode in where)) if (!(mode in where))
where[mode] = []; where[mode] = [];

View File

@@ -642,6 +642,8 @@ const Options = Module("options", {
if (!extraInfo) if (!extraInfo)
extraInfo = {}; extraInfo = {};
extraInfo.definedAt = Components.stack.caller;
let name = names[0]; let name = names[0];
if (name in this._optionMap) { if (name in this._optionMap) {
dactyl.log("Warning: " + name.quote() + " already exists: replacing existing option.", 1); dactyl.log("Warning: " + name.quote() + " already exists: replacing existing option.", 1);

View File

@@ -294,7 +294,14 @@ const Template = Module("Template", {
{ {
this.map(iter, function (item) this.map(iter, function (item)
<tr> <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> <td>{item.description}</td>
</tr>) </tr>)
} }