mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 12:27:58 +01:00
Fix :runtime completion.
This commit is contained in:
@@ -368,9 +368,9 @@ const Buffer = Module("buffer", {
|
|||||||
* tab.
|
* tab.
|
||||||
*/
|
*/
|
||||||
get localStore() {
|
get localStore() {
|
||||||
if (!window.content.dactylStore)
|
if (!content.dactylStore)
|
||||||
window.content.dactylStore = {};
|
content.dactylStore = {};
|
||||||
return window.content.dactylStore;
|
return content.dactylStore;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -383,18 +383,18 @@ const Buffer = Module("buffer", {
|
|||||||
/**
|
/**
|
||||||
* @property {string} The current top-level document's URL.
|
* @property {string} The current top-level document's URL.
|
||||||
*/
|
*/
|
||||||
get URL() window.content.location.href,
|
get URL() content.location.href,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {string} The current top-level document's URL, sans any
|
* @property {string} The current top-level document's URL, sans any
|
||||||
* fragment identifier.
|
* fragment identifier.
|
||||||
*/
|
*/
|
||||||
get URI() window.content.document.documentURI,
|
get URI() content.document.documentURI,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} The buffer's height in pixels.
|
* @property {number} The buffer's height in pixels.
|
||||||
*/
|
*/
|
||||||
get pageHeight() window.content.innerHeight,
|
get pageHeight() content.innerHeight,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} The current browser's zoom level, as a
|
* @property {number} The current browser's zoom level, as a
|
||||||
@@ -413,7 +413,7 @@ const Buffer = Module("buffer", {
|
|||||||
/**
|
/**
|
||||||
* @property {string} The current document's title.
|
* @property {string} The current document's title.
|
||||||
*/
|
*/
|
||||||
get title() window.content.document.title,
|
get title() content.document.title,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} The buffer's horizontal scroll percentile.
|
* @property {number} The buffer's horizontal scroll percentile.
|
||||||
@@ -457,7 +457,7 @@ const Buffer = Module("buffer", {
|
|||||||
if (frame.document.body instanceof HTMLBodyElement)
|
if (frame.document.body instanceof HTMLBodyElement)
|
||||||
frames.push(frame);
|
frames.push(frame);
|
||||||
Array.forEach(frame.frames, rec);
|
Array.forEach(frame.frames, rec);
|
||||||
})(win || window.content);
|
})(win || content);
|
||||||
if (focusedFirst)
|
if (focusedFirst)
|
||||||
return frames.filter(function (f) f === buffer.focusedFrame).concat(
|
return frames.filter(function (f) f === buffer.focusedFrame).concat(
|
||||||
frames.filter(function (f) f !== buffer.focusedFrame));
|
frames.filter(function (f) f !== buffer.focusedFrame));
|
||||||
@@ -469,7 +469,7 @@ const Buffer = Module("buffer", {
|
|||||||
*/
|
*/
|
||||||
get focusedFrame() {
|
get focusedFrame() {
|
||||||
let frame = (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame;
|
let frame = (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame;
|
||||||
return frame && frame.get() || window.content;
|
return frame && frame.get() || content;
|
||||||
},
|
},
|
||||||
set focusedFrame(frame) {
|
set focusedFrame(frame) {
|
||||||
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = Cu.getWeakReference(frame);
|
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = Cu.getWeakReference(frame);
|
||||||
@@ -485,7 +485,7 @@ const Buffer = Module("buffer", {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getCurrentWord: function () {
|
getCurrentWord: function () {
|
||||||
let win = buffer.focusedFrame || window.content;
|
let win = buffer.focusedFrame || content;
|
||||||
let selection = win.getSelection();
|
let selection = win.getSelection();
|
||||||
if (selection.rangeCount == 0)
|
if (selection.rangeCount == 0)
|
||||||
return "";
|
return "";
|
||||||
@@ -821,7 +821,7 @@ const Buffer = Module("buffer", {
|
|||||||
*/
|
*/
|
||||||
scrollTo: function (x, y) {
|
scrollTo: function (x, y) {
|
||||||
marks.add("'", true);
|
marks.add("'", true);
|
||||||
window.content.scrollTo(x, y);
|
content.scrollTo(x, y);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -847,7 +847,7 @@ const Buffer = Module("buffer", {
|
|||||||
* count skips backwards.
|
* count skips backwards.
|
||||||
*/
|
*/
|
||||||
shiftFrameFocus: function (count) {
|
shiftFrameFocus: function (count) {
|
||||||
if (!(window.content.document instanceof HTMLDocument))
|
if (!(content.document instanceof HTMLDocument))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let frames = buffer.allFrames();
|
let frames = buffer.allFrames();
|
||||||
@@ -872,7 +872,7 @@ const Buffer = Module("buffer", {
|
|||||||
|
|
||||||
// focus next frame and scroll into view
|
// focus next frame and scroll into view
|
||||||
frames[next].focus();
|
frames[next].focus();
|
||||||
if (frames[next] != window.content)
|
if (frames[next] != content)
|
||||||
frames[next].frameElement.scrollIntoView(false);
|
frames[next].frameElement.scrollIntoView(false);
|
||||||
|
|
||||||
// add the frame indicator
|
// add the frame indicator
|
||||||
@@ -908,8 +908,8 @@ const Buffer = Module("buffer", {
|
|||||||
showPageInfo: function (verbose, sections) {
|
showPageInfo: function (verbose, sections) {
|
||||||
// Ctrl-g single line output
|
// Ctrl-g single line output
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
let file = window.content.document.location.pathname.split("/").pop() || "[No Name]";
|
let file = content.document.location.pathname.split("/").pop() || "[No Name]";
|
||||||
let title = window.content.document.title || "[No Title]";
|
let title = content.document.title || "[No Title]";
|
||||||
|
|
||||||
let info = template.map("gf",
|
let info = template.map("gf",
|
||||||
function (opt) template.map(buffer.pageInfo[opt][0](), util.identity, ", "),
|
function (opt) template.map(buffer.pageInfo[opt][0](), util.identity, ", "),
|
||||||
@@ -1106,7 +1106,7 @@ const Buffer = Module("buffer", {
|
|||||||
if (win && (win.scrollMaxX > 0 || win.scrollMaxY > 0))
|
if (win && (win.scrollMaxX > 0 || win.scrollMaxY > 0))
|
||||||
return win;
|
return win;
|
||||||
|
|
||||||
win = window.content;
|
win = content;
|
||||||
if (win.scrollMaxX > 0 || win.scrollMaxY > 0)
|
if (win.scrollMaxX > 0 || win.scrollMaxY > 0)
|
||||||
return win;
|
return win;
|
||||||
|
|
||||||
@@ -1307,7 +1307,7 @@ const Buffer = Module("buffer", {
|
|||||||
commands.add(["sav[eas]", "w[rite]"],
|
commands.add(["sav[eas]", "w[rite]"],
|
||||||
"Save current document to disk",
|
"Save current document to disk",
|
||||||
function (args) {
|
function (args) {
|
||||||
let doc = window.content.document;
|
let doc = content.document;
|
||||||
let chosenData = null;
|
let chosenData = null;
|
||||||
let filename = args[0];
|
let filename = args[0];
|
||||||
|
|
||||||
@@ -1351,9 +1351,9 @@ const Buffer = Module("buffer", {
|
|||||||
prefs.set("browser.download.lastDir", io.cwd);
|
prefs.set("browser.download.lastDir", io.cwd);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var contentDisposition = window.content.QueryInterface(Ci.nsIInterfaceRequestor)
|
var contentDisposition = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIDOMWindowUtils)
|
.getInterface(Ci.nsIDOMWindowUtils)
|
||||||
.getDocumentMetadata("content-disposition");
|
.getDocumentMetadata("content-disposition");
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
|
|||||||
@@ -664,7 +664,7 @@ const Commands = Module("commands", {
|
|||||||
*/
|
*/
|
||||||
hasDomain: function (command, host) {
|
hasDomain: function (command, host) {
|
||||||
try {
|
try {
|
||||||
for (let [cmd, args] in this._subCommands(command))
|
for (let [cmd, args] in this.subCommands(command))
|
||||||
if (Array.concat(cmd.domains(args)).some(function (domain) util.isSubdomain(domain, host)))
|
if (Array.concat(cmd.domains(args)).some(function (domain) util.isSubdomain(domain, host)))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -682,7 +682,7 @@ const Commands = Module("commands", {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
hasPrivateData: function (command) {
|
hasPrivateData: function (command) {
|
||||||
for (let [cmd, args] in this._subCommands(command))
|
for (let [cmd, args] in this.subCommands(command))
|
||||||
if (cmd.privateData)
|
if (cmd.privateData)
|
||||||
return !callable(cmd.privateData) || cmd.privateData(args);
|
return !callable(cmd.privateData) || cmd.privateData(args);
|
||||||
return false;
|
return false;
|
||||||
@@ -1059,7 +1059,7 @@ const Commands = Module("commands", {
|
|||||||
while (str);
|
while (str);
|
||||||
},
|
},
|
||||||
|
|
||||||
_subCommands: function (command) {
|
subCommands: function (command) {
|
||||||
let commands = [command];
|
let commands = [command];
|
||||||
while (command = commands.shift())
|
while (command = commands.shift())
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
const jsmodules = {};
|
const jsmodules = {};
|
||||||
const modules = {
|
const modules = {
|
||||||
__proto__: jsmodules,
|
__proto__: jsmodules,
|
||||||
get content() window.content,
|
get content() this.config.browser.contentWindow || window.content,
|
||||||
jsmodules: jsmodules,
|
jsmodules: jsmodules,
|
||||||
newContext: newContext,
|
newContext: newContext,
|
||||||
window: window
|
window: window
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
let win = document.commandDispatcher.focusedWindow;
|
let win = document.commandDispatcher.focusedWindow;
|
||||||
let elem = config.mainWidget || window.content;
|
let elem = config.mainWidget || content;
|
||||||
// TODO: make more generic
|
// TODO: make more generic
|
||||||
try {
|
try {
|
||||||
if (this.has("mail") && !config.isComposeWindow) {
|
if (this.has("mail") && !config.isComposeWindow) {
|
||||||
@@ -374,7 +374,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let frame = buffer.focusedFrame;
|
let frame = buffer.focusedFrame;
|
||||||
if (frame && frame.top == window.content && !Editor.getEditor(frame))
|
if (frame && frame.top == content && !Editor.getEditor(frame))
|
||||||
elem = frame;
|
elem = frame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -624,7 +624,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
data.push(<>{node.textContent}</>.toXMLString());
|
data.push(<>{node.textContent}</>.toXMLString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fix(window.content.document.documentElement);
|
fix(content.document.documentElement);
|
||||||
addDataEntry(file + ".xhtml", data.join(""));
|
addDataEntry(file + ".xhtml", data.join(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -713,7 +713,7 @@ const Events = Module("events", {
|
|||||||
if (elem == null && Editor.getEditor(win))
|
if (elem == null && Editor.getEditor(win))
|
||||||
elem = win;
|
elem = win;
|
||||||
|
|
||||||
if (win && win.top == window.content && dactyl.has("tabs"))
|
if (win && win.top == content && dactyl.has("tabs"))
|
||||||
buffer.focusedFrame = win;
|
buffer.focusedFrame = win;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1064,7 +1064,7 @@ const Events = Module("events", {
|
|||||||
isContentNode: function isContentNode(node) {
|
isContentNode: function isContentNode(node) {
|
||||||
let win = (node.ownerDocument || node).defaultView || node;
|
let win = (node.ownerDocument || node).defaultView || node;
|
||||||
for (; win; win = win.parent != win && win.parent)
|
for (; win; win = win.parent != win && win.parent)
|
||||||
if (win == window.content)
|
if (win == content)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ const RangeFind = Class("RangeFind", {
|
|||||||
this.matchCase = Boolean(matchCase);
|
this.matchCase = Boolean(matchCase);
|
||||||
this.regexp = Boolean(regexp);
|
this.regexp = Boolean(regexp);
|
||||||
|
|
||||||
this.ranges = this.makeFrameList(window.content);
|
this.ranges = this.makeFrameList(content);
|
||||||
|
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ const RangeFind = Class("RangeFind", {
|
|||||||
get searchString() this.lastString,
|
get searchString() this.lastString,
|
||||||
|
|
||||||
get selectedRange() {
|
get selectedRange() {
|
||||||
let selection = (buffer.focusedFrame || window.content).getSelection();
|
let selection = (buffer.focusedFrame || content).getSelection();
|
||||||
return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange();
|
return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange();
|
||||||
},
|
},
|
||||||
set selectedRange(range) {
|
set selectedRange(range) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ function checkFragment() {
|
|||||||
var frag = document.location.hash.substr(1);
|
var frag = document.location.hash.substr(1);
|
||||||
var elem = document.getElementById(frag);
|
var elem = document.getElementById(frag);
|
||||||
function action() {
|
function action() {
|
||||||
window.content.scrollTo(0, window.content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context
|
content.scrollTo(0, content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context
|
||||||
}
|
}
|
||||||
if (elem) {
|
if (elem) {
|
||||||
action();
|
action();
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ const Hints = Module("hints", {
|
|||||||
* Pushes the hints into the pageHints object, but does not display them.
|
* Pushes the hints into the pageHints object, but does not display them.
|
||||||
*
|
*
|
||||||
* @param {Window} win The window for which to generate hints.
|
* @param {Window} win The window for which to generate hints.
|
||||||
* @default window.content
|
* @default content
|
||||||
*/
|
*/
|
||||||
_generate: function _generate(win, offsets) {
|
_generate: function _generate(win, offsets) {
|
||||||
if (!win)
|
if (!win)
|
||||||
@@ -845,7 +845,7 @@ const Hints = Module("hints", {
|
|||||||
this._canUpdate = false;
|
this._canUpdate = false;
|
||||||
this._continue = Boolean(opts.continue);
|
this._continue = Boolean(opts.continue);
|
||||||
|
|
||||||
this._top = opts.window || window.content;
|
this._top = opts.window || content;
|
||||||
this._top.addEventListener("resize", this._resizeTimer.closure.tell, true);
|
this._top.addEventListener("resize", this._resizeTimer.closure.tell, true);
|
||||||
|
|
||||||
this._generate();
|
this._generate();
|
||||||
|
|||||||
@@ -677,7 +677,8 @@ lookup:
|
|||||||
|
|
||||||
context.title = [full ? "Path" : "Filename", "Type"];
|
context.title = [full ? "Path" : "Filename", "Type"];
|
||||||
context.keys = {
|
context.keys = {
|
||||||
text: !full ? "leafName" : function (f) dir + f.leafName,
|
text: !full ? "leafName" : function (f) this.path,
|
||||||
|
path: function (f) dir + f.leafName,
|
||||||
description: function (f) this.isdir ? "Directory" : "File",
|
description: function (f) this.isdir ? "Directory" : "File",
|
||||||
isdir: function (f) f.isDirectory(),
|
isdir: function (f) f.isDirectory(),
|
||||||
icon: function (f) this.isdir ? "resource://gre/res/html/folder.png"
|
icon: function (f) this.isdir ? "resource://gre/res/html/folder.png"
|
||||||
@@ -731,7 +732,7 @@ lookup:
|
|||||||
dir = dir.replace("/+$", "") + "/";
|
dir = dir.replace("/+$", "") + "/";
|
||||||
completion.file(context, true, dir + context.filter);
|
completion.file(context, true, dir + context.filter);
|
||||||
context.title[0] = dir;
|
context.title[0] = dir;
|
||||||
context.keys.text = function (f) f.path.substr(dir.length);
|
context.keys.text = function (f) this.path.substr(dir.length);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ const JavaScript = Module("javascript", {
|
|||||||
|
|
||||||
// Find any complete statements that we can eval before we eval our object.
|
// Find any complete statements that we can eval before we eval our object.
|
||||||
// This allows for things like:
|
// This allows for things like:
|
||||||
// let doc = window.content.document; let elem = doc.createEle<Tab> ...
|
// let doc = content.document; let elem = doc.createEle<Tab> ...
|
||||||
let prev = 0;
|
let prev = 0;
|
||||||
for (let [, v] in Iterator(this._get(0).fullStatements)) {
|
for (let [, v] in Iterator(this._get(0).fullStatements)) {
|
||||||
let key = this._str.substring(prev, v + 1);
|
let key = this._str.substring(prev, v + 1);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const Modes = Module("modes", {
|
|||||||
this.addMode("VISUAL", { char: "v", ownsFocus: true, display: function () "VISUAL" + (this._extended & modes.LINE ? " LINE" : "") }, {
|
this.addMode("VISUAL", { char: "v", ownsFocus: true, display: function () "VISUAL" + (this._extended & modes.LINE ? " LINE" : "") }, {
|
||||||
leave: function (stack, newMode) {
|
leave: function (stack, newMode) {
|
||||||
if (newMode.main == modes.CARET) {
|
if (newMode.main == modes.CARET) {
|
||||||
let selection = window.content.getSelection();
|
let selection = content.getSelection();
|
||||||
if (selection && !selection.isCollapsed)
|
if (selection && !selection.isCollapsed)
|
||||||
selection.collapseToStart();
|
selection.collapseToStart();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user