mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 18:57:59 +01:00
Add search to the MOW, skip search results in hidden nodes, and fix MOW sizing issues.
This commit is contained in:
@@ -275,7 +275,7 @@ var Buffer = Module("buffer", {
|
|||||||
*/
|
*/
|
||||||
get localStore() {
|
get localStore() {
|
||||||
let doc = content.document;
|
let doc = content.document;
|
||||||
let store = overlay.getData(doc, "buffer");
|
let store = overlay.getData(doc, "buffer", null);
|
||||||
if (!store || !buffer.localStorePrototype.isPrototypeOf(store))
|
if (!store || !buffer.localStorePrototype.isPrototypeOf(store))
|
||||||
store = overlay.setData(doc, "buffer", Object.create(buffer.localStorePrototype));
|
store = overlay.setData(doc, "buffer", Object.create(buffer.localStorePrototype));
|
||||||
return store.instance = store;
|
return store.instance = store;
|
||||||
|
|||||||
@@ -153,6 +153,8 @@ var CommandWidgets = Class("CommandWidgets", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.updateVisibility();
|
this.updateVisibility();
|
||||||
|
|
||||||
|
this.initialized = true;
|
||||||
},
|
},
|
||||||
addElement: function addElement(obj) {
|
addElement: function addElement(obj) {
|
||||||
const self = this;
|
const self = this;
|
||||||
@@ -250,6 +252,9 @@ var CommandWidgets = Class("CommandWidgets", {
|
|||||||
Array.forEach(node.children, check);
|
Array.forEach(node.children, check);
|
||||||
}
|
}
|
||||||
[this.commandbar.container, this.statusbar.container].forEach(check);
|
[this.commandbar.container, this.statusbar.container].forEach(check);
|
||||||
|
|
||||||
|
if (this.initialized && loaded.mow && mow.visible)
|
||||||
|
mow.resize(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
active: Class.Memoize(Object),
|
active: Class.Memoize(Object),
|
||||||
|
|||||||
@@ -103,12 +103,15 @@ var MOW = Module("mow", {
|
|||||||
if (modes.main != modes.OUTPUT_MULTILINE) {
|
if (modes.main != modes.OUTPUT_MULTILINE) {
|
||||||
modes.push(modes.OUTPUT_MULTILINE, null, {
|
modes.push(modes.OUTPUT_MULTILINE, null, {
|
||||||
onKeyPress: this.closure.onKeyPress,
|
onKeyPress: this.closure.onKeyPress,
|
||||||
|
|
||||||
leave: this.closure(function leave(stack) {
|
leave: this.closure(function leave(stack) {
|
||||||
if (stack.pop)
|
if (stack.pop)
|
||||||
for (let message in values(this.messages))
|
for (let message in values(this.messages))
|
||||||
if (message.leave)
|
if (message.leave)
|
||||||
message.leave(stack);
|
message.leave(stack);
|
||||||
})
|
}),
|
||||||
|
|
||||||
|
window: this.window
|
||||||
});
|
});
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
}
|
}
|
||||||
@@ -241,12 +244,14 @@ var MOW = Module("mow", {
|
|||||||
|
|
||||||
let doc = this.widget.contentDocument;
|
let doc = this.widget.contentDocument;
|
||||||
|
|
||||||
let availableHeight = config.outputHeight;
|
let trim = Math.max(0, DOM("#" + config.ids.commandContainer, document).rect.bottom - window.innerHeight);
|
||||||
|
let availableHeight = config.outputHeight - trim;
|
||||||
if (this.visible)
|
if (this.visible)
|
||||||
availableHeight += parseFloat(this.widgets.mowContainer.height || 0);
|
availableHeight += parseFloat(this.widgets.mowContainer.height || 0);
|
||||||
availableHeight -= extra || 0;
|
availableHeight -= extra || 0;
|
||||||
|
|
||||||
doc.body.style.minWidth = this.widgets.commandbar.commandline.scrollWidth + "px";
|
doc.body.style.minWidth = this.widgets.commandbar.commandline.scrollWidth + "px";
|
||||||
|
|
||||||
this.widgets.mowContainer.height = Math.min(doc.body.clientHeight, availableHeight) + "px";
|
this.widgets.mowContainer.height = Math.min(doc.body.clientHeight, availableHeight) + "px";
|
||||||
this.timeout(function ()
|
this.timeout(function ()
|
||||||
this.widgets.mowContainer.height = Math.min(doc.body.clientHeight, availableHeight) + "px",
|
this.widgets.mowContainer.height = Math.min(doc.body.clientHeight, availableHeight) + "px",
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ defineModule("finder", {
|
|||||||
require: ["prefs"]
|
require: ["prefs"]
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
this.lazyRequire("overlay", ["overlay"]);
|
||||||
|
|
||||||
function equals(a, b) XPCNativeWrapper(a) == XPCNativeWrapper(b);
|
function equals(a, b) XPCNativeWrapper(a) == XPCNativeWrapper(b);
|
||||||
|
|
||||||
/** @instance rangefinder */
|
/** @instance rangefinder */
|
||||||
@@ -22,13 +24,21 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
this.lastFindPattern = "";
|
this.lastFindPattern = "";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get content() {
|
||||||
|
let { window } = this.modes.getStack(0).params;
|
||||||
|
return window || this.window.content;
|
||||||
|
},
|
||||||
|
|
||||||
get rangeFind() {
|
get rangeFind() {
|
||||||
let find = modules.buffer.localStore.rangeFind;
|
let find = overlay.getData(this.content.document,
|
||||||
if (find && find.stale || !isinstance(find, RangeFind))
|
"range-find", null);
|
||||||
|
|
||||||
|
if (!isinstance(find, RangeFind) || find.stale)
|
||||||
return this.rangeFind = null;
|
return this.rangeFind = null;
|
||||||
return find;
|
return find;
|
||||||
},
|
},
|
||||||
set rangeFind(val) modules.buffer.localStore.rangeFind = val
|
set rangeFind(val) overlay.setData(this.content.document,
|
||||||
|
"range-find", val)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
init: function init() {
|
init: function init() {
|
||||||
@@ -44,7 +54,7 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
openPrompt: function (mode) {
|
openPrompt: function (mode) {
|
||||||
this.modules.marks.push();
|
this.modules.marks.push();
|
||||||
this.commandline;
|
this.commandline;
|
||||||
this.CommandMode(mode).open();
|
this.CommandMode(mode, this.content).open();
|
||||||
|
|
||||||
if (this.rangeFind && equals(this.rangeFind.window.get(), this.window))
|
if (this.rangeFind && equals(this.rangeFind.window.get(), this.window))
|
||||||
this.rangeFind.reset();
|
this.rangeFind.reset();
|
||||||
@@ -95,7 +105,7 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
|
|
||||||
if (this.rangeFind)
|
if (this.rangeFind)
|
||||||
this.rangeFind.cancel();
|
this.rangeFind.cancel();
|
||||||
this.rangeFind = RangeFind(this.window, matchCase, backward,
|
this.rangeFind = RangeFind(this.window, this.content, matchCase, backward,
|
||||||
linksOnly && this.options.get("hinttags").matcher,
|
linksOnly && this.options.get("hinttags").matcher,
|
||||||
regexp);
|
regexp);
|
||||||
this.rangeFind.highlighted = highlighted;
|
this.rangeFind.highlighted = highlighted;
|
||||||
@@ -211,8 +221,9 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
commandline: function initCommandline(dactyl, modules, window) {
|
commandline: function initCommandline(dactyl, modules, window) {
|
||||||
const { rangefinder } = modules;
|
const { rangefinder } = modules;
|
||||||
rangefinder.CommandMode = Class("CommandFindMode", modules.CommandMode, {
|
rangefinder.CommandMode = Class("CommandFindMode", modules.CommandMode, {
|
||||||
init: function init(mode) {
|
init: function init(mode, window) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
this.window = window;
|
||||||
init.supercall(this);
|
init.supercall(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -327,9 +338,9 @@ 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 init(window, matchCase, backward, elementPath, regexp) {
|
init: function init(window, content, matchCase, backward, elementPath, regexp) {
|
||||||
this.window = Cu.getWeakReference(window);
|
this.window = Cu.getWeakReference(window);
|
||||||
this.content = window.content;
|
this.content = content;
|
||||||
|
|
||||||
this.baseDocument = Cu.getWeakReference(this.content.document);
|
this.baseDocument = Cu.getWeakReference(this.content.document);
|
||||||
this.elementPath = elementPath || null;
|
this.elementPath = elementPath || null;
|
||||||
@@ -346,7 +357,7 @@ var RangeFind = Class("RangeFind", {
|
|||||||
this.lastString = "";
|
this.lastString = "";
|
||||||
},
|
},
|
||||||
|
|
||||||
get store() this.content.document.dactylStore = this.content.document.dactylStore || {},
|
get store() overlay.getData(this.content.document, "buffer", Object),
|
||||||
|
|
||||||
get backward() this.finder.findBackwards,
|
get backward() this.finder.findBackwards,
|
||||||
set backward(val) this.finder.findBackwards = val,
|
set backward(val) this.finder.findBackwards = val,
|
||||||
@@ -682,7 +693,7 @@ var RangeFind = Class("RangeFind", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var range = this.finder.Find(word, this.range.range, start, this.range.range);
|
var range = this.finder.Find(word, this.range.range, start, this.range.range);
|
||||||
if (range)
|
if (range && DOM(range.commonAncestorContainer).isVisible)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ FEATURES:
|
|||||||
9 add [count] support to :b* and :tab* commands where missing
|
9 add [count] support to :b* and :tab* commands where missing
|
||||||
8 wherever possible: get rid of dialogs and ask console-like dialog questions
|
8 wherever possible: get rid of dialogs and ask console-like dialog questions
|
||||||
or write error prompts directly on the webpage or with :echo()
|
or write error prompts directly on the webpage or with :echo()
|
||||||
8 add search capability to MOW
|
|
||||||
8 registers
|
8 registers
|
||||||
8 Document Caret and Visual modes.
|
8 Document Caret and Visual modes.
|
||||||
8 add support for filename special characters such as %
|
8 add support for filename special characters such as %
|
||||||
|
|||||||
Reference in New Issue
Block a user