mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-24 20:25:46 +01:00
Fix RangeFind quirks.
This commit is contained in:
@@ -266,8 +266,9 @@ var MOW = Module("mow", {
|
|||||||
* and what they do.
|
* and what they do.
|
||||||
*/
|
*/
|
||||||
updateMorePrompt: function updateMorePrompt(force, showHelp) {
|
updateMorePrompt: function updateMorePrompt(force, showHelp) {
|
||||||
if (!this.visible)
|
if (!this.visible || !isinstance(modes.main, modes.OUTPUT_MULTILINE))
|
||||||
return this.widgets.message = null;
|
return this.widgets.message = null;
|
||||||
|
|
||||||
let elem = this.widget.contentDocument.documentElement;
|
let elem = this.widget.contentDocument.documentElement;
|
||||||
|
|
||||||
if (showHelp)
|
if (showHelp)
|
||||||
|
|||||||
@@ -20,7 +20,12 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
this.lastFindPattern = "";
|
this.lastFindPattern = "";
|
||||||
},
|
},
|
||||||
|
|
||||||
get rangeFind() modules.buffer.localStore.rangeFind,
|
get rangeFind() {
|
||||||
|
let find = modules.buffer.localStore.rangeFind;
|
||||||
|
if (find && find.stale || !isinstance(find, RangeFind))
|
||||||
|
return this.rangeFind = null;
|
||||||
|
return find;
|
||||||
|
},
|
||||||
set rangeFind(val) modules.buffer.localStore.rangeFind = val
|
set rangeFind(val) modules.buffer.localStore.rangeFind = val
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -38,9 +43,6 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
bootstrap: function (str, backward) {
|
bootstrap: function (str, backward) {
|
||||||
if (this.rangeFind && this.rangeFind.stale)
|
|
||||||
this.rangeFind = null;
|
|
||||||
|
|
||||||
let highlighted = this.rangeFind && this.rangeFind.highlighted;
|
let highlighted = this.rangeFind && this.rangeFind.highlighted;
|
||||||
let selections = this.rangeFind && this.rangeFind.selections;
|
let selections = this.rangeFind && this.rangeFind.selections;
|
||||||
let linksOnly = false;
|
let linksOnly = false;
|
||||||
@@ -69,7 +71,7 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
// It's possible, with :tabdetach for instance, for the rangeFind to
|
// It's possible, with :tabdetach for instance, for the rangeFind to
|
||||||
// actually move from one window to another, which breaks things.
|
// actually move from one window to another, which breaks things.
|
||||||
if (!this.rangeFind
|
if (!this.rangeFind
|
||||||
|| this.rangeFind.window.get() != this.window
|
|| this.rangeFind.window.get() !== this.window
|
||||||
|| linksOnly != !!this.rangeFind.elementPath
|
|| linksOnly != !!this.rangeFind.elementPath
|
||||||
|| regexp != this.rangeFind.regexp
|
|| regexp != this.rangeFind.regexp
|
||||||
|| matchCase != this.rangeFind.matchCase
|
|| matchCase != this.rangeFind.matchCase
|
||||||
@@ -98,7 +100,7 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
findAgain: function (reverse) {
|
findAgain: function (reverse) {
|
||||||
if (!this.rangeFind || this.rangeFind.stale)
|
if (!this.rangeFind)
|
||||||
this.find(this.lastFindPattern);
|
this.find(this.lastFindPattern);
|
||||||
else if (!this.rangeFind.find(null, reverse))
|
else if (!this.rangeFind.find(null, reverse))
|
||||||
this.dactyl.echoerr("E486: Pattern not found: " + this.lastFindPattern,
|
this.dactyl.echoerr("E486: Pattern not found: " + this.lastFindPattern,
|
||||||
@@ -196,7 +198,7 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
|
|
||||||
get prompt() this.mode === modules.modes.FIND_BACKWARD ? "?" : "/",
|
get prompt() this.mode === modules.modes.FIND_BACKWARD ? "?" : "/",
|
||||||
|
|
||||||
get onCancel() rangefinder.closure.onCancel,
|
get onCancel() modules.rangefinder.closure.onCancel,
|
||||||
get onChange() modules.rangefinder.closure.onChange,
|
get onChange() modules.rangefinder.closure.onChange,
|
||||||
get onSubmit() modules.rangefinder.closure.onSubmit
|
get onSubmit() modules.rangefinder.closure.onSubmit
|
||||||
});
|
});
|
||||||
@@ -293,7 +295,7 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
* large amounts of data are concerned (e.g., for API documents).
|
* large amounts of data are concerned (e.g., for API documents).
|
||||||
*/
|
*/
|
||||||
var RangeFind = Class("RangeFind", {
|
var RangeFind = Class("RangeFind", {
|
||||||
init: function (window, matchCase, backward, elementPath, regexp) {
|
init: function init(window, matchCase, backward, elementPath, regexp) {
|
||||||
this.window = Cu.getWeakReference(window);
|
this.window = Cu.getWeakReference(window);
|
||||||
this.content = window.content;
|
this.content = window.content;
|
||||||
|
|
||||||
@@ -305,8 +307,6 @@ var RangeFind = Class("RangeFind", {
|
|||||||
this.matchCase = Boolean(matchCase);
|
this.matchCase = Boolean(matchCase);
|
||||||
this.regexp = Boolean(regexp);
|
this.regexp = Boolean(regexp);
|
||||||
|
|
||||||
this.ranges = this.makeFrameList(this.content);
|
|
||||||
|
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
||||||
this.highlighted = null;
|
this.highlighted = null;
|
||||||
@@ -348,13 +348,13 @@ var RangeFind = Class("RangeFind", {
|
|||||||
this.store.focusedFrame = Cu.getWeakReference(range.startContainer.ownerDocument.defaultView);
|
this.store.focusedFrame = Cu.getWeakReference(range.startContainer.ownerDocument.defaultView);
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel: function () {
|
cancel: function cancel() {
|
||||||
this.purgeListeners();
|
this.purgeListeners();
|
||||||
this.range.deselect();
|
this.range.deselect();
|
||||||
this.range.descroll();
|
this.range.descroll();
|
||||||
},
|
},
|
||||||
|
|
||||||
compareRanges: function (r1, r2) {
|
compareRanges: function compareRanges(r1, r2) {
|
||||||
try {
|
try {
|
||||||
return this.backward ? r1.compareBoundaryPoints(r1.END_TO_START, r2)
|
return this.backward ? r1.compareBoundaryPoints(r1.END_TO_START, r2)
|
||||||
: -r1.compareBoundaryPoints(r1.START_TO_END, r2);
|
: -r1.compareBoundaryPoints(r1.START_TO_END, r2);
|
||||||
@@ -365,7 +365,7 @@ var RangeFind = Class("RangeFind", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
findRange: function (range) {
|
findRange: function findRange(range) {
|
||||||
let doc = range.startContainer.ownerDocument;
|
let doc = range.startContainer.ownerDocument;
|
||||||
let win = doc.defaultView;
|
let win = doc.defaultView;
|
||||||
let ranges = this.ranges.filter(function (r)
|
let ranges = this.ranges.filter(function (r)
|
||||||
@@ -376,7 +376,7 @@ var RangeFind = Class("RangeFind", {
|
|||||||
return ranges[0];
|
return ranges[0];
|
||||||
},
|
},
|
||||||
|
|
||||||
findSubRanges: function (range) {
|
findSubRanges: function findSubRanges(range) {
|
||||||
let doc = range.startContainer.ownerDocument;
|
let doc = range.startContainer.ownerDocument;
|
||||||
for (let elem in util.evaluateXPath(this.elementPath, doc)) {
|
for (let elem in util.evaluateXPath(this.elementPath, doc)) {
|
||||||
let r = RangeFind.nodeRange(elem);
|
let r = RangeFind.nodeRange(elem);
|
||||||
@@ -385,7 +385,7 @@ var RangeFind = Class("RangeFind", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
focus: function () {
|
focus: function focus() {
|
||||||
if (this.lastRange)
|
if (this.lastRange)
|
||||||
var node = util.evaluateXPath(RangeFind.selectNodePath,
|
var node = util.evaluateXPath(RangeFind.selectNodePath,
|
||||||
this.lastRange.commonAncestorContainer).snapshotItem(0);
|
this.lastRange.commonAncestorContainer).snapshotItem(0);
|
||||||
@@ -396,8 +396,7 @@ var RangeFind = Class("RangeFind", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
highlight: function (clear) {
|
highlight: function highlight(clear) {
|
||||||
|
|
||||||
if (!clear && (!this.lastString || this.lastString == this.highlighted))
|
if (!clear && (!this.lastString || this.lastString == this.highlighted))
|
||||||
return;
|
return;
|
||||||
if (clear && !this.highlighted)
|
if (clear && !this.highlighted)
|
||||||
@@ -516,6 +515,8 @@ var RangeFind = Class("RangeFind", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset: function () {
|
reset: function () {
|
||||||
|
this.ranges = this.makeFrameList(this.content);
|
||||||
|
|
||||||
this.startRange = this.selectedRange;
|
this.startRange = this.selectedRange;
|
||||||
this.startRange.collapse(!this.reverse);
|
this.startRange.collapse(!this.reverse);
|
||||||
this.lastRange = this.selectedRange;
|
this.lastRange = this.selectedRange;
|
||||||
@@ -636,7 +637,7 @@ var RangeFind = Class("RangeFind", {
|
|||||||
onUnload: function (event) {
|
onUnload: function (event) {
|
||||||
this.purgeListeners();
|
this.purgeListeners();
|
||||||
if (this.highlighted)
|
if (this.highlighted)
|
||||||
this.highlight(false);
|
this.highlight(true);
|
||||||
this.stale = true;
|
this.stale = true;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
Reference in New Issue
Block a user