mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 14:27:59 +01:00
Cleanup/fix buffer.shiftFrameFocus. Other misc cleanup/fixes.
This commit is contained in:
@@ -364,11 +364,11 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB);
|
return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB);
|
||||||
|
|
||||||
if (filter.length > 0 && tags.length > 0)
|
if (filter.length > 0 && tags.length > 0)
|
||||||
dactyl.echoerr("E283: No bookmarks matching tags: " + tags.quote() + " and string: " + filter.quote());
|
dactyl.echoerr("E283: No bookmarks matching tags: " + tags.map(String.quote) + " and string: " + filter.quote());
|
||||||
else if (filter.length > 0)
|
else if (filter.length > 0)
|
||||||
dactyl.echoerr("E283: No bookmarks matching string: " + filter.quote());
|
dactyl.echoerr("E283: No bookmarks matching string: " + filter.quote());
|
||||||
else if (tags.length > 0)
|
else if (tags.length > 0)
|
||||||
dactyl.echoerr("E283: No bookmarks matching tags: " + tags.quote());
|
dactyl.echoerr("E283: No bookmarks matching tags: " + tags.map(String.quote));
|
||||||
else
|
else
|
||||||
dactyl.echoerr("No bookmarks set");
|
dactyl.echoerr("No bookmarks set");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -494,6 +494,8 @@ const Buffer = Module("buffer", {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
focusAllowed: function (elem) {
|
focusAllowed: function (elem) {
|
||||||
|
if (elem instanceof Window && !Editor.getEditor(window))
|
||||||
|
return true;
|
||||||
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
|
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
|
||||||
return !options["strictfocus"] || win.dactylFocusAllowed;
|
return !options["strictfocus"] || win.dactylFocusAllowed;
|
||||||
},
|
},
|
||||||
@@ -811,52 +813,34 @@ const Buffer = Module("buffer", {
|
|||||||
* @param {number} count The number of frames to skip through.
|
* @param {number} count The number of frames to skip through.
|
||||||
* @param {boolean} forward The direction of motion.
|
* @param {boolean} forward The direction of motion.
|
||||||
*/
|
*/
|
||||||
shiftFrameFocus: function (count, forward) {
|
shiftFrameFocus: function (count) {
|
||||||
if (!(window.content.document instanceof HTMLDocument))
|
if (!(window.content.document instanceof HTMLDocument))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
count = Math.max(count, 1);
|
|
||||||
let frames = buffer.allFrames();
|
let frames = buffer.allFrames();
|
||||||
|
|
||||||
if (frames.length == 0) // currently top is always included
|
if (frames.length == 0) // currently top is always included
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// remove all unfocusable frames
|
// remove all hidden frames
|
||||||
// TODO: find a better way to do this - walking the tree is too slow
|
frames = frames.filter(function (frame) !(frame.document.body instanceof HTMLFrameSetElement))
|
||||||
let start = document.commandDispatcher.focusedWindow;
|
.filter(function (frame) !frame.frameElement ||
|
||||||
frames = frames.filter(function (frame) {
|
let (rect = frame.frameElement.getBoundingClientRect())
|
||||||
frame.focus();
|
rect.width && rect.height);
|
||||||
return document.commandDispatcher.focusedWindow == frame;
|
|
||||||
});
|
|
||||||
start.focus();
|
|
||||||
|
|
||||||
// find the currently focused frame index
|
// find the currently focused frame index
|
||||||
// TODO: If the window is a frameset then the first _frame_ should be
|
// TODO: If the window is a frameset then the first _frame_ should be
|
||||||
// focused. Since this is not the current FF behavior,
|
// focused. Since this is not the current FF behavior,
|
||||||
// we initialize current to -1 so the first call takes us to the
|
// we initialize current to -1 so the first call takes us to the
|
||||||
// first frame.
|
// first frame.
|
||||||
let current = frames.indexOf(document.commandDispatcher.focusedWindow);
|
let current = Math.max(0, frames.indexOf(buffer.focusedFrame));
|
||||||
|
|
||||||
// calculate the next frame to focus
|
// calculate the next frame to focus
|
||||||
let next = current;
|
let next = current + count;
|
||||||
if (forward) {
|
if (next < 0 || next >= frames.length)
|
||||||
next = current + count;
|
dactyl.beep();
|
||||||
|
next = Math.constrain(next, 0, frames.length - 1);
|
||||||
if (next > frames.length - 1) {
|
util.dump(current, count, next, String(frames[next]));
|
||||||
if (current == frames.length - 1)
|
|
||||||
dactyl.beep();
|
|
||||||
next = frames.length - 1; // still allow the frame indicator to be activated
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
next = current - count;
|
|
||||||
|
|
||||||
if (next < 0) {
|
|
||||||
if (current == 0)
|
|
||||||
dactyl.beep();
|
|
||||||
next = 0; // still allow the frame indicator to be activated
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// focus next frame and scroll into view
|
// focus next frame and scroll into view
|
||||||
frames[next].focus();
|
frames[next].focus();
|
||||||
@@ -866,7 +850,7 @@ const Buffer = Module("buffer", {
|
|||||||
// add the frame indicator
|
// add the frame indicator
|
||||||
let doc = frames[next].document;
|
let doc = frames[next].document;
|
||||||
let indicator = util.xmlToDom(<div highlight="FrameIndicator"/>, doc);
|
let indicator = util.xmlToDom(<div highlight="FrameIndicator"/>, doc);
|
||||||
doc.body.appendChild(indicator);
|
(doc.body || doc.documentElement || doc).appendChild(indicator);
|
||||||
|
|
||||||
util.timeout(function () { doc.body.removeChild(indicator); }, 500);
|
util.timeout(function () { doc.body.removeChild(indicator); }, 500);
|
||||||
|
|
||||||
@@ -1586,12 +1570,12 @@ const Buffer = Module("buffer", {
|
|||||||
|
|
||||||
mappings.add(myModes, ["]f"],
|
mappings.add(myModes, ["]f"],
|
||||||
"Focus next frame",
|
"Focus next frame",
|
||||||
function (count) { buffer.shiftFrameFocus(Math.max(count, 1), true); },
|
function (count) { buffer.shiftFrameFocus(Math.max(count, 1)); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["[f"],
|
mappings.add(myModes, ["[f"],
|
||||||
"Focus previous frame",
|
"Focus previous frame",
|
||||||
function (count) { buffer.shiftFrameFocus(Math.max(count, 1), false); },
|
function (count) { buffer.shiftFrameFocus(-Math.max(count, 1)); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["]]"],
|
mappings.add(myModes, ["]]"],
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
highlight.highlightNode(document.documentElement, "Bell");
|
highlight.highlightNode(document.documentElement, "Bell");
|
||||||
util.timeout(function () { document.documentElement.removeAttributeNS(NS, "highlight"); }, 20);
|
util.timeout(function () { document.documentElement.removeAttributeNS(NS, "highlight"); }, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1268,7 +1268,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["urlseparator", "us"],
|
options.add(["urlseparator", "urlsep", "us"],
|
||||||
"Set the separator regexp used to separate multiple URL args",
|
"Set the separator regexp used to separate multiple URL args",
|
||||||
"string", "\\|");
|
"string", "\\|");
|
||||||
|
|
||||||
|
|||||||
@@ -233,7 +233,7 @@
|
|||||||
<span dactyl:highlight="HelpDefault">(default:<xsl:text> </xsl:text>
|
<span dactyl:highlight="HelpDefault">(default:<xsl:text> </xsl:text>
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$type = 'string'">
|
<xsl:when test="$type = 'string'">
|
||||||
<span dactyl:highlight="HelpString"><xsl:apply-templates mode="help-1"/></span>
|
<span dactyl:highlight="HelpString" delim="'"><xsl:apply-templates mode="help-1"/></span>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="contains($type, 'list') or contains($type, 'map')">
|
<xsl:when test="contains($type, 'list') or contains($type, 'map')">
|
||||||
<span dactyl:highlight="HelpString" delim=""><xsl:apply-templates mode="help-1"/></span>
|
<span dactyl:highlight="HelpString" delim=""><xsl:apply-templates mode="help-1"/></span>
|
||||||
|
|||||||
@@ -794,7 +794,7 @@ const Hints = Module("hints", {
|
|||||||
|
|
||||||
open: function open(mode, opts) {
|
open: function open(mode, opts) {
|
||||||
this._extendedhintCount = opts.count;
|
this._extendedhintCount = opts.count;
|
||||||
commandline.input(";", null, {
|
commandline.input(mode, null, {
|
||||||
promptHighlight: "Normal",
|
promptHighlight: "Normal",
|
||||||
completer: function (context) {
|
completer: function (context) {
|
||||||
context.compare = function () 0;
|
context.compare = function () 0;
|
||||||
@@ -1086,16 +1086,6 @@ const Hints = Module("hints", {
|
|||||||
"Start QuickHint mode",
|
"Start QuickHint mode",
|
||||||
function () { hints.show("o"); });
|
function () { hints.show("o"); });
|
||||||
|
|
||||||
// At the moment, "F" calls
|
|
||||||
// buffer.followLink(clicked_element, DO_WHAT_FIREFOX_DOES_WITH_CNTRL_CLICK)
|
|
||||||
// It is not clear that it shouldn't be:
|
|
||||||
// buffer.followLink(clicked_element, !DO_WHAT_FIREFOX_DOES_WITH_CNTRL_CLICK)
|
|
||||||
// In fact, it might be nice if there was a "dual" to F (like H and
|
|
||||||
// gH, except that gF is already taken). --tpp
|
|
||||||
//
|
|
||||||
// Likewise, it might be nice to have a dactyl.NEW_FOREGROUND_TAB
|
|
||||||
// and then make dactyl.NEW_TAB always do what a Cntrl+Click
|
|
||||||
// does. --tpp
|
|
||||||
mappings.add(myModes, ["F"],
|
mappings.add(myModes, ["F"],
|
||||||
"Start QuickHint mode, but open link in a new tab",
|
"Start QuickHint mode, but open link in a new tab",
|
||||||
function () { hints.show(options.get("activate").has("links") ? "t" : "b"); });
|
function () { hints.show(options.get("activate").has("links") ? "t" : "b"); });
|
||||||
|
|||||||
@@ -616,7 +616,7 @@
|
|||||||
//xhtml:input[not(@type=''hidden'')] |
|
//xhtml:input[not(@type=''hidden'')] |
|
||||||
//textarea | //xhtml:textarea |
|
//textarea | //xhtml:textarea |
|
||||||
//button | //xhtml:button |
|
//button | //xhtml:button |
|
||||||
//select | //xhtml:select' </default>
|
//select | //xhtml:select'</default>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
Defines specialized XPath expressions for arbitrary
|
Defines specialized XPath expressions for arbitrary
|
||||||
@@ -796,7 +796,7 @@
|
|||||||
</dd>
|
</dd>
|
||||||
<dt>transliterated</dt>
|
<dt>transliterated</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Certain alphanumeric characters are translated into their
|
Certain alphanumeric characters are transliterated into their
|
||||||
unaccented equivalents, such that ‘euro’ will match 'æuró',
|
unaccented equivalents, such that ‘euro’ will match 'æuró',
|
||||||
and ‘Ångström’ will match ‘angstrom’.
|
and ‘Ångström’ will match ‘angstrom’.
|
||||||
</dd>
|
</dd>
|
||||||
@@ -927,7 +927,7 @@
|
|||||||
<dt>2</dt> <dd>Always</dd>
|
<dt>2</dt> <dd>Always</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<note>laststatus=1 not implemented.</note>
|
<note>laststatus=1 is not implemented.</note>
|
||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
@@ -1418,10 +1418,10 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>'us' 'urlseparator'</tags>
|
<tags>'us' 'urlsep' 'urlseparator'</tags>
|
||||||
<spec>'urlseparator'</spec>
|
<spec>'urlseparator'</spec>
|
||||||
<type>string</type>
|
<type>string</type>
|
||||||
<default>\\|</default>
|
<default>\|</default>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
The regular expression used to split URL lists in commands
|
The regular expression used to split URL lists in commands
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
|||||||
}</rows>
|
}</rows>
|
||||||
</grid>
|
</grid>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
},
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
let (branch = Item.PREFIX + Item.BRANCH) {
|
let (branch = Item.PREFIX + Item.BRANCH) {
|
||||||
@@ -328,14 +328,18 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
|||||||
prefToArg: function (pref) pref.replace(/.*\./, "").toLowerCase(),
|
prefToArg: function (pref) pref.replace(/.*\./, "").toLowerCase(),
|
||||||
|
|
||||||
iterCookies: function iterCookies(host) {
|
iterCookies: function iterCookies(host) {
|
||||||
for (let c in iter(services.get("cookies")))
|
for (let c in iter(services.get("cookies"))) {
|
||||||
if (c.QueryInterface(Ci.nsICookie2) && !host || util.isSubdomain(c.rawHost, host))
|
c.QueryInterface(Ci.nsICookie2);
|
||||||
|
if (!host || util.isSubdomain(c.rawHost, host))
|
||||||
yield c;
|
yield c;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
iterPermissions: function iterPermissions(host) {
|
iterPermissions: function iterPermissions(host) {
|
||||||
for (let p in iter(services.get("permissions")))
|
for (let p in iter(services.get("permissions"))) {
|
||||||
if (p.QueryInterface(Ci.nsIPermission) && (!host || util.isSubdomain(p.host, host)))
|
p.QueryInterface(Ci.nsIPermission);
|
||||||
|
if (!host || util.isSubdomain(p.host, host))
|
||||||
yield p;
|
yield p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
load: function (dactyl, modules, window) {
|
load: function (dactyl, modules, window) {
|
||||||
@@ -443,7 +447,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
|||||||
services.get("permissions").add(uri, "cookie", Sanitizer.PERMS[perm]);
|
services.get("permissions").add(uri, "cookie", Sanitizer.PERMS[perm]);
|
||||||
}
|
}
|
||||||
commands.add(["cookies", "ck"],
|
commands.add(["cookies", "ck"],
|
||||||
"Change cookie permissions for sites.",
|
"Change cookie permissions for sites",
|
||||||
function (args) {
|
function (args) {
|
||||||
let host = args.shift();
|
let host = args.shift();
|
||||||
let session = true;
|
let session = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user