mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 19:07:58 +01:00
Last commit, only better and with collateral fixes.
--HG-- branch : groups
This commit is contained in:
@@ -274,11 +274,20 @@ var EventHive = Class("EventHive", Group.Hive, {
|
|||||||
* phase, otherwise during the bubbling phase.
|
* phase, otherwise during the bubbling phase.
|
||||||
*/
|
*/
|
||||||
listen: function (target, event, callback, capture) {
|
listen: function (target, event, callback, capture) {
|
||||||
let args = Array.slice(arguments, 0);
|
if (isObject(event))
|
||||||
args[2] = this.wrapListener(callback);
|
var [self, events] = [event, event[callback]];
|
||||||
args[0].addEventListener.apply(args[0], args.slice(1));
|
else
|
||||||
args[0] = Cu.getWeakReference(args[0]);
|
[self, events] = [null, array.toObject([[event, callback]])];
|
||||||
this.sessionListeners.push(args);
|
|
||||||
|
for (let [event, callback] in Iterator(events)) {
|
||||||
|
let args = [Cu.getWeakReference(target),
|
||||||
|
event,
|
||||||
|
this.wrapListener(callback, self),
|
||||||
|
capture];
|
||||||
|
|
||||||
|
target.addEventListener.apply(target, args.slice(1));
|
||||||
|
this.sessionListeners.push(args);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,8 +402,7 @@ var Events = Module("events", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._activeMenubar = false;
|
this._activeMenubar = false;
|
||||||
for (let [event, callback] in Iterator(this.events))
|
this.listen(window, this, "events");
|
||||||
this.listen(window, event, callback, true);
|
|
||||||
|
|
||||||
dactyl.registerObserver("modeChange", function () {
|
dactyl.registerObserver("modeChange", function () {
|
||||||
delete self.processor;
|
delete self.processor;
|
||||||
|
|||||||
@@ -9,7 +9,30 @@
|
|||||||
var MOW = Module("mow", {
|
var MOW = Module("mow", {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
this._resize = Timer(20, 400, function (force) { this.resize(force) }, this);
|
this._resize = Timer(20, 400, function () {
|
||||||
|
if (this.visible) {
|
||||||
|
this.resize(false);
|
||||||
|
this.updateMorePrompt();
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this._timer = Timer(20, 400, function () {
|
||||||
|
util.dump("RESIZE " + this.window.document.body.textContent);
|
||||||
|
this.resize(true);
|
||||||
|
|
||||||
|
if (options["more"] && this.isScrollable(1)) {
|
||||||
|
// start the last executed command's output at the top of the screen
|
||||||
|
let elements = this.document.getElementsByClassName("ex-command-output");
|
||||||
|
elements[elements.length - 1].scrollIntoView(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.body.scrollTop = this.body.scrollHeight;
|
||||||
|
|
||||||
|
dactyl.focus(this.window);
|
||||||
|
this.updateMorePrompt();
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
events.listen(window, this, "windowEvents");
|
||||||
|
|
||||||
let fontSize = util.computedStyle(document.documentElement).fontSize;
|
let fontSize = util.computedStyle(document.documentElement).fontSize;
|
||||||
styles.system.add("font-size", "dactyl://content/buffer.xhtml",
|
styles.system.add("font-size", "dactyl://content/buffer.xhtml",
|
||||||
@@ -112,7 +135,7 @@ var MOW = Module("mow", {
|
|||||||
|
|
||||||
// FIXME: need to make sure an open MOW is closed when commands
|
// FIXME: need to make sure an open MOW is closed when commands
|
||||||
// that don't generate output are executed
|
// that don't generate output are executed
|
||||||
if (this.widgets.mowContainer.collapsed) {
|
if (!this.visible) {
|
||||||
this.body.scrollTop = 0;
|
this.body.scrollTop = 0;
|
||||||
body.textContent = "";
|
body.textContent = "";
|
||||||
}
|
}
|
||||||
@@ -123,18 +146,9 @@ var MOW = Module("mow", {
|
|||||||
if (!silent)
|
if (!silent)
|
||||||
dactyl.triggerObserver("echoMultiline", data, highlightGroup, output);
|
dactyl.triggerObserver("echoMultiline", data, highlightGroup, output);
|
||||||
|
|
||||||
this._resize.tell(true);
|
this._timer.tell();
|
||||||
|
if (!this.visible)
|
||||||
if (options["more"] && this.isScrollable(1)) {
|
this._timer.flush();
|
||||||
// start the last executed command's output at the top of the screen
|
|
||||||
let elements = this.document.getElementsByClassName("ex-command-output");
|
|
||||||
elements[elements.length - 1].scrollIntoView(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.body.scrollTop = this.body.scrollHeight;
|
|
||||||
|
|
||||||
dactyl.focus(this.window);
|
|
||||||
this.updateMorePrompt();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
@@ -172,6 +186,12 @@ var MOW = Module("mow", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
windowEvents: {
|
||||||
|
resize: function onResize(event) {
|
||||||
|
this._resize.tell();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
contextEvents: {
|
contextEvents: {
|
||||||
popupshowing: function (event) {
|
popupshowing: function (event) {
|
||||||
let menu = commandline.widgets.contextMenu;
|
let menu = commandline.widgets.contextMenu;
|
||||||
@@ -208,14 +228,14 @@ var MOW = Module("mow", {
|
|||||||
* already so.
|
* already so.
|
||||||
*/
|
*/
|
||||||
resize: function updateOutputHeight(open, extra) {
|
resize: function updateOutputHeight(open, extra) {
|
||||||
if (!open && this.widgets.mowContainer.collapsed)
|
if (!(open || this.visible))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let doc = this.widget.contentDocument;
|
let doc = this.widget.contentDocument;
|
||||||
|
|
||||||
let availableHeight = config.outputHeight;
|
let availableHeight = config.outputHeight;
|
||||||
if (!this.widgets.mowContainer.collapsed)
|
if (this.visible)
|
||||||
availableHeight += parseFloat(this.widgets.mowContainer.height);
|
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";
|
||||||
@@ -225,6 +245,7 @@ var MOW = Module("mow", {
|
|||||||
0);
|
0);
|
||||||
|
|
||||||
doc.body.style.minWidth = "";
|
doc.body.style.minWidth = "";
|
||||||
|
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -243,7 +264,7 @@ var MOW = Module("mow", {
|
|||||||
* and what they do.
|
* and what they do.
|
||||||
*/
|
*/
|
||||||
updateMorePrompt: function updateMorePrompt(force, showHelp) {
|
updateMorePrompt: function updateMorePrompt(force, showHelp) {
|
||||||
if (this.widgets.mowContainer.collapsed)
|
if (!this.visible)
|
||||||
return this.widgets.message = null;
|
return this.widgets.message = null;
|
||||||
let elem = this.widget.contentDocument.documentElement;
|
let elem = this.widget.contentDocument.documentElement;
|
||||||
|
|
||||||
@@ -256,6 +277,7 @@ var MOW = Module("mow", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
visible: Modes.boundProperty({
|
visible: Modes.boundProperty({
|
||||||
|
get: function get_mowVisible() !this.widgets.mowContainer.collapsed,
|
||||||
set: function set_mowVisible(value) {
|
set: function set_mowVisible(value) {
|
||||||
this.widgets.mowContainer.collapsed = !value;
|
this.widgets.mowContainer.collapsed = !value;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user