1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-03 15:54:11 +01:00

Merge key-processing.

This commit is contained in:
Kris Maglione
2011-01-29 02:53:32 -05:00
26 changed files with 1180 additions and 1038 deletions

View File

@@ -115,9 +115,8 @@ var Bookmarks = Module("bookmarks", {
if (charset != null && charset !== "UTF-8")
options["-charset"] = charset;
commandline.open(":",
commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword ",
modes.EX);
CommandExMode().open(
commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword ");
},
/**
@@ -213,7 +212,7 @@ var Bookmarks = Module("bookmarks", {
return iter(services.browserSearch.getVisibleEngines({})).map(function ([, engine]) {
let alias = engine.alias;
if (!alias || !/^[a-z-]+$/.test(alias))
alias = engine.name.replace(/[a-z_-]+/i, "-").replace(/^-|-$/, "").toLowerCase();
alias = engine.name.replace(/[^a-z_-]+/gi, "-").replace(/^-|-$/, "").toLowerCase();
if (!alias)
alias = "search"; // for search engines which we can't find a suitable alias
@@ -249,7 +248,7 @@ var Bookmarks = Module("bookmarks", {
if (engine && engine.supportsResponseType(responseType))
var queryURI = engine.getSubmission(query, responseType).uri.spec;
if (!queryURI)
return [];
return (callback || util.identity)([]);
function process(resp) {
let results = [];
@@ -582,9 +581,8 @@ var Bookmarks = Module("bookmarks", {
options["-charset"] = content.document.characterSet;
}
commandline.open(":",
commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] }),
modes.EX);
CommandExMode().open(
commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] }));
});
mappings.add(myModes, ["A"],

View File

@@ -65,33 +65,33 @@ var Browser = Module("browser", {
mappings: function () {
mappings.add([modes.NORMAL],
["y"], "Yank current location to the clipboard",
["y", "<yank-location>"], "Yank current location to the clipboard",
function () { dactyl.clipboardWrite(buffer.uri.spec, true); });
// opening websites
mappings.add([modes.NORMAL],
["o"], "Open one or more URLs",
function () { commandline.open(":", "open ", modes.EX); });
function () { CommandExMode().open("open "); });
mappings.add([modes.NORMAL], ["O"],
"Open one or more URLs, based on current location",
function () { commandline.open(":", "open " + buffer.uri.spec, modes.EX); });
function () { CommandExMode().open("open " + buffer.uri.spec); });
mappings.add([modes.NORMAL], ["t"],
"Open one or more URLs in a new tab",
function () { commandline.open(":", "tabopen ", modes.EX); });
function () { CommandExMode().open("tabopen "); });
mappings.add([modes.NORMAL], ["T"],
"Open one or more URLs in a new tab, based on current location",
function () { commandline.open(":", "tabopen " + buffer.uri.spec, modes.EX); });
function () { CommandExMode().open("tabopen " + buffer.uri.spec); });
mappings.add([modes.NORMAL], ["w"],
"Open one or more URLs in a new window",
function () { commandline.open(":", "winopen ", modes.EX); });
function () { CommandExMode().open("winopen "); });
mappings.add([modes.NORMAL], ["W"],
"Open one or more URLs in a new window, based on current location",
function () { commandline.open(":", "winopen " + buffer.uri.spec, modes.EX); });
function () { CommandExMode().open("winopen " + buffer.uri.spec); });
mappings.add([modes.NORMAL],
["<C-a>"], "Increment last number in URL",

View File

@@ -766,25 +766,25 @@ var Buffer = Module("buffer", {
try {
window.urlSecurityCheck(uri.spec, doc.nodePrincipal);
commandline.input("Save link: ", function (path) {
let file = io.File(path);
if (file.exists() && file.isDirectory())
file.append(buffer.getDefaultNames(elem)[0][0]);
io.CommandFileMode("Save link: ", {
onSubmit: function (path) {
let file = io.File(path);
if (file.exists() && file.isDirectory())
file.append(buffer.getDefaultNames(elem)[0][0]);
try {
if (!file.exists())
file.create(File.NORMAL_FILE_TYPE, octal(644));
}
catch (e) {
util.assert(false, "Invalid destination: " + e.name);
}
try {
if (!file.exists())
file.create(File.NORMAL_FILE_TYPE, octal(644));
}
catch (e) {
util.assert(false, "Invalid destination: " + e.name);
}
buffer.saveURI(uri, file);
}, {
autocomplete: true,
completer: function (context) completion.savePage(context, elem),
history: "file"
});
buffer.saveURI(uri, file);
},
completer: function (context) completion.savePage(context, elem)
}).open();
}
catch (e) {
dactyl.echoerr(e);
@@ -1360,17 +1360,15 @@ var Buffer = Module("buffer", {
},
openUploadPrompt: function openUploadPrompt(elem) {
commandline.input("Upload file: ", function (path) {
let file = io.File(path);
dactyl.assert(file.exists());
io.CommandFileMode("Upload file: ", {
onSubmit: function (path) {
let file = io.File(path);
dactyl.assert(file.exists());
elem.value = file.path;
events.dispatch(elem, events.create(elem.ownerDocument, "change", {}));
}, {
completer: function (context) completion.file(context),
default: elem.value,
history: "file"
});
elem.value = file.path;
events.dispatch(elem, events.create(elem.ownerDocument, "change", {}));
}
}).open(elem.value);
}
}, {
commands: function () {
@@ -1422,7 +1420,7 @@ var Buffer = Module("buffer", {
let arg = args[0];
let opt = options.get("pageinfo");
dactyl.assert(opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg);
dactyl.assert(!arg || opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg);
buffer.showPageInfo(true, arg);
},
{
@@ -1530,7 +1528,8 @@ var Buffer = Module("buffer", {
if (/^>>/.test(context.filter))
context.advance(/^>>\s*/.exec(context.filter)[0].length);
return completion.savePage(context, content.document);
completion.savePage(context, content.document);
context.fork("file", 0, completion, "file");
},
literal: 0
});
@@ -1642,7 +1641,6 @@ var Buffer = Module("buffer", {
this, function (context) {
context.completions = buffer.getDefaultNames(node);
});
return context.fork("files", 0, completion, "file");
};
},
events: function () {
@@ -1653,7 +1651,7 @@ var Buffer = Module("buffer", {
mappings: function () {
var myModes = config.browserModes;
mappings.add(myModes, ["."],
mappings.add(myModes, [".", "<repeat-key>"],
"Repeat the last key event",
function (args) {
if (mappings.repeat) {
@@ -1672,31 +1670,31 @@ var Buffer = Module("buffer", {
function () { ex.stop(); });
// scrolling
mappings.add(myModes, ["j", "<Down>", "<C-e>"],
mappings.add(myModes, ["j", "<Down>", "<C-e>", "<scroll-down-line>"],
"Scroll document down",
function (args) { buffer.scrollVertical("lines", Math.max(args.count, 1)); },
{ count: true });
mappings.add(myModes, ["k", "<Up>", "<C-y>"],
mappings.add(myModes, ["k", "<Up>", "<C-y>", "<scroll-up-line>"],
"Scroll document up",
function (args) { buffer.scrollVertical("lines", -Math.max(args.count, 1)); },
{ count: true });
mappings.add(myModes, dactyl.has("mail") ? ["h"] : ["h", "<Left>"],
mappings.add(myModes, dactyl.has("mail") ? ["h", "<scroll-left-column>"] : ["h", "<Left>", "<scroll-left-column>"],
"Scroll document to the left",
function (args) { buffer.scrollHorizontal("columns", -Math.max(args.count, 1)); },
{ count: true });
mappings.add(myModes, dactyl.has("mail") ? ["l"] : ["l", "<Right>"],
mappings.add(myModes, dactyl.has("mail") ? ["l", "<scroll-right-column>"] : ["l", "<Right>", "<scroll-right-column>"],
"Scroll document to the right",
function (args) { buffer.scrollHorizontal("columns", Math.max(args.count, 1)); },
{ count: true });
mappings.add(myModes, ["0", "^"],
mappings.add(myModes, ["0", "^", "<scroll-begin>"],
"Scroll to the absolute left of the document",
function () { buffer.scrollToPercent(0, null); });
mappings.add(myModes, ["$"],
mappings.add(myModes, ["$", "<scroll-end>"],
"Scroll to the absolute right of the document",
function () { buffer.scrollToPercent(100, null); });
@@ -1710,7 +1708,7 @@ var Buffer = Module("buffer", {
function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 100); },
{ count: true });
mappings.add(myModes, ["%"],
mappings.add(myModes, ["%", "<scroll-percent>"],
"Scroll to {count} percent of the document",
function (args) {
dactyl.assert(args.count > 0 && args.count <= 100);
@@ -1718,59 +1716,59 @@ var Buffer = Module("buffer", {
},
{ count: true });
mappings.add(myModes, ["<C-d>"],
mappings.add(myModes, ["<C-d>", "<scroll-down>"],
"Scroll window downwards in the buffer",
function (args) { buffer._scrollByScrollSize(args.count, true); },
{ count: true });
mappings.add(myModes, ["<C-u>"],
mappings.add(myModes, ["<C-u>", "<scroll-up>"],
"Scroll window upwards in the buffer",
function (args) { buffer._scrollByScrollSize(args.count, false); },
{ count: true });
mappings.add(myModes, ["<C-b>", "<PageUp>", "<S-Space>"],
mappings.add(myModes, ["<C-b>", "<PageUp>", "<S-Space>", "<scroll-page-up>"],
"Scroll up a full page",
function (args) { buffer.scrollVertical("pages", -Math.max(args.count, 1)); },
{ count: true });
mappings.add(myModes, ["<C-f>", "<PageDown>", "<Space>"],
mappings.add(myModes, ["<C-f>", "<PageDown>", "<Space>", "<scroll-page-down>"],
"Scroll down a full page",
function (args) { buffer.scrollVertical("pages", Math.max(args.count, 1)); },
{ count: true });
mappings.add(myModes, ["]f"],
mappings.add(myModes, ["]f", "<previous-frame>"],
"Focus next frame",
function (args) { buffer.shiftFrameFocus(Math.max(args.count, 1)); },
{ count: true });
mappings.add(myModes, ["[f"],
mappings.add(myModes, ["[f", "<next-frame>"],
"Focus previous frame",
function (args) { buffer.shiftFrameFocus(-Math.max(args.count, 1)); },
{ count: true });
mappings.add(myModes, ["]]"],
mappings.add(myModes, ["]]", "<next-page>"],
"Follow the link labeled 'next' or '>' if it exists",
function (args) {
buffer.findLink("next", options["nextpattern"], (args.count || 1) - 1, true);
},
{ count: true });
mappings.add(myModes, ["[["],
mappings.add(myModes, ["[[", "<previous-page>"],
"Follow the link labeled 'prev', 'previous' or '<' if it exists",
function (args) {
buffer.findLink("previous", options["previouspattern"], (args.count || 1) - 1, true);
},
{ count: true });
mappings.add(myModes, ["gf"],
mappings.add(myModes, ["gf", "<view-source>"],
"Toggle between rendered and source view",
function () { buffer.viewSource(null, false); });
mappings.add(myModes, ["gF"],
mappings.add(myModes, ["gF", "<view-source-externally>"],
"View source with an external editor",
function () { buffer.viewSource(null, true); });
mappings.add(myModes, ["gi"],
mappings.add(myModes, ["gi", "<focus-input>"],
"Focus last used input field",
function (args) {
let elem = buffer.lastInputField;
@@ -1810,7 +1808,7 @@ var Buffer = Module("buffer", {
dactyl.open(url, { from: "paste", where: dactyl.NEW_TAB, background: true });
});
mappings.add(myModes, ["p", "<MiddleMouse>"],
mappings.add(myModes, ["p", "<MiddleMouse>", "<open-clipboard-url>"],
"Open (put) a URL based on the current clipboard contents in the current buffer",
function () {
let url = dactyl.clipboardRead();
@@ -1818,7 +1816,7 @@ var Buffer = Module("buffer", {
dactyl.open(url);
});
mappings.add(myModes, ["P"],
mappings.add(myModes, ["P", "<tab-open-clipboard-url>"],
"Open (put) a URL based on the current clipboard contents in a new buffer",
function () {
let url = dactyl.clipboardRead();
@@ -1827,16 +1825,16 @@ var Buffer = Module("buffer", {
});
// reloading
mappings.add(myModes, ["r"],
mappings.add(myModes, ["r", "<reload>"],
"Reload the current web page",
function () { tabs.reload(tabs.getTab(), false); });
mappings.add(myModes, ["R"],
mappings.add(myModes, ["R", "<full-reload>"],
"Reload while skipping the cache",
function () { tabs.reload(tabs.getTab(), true); });
// yanking
mappings.add(myModes, ["Y"],
mappings.add(myModes, ["Y", "<yank-word>"],
"Copy selected text or current word",
function () {
let sel = buffer.getCurrentWord();
@@ -1845,62 +1843,62 @@ var Buffer = Module("buffer", {
});
// zooming
mappings.add(myModes, ["zi", "+"],
mappings.add(myModes, ["zi", "+", "<text-zoom-in>"],
"Enlarge text zoom of current web page",
function (args) { buffer.zoomIn(Math.max(args.count, 1), false); },
{ count: true });
mappings.add(myModes, ["zm"],
mappings.add(myModes, ["zm", "<text-zoom-more>"],
"Enlarge text zoom of current web page by a larger amount",
function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, false); },
{ count: true });
mappings.add(myModes, ["zo", "-"],
mappings.add(myModes, ["zo", "-", "<text-zoom-out>"],
"Reduce text zoom of current web page",
function (args) { buffer.zoomOut(Math.max(args.count, 1), false); },
{ count: true });
mappings.add(myModes, ["zr"],
mappings.add(myModes, ["zr", "<text-zoom-reduce>"],
"Reduce text zoom of current web page by a larger amount",
function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, false); },
{ count: true });
mappings.add(myModes, ["zz"],
mappings.add(myModes, ["zz", "<text-zoom>"],
"Set text zoom value of current web page",
function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, false); },
{ count: true });
mappings.add(myModes, ["ZI", "zI"],
mappings.add(myModes, ["ZI", "zI", "<full-zoom-in>"],
"Enlarge full zoom of current web page",
function (args) { buffer.zoomIn(Math.max(args.count, 1), true); },
{ count: true });
mappings.add(myModes, ["ZM", "zM"],
mappings.add(myModes, ["ZM", "zM", "<full-zoom-more>"],
"Enlarge full zoom of current web page by a larger amount",
function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, true); },
{ count: true });
mappings.add(myModes, ["ZO", "zO"],
mappings.add(myModes, ["ZO", "zO", "<full-zoom-out>"],
"Reduce full zoom of current web page",
function (args) { buffer.zoomOut(Math.max(args.count, 1), true); },
{ count: true });
mappings.add(myModes, ["ZR", "zR"],
mappings.add(myModes, ["ZR", "zR", "<full-zoom-reduce>"],
"Reduce full zoom of current web page by a larger amount",
function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, true); },
{ count: true });
mappings.add(myModes, ["zZ"],
mappings.add(myModes, ["zZ", "<full-zoom>"],
"Set full zoom value of current web page",
function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, true); },
{ count: true });
// page info
mappings.add(myModes, ["<C-g>"],
mappings.add(myModes, ["<C-g>", "<page-info>"],
"Print the current file name",
function () { buffer.showPageInfo(false); });
mappings.add(myModes, ["g<C-g>"],
mappings.add(myModes, ["g<C-g>", "<more-page-info>"],
"Print file information",
function () { buffer.showPageInfo(true); });
},

File diff suppressed because it is too large Load Diff

View File

@@ -1334,6 +1334,7 @@ var Commands = Module("commands", {
bang: args["-bang"],
count: args["-count"],
completer: completerFunc,
literal: args["-count"] == "*" ? 0 : null,
persist: !args["-nopersist"],
replacementText: args.literalArg,
sourcing: io.sourcing && update({}, io.sourcing)

View File

@@ -40,11 +40,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
this.commands["dactyl.restart"] = function (event) {
dactyl.restart();
};
styles.registerSheet("resource://dactyl-skin/dactyl.css");
},
cleanup: function () {
delete window.dactyl;
delete window.liberator;
styles.unregisterSheet("resource://dactyl-skin/dactyl.css");
},
destroy: function () {
@@ -1333,6 +1337,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
*/
trapErrors: function trapErrors(func, self) {
try {
if (isString(func))
func = self[func];
return func.apply(self || this, Array.slice(arguments, 2));
}
catch (e) {

View File

@@ -11,15 +11,17 @@
var ProcessorStack = Class("ProcessorStack", {
init: function (mode, hives, keyModes) {
this.main = mode.main;
this._actions = [];
this.actions = [];
this.buffer = "";
this.events = [];
this.processors = keyModes.map(function (m) hives.map(function (h) KeyProcessor(m, h)))
.flatten().array;
this.ownsBuffer = !this.processors.some(function (p) p.main.ownsBuffer);
for (let [i, input] in Iterator(this.processors)) {
let params = input.main == mode.main ? mode.params : input.main.params;
let params = input.main.params;
if (params.preExecute)
input.preExecute = params.preExecute;
if (params.postExecute)
@@ -31,9 +33,71 @@ var ProcessorStack = Class("ProcessorStack", {
}
},
notify: function () {
this.execute(Events.KILL, true);
},
execute: function execute(result, force) {
if (force && this.actions.length)
this.processors.length = 0;
if (this.ownsBuffer)
statusline.updateInputBuffer(this.processors.length ? this.buffer : "");
if (this.processors.length) {
result = Events.KILL;
if (this.actions.length && options["timeout"])
this.timer = services.Timer(this, options["timeoutlen"], services.Timer.TYPE_ONE_SHOT);
}
else if (this.actions.length) {
if (this._actions.length == 0) {
dactyl.beep();
events.feedingKeys = false;
}
for (var res = this.actions[0]; callable(res);)
res = res();
result = res === Events.PASS ? Events.PASS : Events.KILL;
}
else if (result !== Events.KILL && !this.actions.length &&
(this.events.length > 1 ||
this.processors.some(function (p) !p.main.passUnknown))) {
result = Events.KILL;
dactyl.beep();
events.feedingKeys = false;
}
else if (result === undefined)
result = Events.PASS;
if (result !== Events.PASS)
Events.kill(this.events[this.events.length - 1]);
if (result === Events.PASS || result === Events.ABORT)
this.events.filter(function (e) e.getPreventDefault())
.forEach(function (event, i) {
let elem = event.originalTarget;
if (event.originalTarget) {
let doc = elem.ownerDocument || elem.document || elem;
let evt = events.create(doc, event.type, event);
events.dispatch(elem, evt, { skipmap: true, isMacro: true, isReplay: true });
}
else if (i > 0)
events.events.keypress.call(events, event);
});
if (force && this.processors.length === 0)
events.processor = null;
return this.processors.length == 0;
},
process: function process(event) {
function dbg() {}
if (this.timer)
this.timer.cancel();
let key = events.toString(event);
this.events.push(event);
@@ -70,9 +134,7 @@ var ProcessorStack = Class("ProcessorStack", {
dbg("ACTIONS: " + actions.length + " " + this.actions.length);
dbg("PROCESSORS:", processors);
if (!processors.some(function (p) p.main.ownsBuffer))
statusline.updateInputBuffer(processors.length ? this.buffer : "");
this._actions = actions;
this.actions = actions.concat(this.actions);
if (result === Events.KILL)
@@ -87,41 +149,7 @@ var ProcessorStack = Class("ProcessorStack", {
this.processors = processors;
if (processors.length)
result = Events.KILL;
else if (this.actions.length) {
if (actions.length == 0)
dactyl.beep();
if (modes.replaying && !events.waitForPageLoad())
result = Events.KILL;
else {
for (var res = this.actions[0]; callable(res);)
res = res();
result = res === Events.PASS ? Events.PASS : Events.KILL;
}
}
else if (result !== Events.KILL && processors.some(function (p) !p.main.passUnknown)) {
result = Events.KILL;
dactyl.beep();
}
else if (result === undefined)
result = Events.PASS;
if (result !== Events.PASS)
Events.kill(event);
if (result === Events.PASS || result === Events.ABORT)
this.events.filter(function (e) e.getPreventDefault())
.forEach(function (event, i) {
if (event.originalTarget) {
let evt = events.create(event.originalTarget.ownerDocument, event.type, event);
events.dispatch(event.originalTarget, evt, { skipmap: true, isMacro: true });
}
else if (i > 0)
events.events.keypress.call(events, event);
});
return this.processors.length == 0;
return this.execute(result, options["timeout"] && options["timeoutlen"] === 0)
}
});
@@ -157,12 +185,13 @@ var KeyProcessor = Class("KeyProcessor", {
return this.onKeyPress(event);
},
execute: function execute(map)
let (self = this, args = arguments)
execute: function execute(map, args)
let (self = this)
function execute() {
if (self.preExecute)
self.preExecute.apply(self, args);
let res = map.execute.apply(map, Array.slice(args, 1));
let res = map.execute.call(map, update({ self: self.main.params.mappingSelf || self.main.mappingSelf || map },
args))
if (self.postExecute)
self.postExecute.apply(self, args);
return res;
@@ -487,6 +516,7 @@ var Events = Module("events", {
util.threadYield(1, true);
for (let [, evt_obj] in Iterator(events.fromString(keys))) {
let now = Date.now();
for (let type in values(["keydown", "keyup", "keypress"])) {
let evt = update({}, evt_obj, { type: type });
@@ -587,9 +617,14 @@ var Events = Module("events", {
* of x.
*
* @param {string} keys Messy form.
* @param {boolean} unknownOk Whether unknown keys are passed
* through rather than being converted to <lt>keyname>.
* @default false
* @returns {string} Canonical form.
*/
canonicalKeys: function (keys, unknownOk) {
if (arguments.length === 1)
unknownOk = true;
return events.fromString(keys, unknownOk).map(events.closure.toString).join("");
},
@@ -644,11 +679,17 @@ var Events = Module("events", {
* <S-@> where @ is a non-case-changeable, non-space character.
*
* @param {string} keys The string to parse.
* @param {boolean} unknownOk Whether unknown keys are passed
* through rather than being converted to <lt>keyname>.
* @default false
* @returns {Array[Object]}
*/
fromString: function (input, unknownOk) {
let out = [];
if (arguments.length === 1)
unknownOk = true;
let out = [];
let re = RegExp("<.*?>?>|[^<]|<(?!.*>)", "g");
let match;
while ((match = re.exec(input))) {
@@ -855,10 +896,7 @@ var Events = Module("events", {
isContentNode: function isContentNode(node) {
let win = (node.ownerDocument || node).defaultView || node;
for (; win; win = win.parent != win && win.parent)
if (win == content)
return true;
return false;
return XPCNativeWrapper(win).top == content;
},
/**
@@ -867,39 +905,20 @@ var Events = Module("events", {
*
* @returns {boolean}
*/
waitForPageLoad: function () {
waitForPageLoad: function (time) {
util.threadYield(true); // clear queue
if (buffer.loaded == 1)
if (buffer.loaded)
return true;
const maxWaitTime = 25;
let start = Date.now();
let end = start + (maxWaitTime * 1000); // maximum time to wait - TODO: add option
let now;
while (now = Date.now(), now < end) {
util.threadYield();
dactyl.echo("Waiting for page to load...", commandline.DISALLOW_MULTILINE);
if (!events.feedingKeys)
return false;
const maxWaitTime = (time || 25);
util.waitFor(function () !events.feedingKeys || buffer.loaded, this, maxWaitTime * 1000, true);
if (buffer.loaded > 0) {
util.sleep(250);
break;
}
else
dactyl.echo("Waiting for page to load...", commandline.DISALLOW_MULTILINE);
}
commandline.clear();
// TODO: allow macros to be continued when page does not fully load with an option
if (!buffer.loaded)
dactyl.echoerr("Page did not load completely in " + maxWaitTime + " seconds. Macro stopped.");
// sometimes the input widget had focus when replaying a macro
// maybe this call should be moved somewhere else?
// dactyl.focusContent(true);
return buffer.loaded;
},
@@ -992,7 +1011,7 @@ var Events = Module("events", {
*/
input: function onInput(event) {
if (event.originalTarget.dactylKeyPress)
if ("dactylKeyPress" in event.originalTarget)
delete event.originalTarget.dactylKeyPress;
},
@@ -1017,18 +1036,17 @@ var Events = Module("events", {
let duringFeed = this.duringFeed || [];
this.duringFeed = [];
try {
if (this.feedingEvent && [!(k in event) || event[k] === v for ([k, v] in Iterator(this.feedingEvent))].every(util.identity)) {
if (this.feedingEvent)
for (let [k, v] in Iterator(this.feedingEvent))
if (!(k in event))
event[k] = v;
this.feedingEvent = null;
}
this.feedingEvent = null;
let key = events.toString(event);
if (!key)
return null;
if (modes.recording && (!this._input || !mappings.user.hasMap(modes.main, this._input.buffer + key)))
if (modes.recording && !event.isReplay)
events._macroKeys.push(key);
// feedingKeys needs to be separate from interrupted so
@@ -1036,8 +1054,6 @@ var Events = Module("events", {
// interrupting whatever it's started and a real <C-c>
// interrupting our playback.
if (events.feedingKeys && !event.isMacro) {
if (!event.originalTarget)
util.dumpStack();
if (key == "<C-c>") {
events.feedingKeys = false;
if (modes.replaying) {
@@ -1087,7 +1103,8 @@ var Events = Module("events", {
let hives = mappings.hives.slice(event.noremap ? -1 : 0);
let keyModes = array([mode.params.keyModes, mode.main, mode.main.allBases]).flatten().compact();
let main = { __proto__: mode.main, params: mode.params };
let keyModes = array([mode.params.keyModes, main, mode.main.allBases]).flatten().compact();
this.processor = ProcessorStack(mode, hives, keyModes);
}
@@ -1169,10 +1186,6 @@ var Events = Module("events", {
// access to the real focus target
// Huh? --djk
onFocusChange: function onFocusChange(event) {
// command line has its own focus change handler
if (modes.main == modes.COMMAND_LINE)
return;
function hasHTMLDocument(win) win && win.document && win.document instanceof HTMLDocument
let win = window.document.commandDispatcher.focusedWindow;
@@ -1193,22 +1206,13 @@ var Events = Module("events", {
return;
}
if (Events.isInputElement(elem)) {
if (!(modes.main & (modes.INSERT | modes.TEXT_EDIT | modes.VISUAL)))
modes.push(modes.INSERT);
if (hasHTMLDocument(win))
buffer.lastInputField = elem;
return;
}
if (elem instanceof HTMLTextAreaElement || (elem && util.computedStyle(elem).MozUserModify == "read-write")
|| elem == null && win && Editor.getEditor(win)) {
if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart)
modes.pop();
if (!(modes.main & (modes.INSERT | modes.TEXT_EDIT | modes.VISUAL)))
if (!modes.main.input)
if (options["insertmode"])
modes.push(modes.INSERT);
else {
@@ -1222,6 +1226,15 @@ var Events = Module("events", {
return;
}
if (Events.isInputElement(elem)) {
if (!modes.main.input)
modes.push(modes.INSERT);
if (hasHTMLDocument(win))
buffer.lastInputField = elem;
return;
}
if (config.focusChange) {
config.focusChange(win);
return;
@@ -1314,39 +1327,59 @@ var Events = Module("events", {
};
},
mappings: function () {
mappings.add(modes.all,
["<C-z>"], "Temporarily ignore all " + config.appName + " key bindings",
mappings.add(modes.MAIN,
["<C-z>", "<pass-all-keys>"], "Temporarily ignore all " + config.appName + " key bindings",
function () { modes.push(modes.PASS_THROUGH); });
mappings.add(modes.all,
["<C-v>"], "Pass through next key",
mappings.add(modes.MAIN,
["<C-v>", "<pass-next-key>"], "Pass through next key",
function () {
if (modes.main == modes.QUOTE)
return Events.PASS;
modes.push(modes.QUOTE);
});
mappings.add(modes.all,
mappings.add(modes.BASE,
["<Nop>"], "Do nothing",
function () {});
// macros
mappings.add([modes.NORMAL, modes.TEXT_AREA, modes.PLAYER].filter(util.identity),
["q"], "Record a key sequence into a macro",
mappings.add([modes.COMMAND],
["q", "<record-macro>"], "Record a key sequence into a macro",
function ({ arg }) {
events._macroKeys.pop();
events[modes.recording ? "finishRecording" : "startRecording"](arg);
},
{ get arg() !modes.recording });
mappings.add([modes.NORMAL, modes.TEXT_AREA, modes.PLAYER].filter(util.identity),
["@"], "Play a macro",
mappings.add([modes.COMMAND],
["@", "<play-macro>"], "Play a macro",
function ({ arg, count }) {
count = Math.max(count, 1);
while (count-- && events.playMacro(arg))
;
},
{ arg: true, count: true });
mappings.add([modes.COMMAND],
["<A-m>s", "<sleep>"], "Sleep for {count} milliseconds before continuing macro playback",
function ({ command, count }) {
let now = Date.now();
dactyl.assert(count, "Count required for " + command);
if (events.feedingKeys)
util.sleep(count);
},
{ count: true });
mappings.add([modes.COMMAND],
["<A-m>l", "<wait-for-page-load>"], "Wait for the current page to finish loading before continuing macro playback",
function ({ count }) {
if (events.feedingKeys && !events.waitForPageLoad(count)) {
util.interrupted = true;
throw Error("Interrupted");
}
},
{ count: true });
},
options: function () {
options.add(["passkeys", "pk"],
@@ -1367,9 +1400,18 @@ var Events = Module("events", {
return values;
}
});
options.add(["strictfocus", "sf"],
"Prevent scripts from focusing input elements without user intervention",
"boolean", true);
options.add(["timeout", "tmo"],
"Whether to execute a shorter key command after a timeout when a longer command exists",
"boolean", true);
options.add(["timeoutlen", "tmol"],
"Maximum time (milliseconds) to wait for a longer key command when a shorter one exists",
"number", 1000);
},
sanitizer: function () {
sanitizer.addItem("macros", {

View File

@@ -9,16 +9,18 @@
/** @scope modules */
/** @instance hints */
var HintSession = Class("HintSession", {
var HintSession = Class("HintSession", CommandMode, {
init: function init(mode, opts) {
init.supercall(this);
opts = opts || {};
// Hack.
if (!opts.window && modes.main == modes.OUTPUT_MULTILINE)
opts.window = commandline.widgets.multilineOutput.contentWindow;
this.mode = hints.modes[mode];
dactyl.assert(this.mode);
this.hintMode = hints.modes[mode];
dactyl.assert(this.hintMode);
this.activeTimeout = null; // needed for hinttimeout > 0
this.continue = Boolean(opts.continue);
@@ -31,8 +33,7 @@ var HintSession = Class("HintSession", {
this.usedTabKey = false;
this.validHints = []; // store the indices of the "hints" array with valid elements
commandline.input(UTF8(this.mode.prompt) + ": ", null, this.closure);
modes.extended = modes.HINTS;
this.open();
this.top = opts.window || content;
this.top.addEventListener("resize", hints.resizeTimer.closure.tell, true);
@@ -51,7 +52,22 @@ var HintSession = Class("HintSession", {
this.checkUnique();
},
get extended() modes.HINTS,
get mode() modes.HINTS,
get prompt() ["Question", UTF8(this.hintMode.prompt) + ": "],
leave: function leave(stack) {
leave.superapply(this, arguments);
if (!stack.push) {
if (hints.hintSession == this)
hints.hintSession = null;
if (this.top)
this.top.removeEventListener("resize", hints.resizeTimer.closure.tell, true);
this.removeHints(0);
}
},
checkUnique: function _checkUnique() {
if (this.hintNumber == 0)
@@ -236,7 +252,7 @@ var HintSession = Class("HintSession", {
let baseNodeAbsolute = util.xmlToDom(<span highlight="Hint" style="display: none"/>, doc);
let mode = this.mode;
let mode = this.hintMode;
let res = util.evaluateXPath(mode.xpath, doc, true);
let start = this.pageHints.length;
@@ -289,18 +305,6 @@ var HintSession = Class("HintSession", {
return true;
},
leave: function leave(stack) {
if (!stack.push) {
if (hints.hintSession == this)
hints.hintSession = null;
this.continue = false;
if (this.top)
this.top.removeEventListener("resize", hints.resizeTimer.closure.tell, true);
this.removeHints(0);
}
},
/**
* Handle user input.
*
@@ -429,7 +433,7 @@ var HintSession = Class("HintSession", {
if ((modes.extended & modes.HINTS) && !this.continue)
modes.pop();
commandline.lastEcho = null; // Hack.
dactyl.trapErrors(this.mode.action, this.mode,
dactyl.trapErrors("action", this.hintMode,
elem, elem.href || elem.src || "",
this.extendedhintCount, top);
if (this.continue && this.top)
@@ -662,6 +666,7 @@ var Hints = Module("hints", {
if (modes.extended & modes.HINTS)
modes.getStack(0).params.onResize();
});
let appContent = document.getElementById("appcontent");
if (appContent)
events.addSessionListener(appContent, "scroll", this.resizeTimer.closure.tell, false);
@@ -681,9 +686,9 @@ var Hints = Module("hints", {
this.addMode("t", "Follow hint in a new tab", function (elem) buffer.followLink(elem, dactyl.NEW_TAB));
this.addMode("b", "Follow hint in a background tab", function (elem) buffer.followLink(elem, dactyl.NEW_BACKGROUND_TAB));
this.addMode("w", "Follow hint in a new window", function (elem) buffer.followLink(elem, dactyl.NEW_WINDOW));
this.addMode("O", "Generate an :open URL prompt", function (elem, loc) commandline.open(":", "open " + loc, modes.EX));
this.addMode("T", "Generate a :tabopen URL prompt", function (elem, loc) commandline.open(":", "tabopen " + loc, modes.EX));
this.addMode("W", "Generate a :winopen URL prompt", function (elem, loc) commandline.open(":", "winopen " + loc, modes.EX));
this.addMode("O", "Generate an :open URL prompt", function (elem, loc) CommandExMode.open("open " + loc));
this.addMode("T", "Generate a :tabopen URL prompt", function (elem, loc) CommandExMode.open("tabopen " + loc));
this.addMode("W", "Generate a :winopen URL prompt", function (elem, loc) CommandExMode.open("winopen " + loc));
this.addMode("a", "Add a bookmark", function (elem) bookmarks.addSearchKeyword(elem));
this.addMode("S", "Add a search keyword", function (elem) bookmarks.addSearchKeyword(elem));
this.addMode("v", "View hint source", function (elem, loc) buffer.viewSource(loc, false));
@@ -952,20 +957,19 @@ var Hints = Module("hints", {
open: function open(mode, opts) {
this._extendedhintCount = opts.count;
commandline.input(mode, null, {
commandline.input(["Normal", mode], "", {
completer: function (context) {
context.compare = function () 0;
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints.modes))];
},
onAccept: function (arg) {
onSubmit: function (arg) {
if (arg)
util.timeout(function () {
dactyl.trapErrors(hints.show, hints, arg, opts);
});
hints.show(arg, opts);
},
onChange: function () {
this.accepted = true;
modes.pop();
},
get onCancel() this.onAccept,
onChange: function () { modes.pop(); },
promptHighlight: "Normal"
});
},
@@ -1075,6 +1079,15 @@ var Hints = Module("hints", {
Mode: Struct("name", "prompt", "action", "tags", "filter")
}, {
modes: function () {
modes.addMode("HINTS", {
extended: true,
description: "Active when selecting elements in QuickHint or ExtendedHint mode",
bases: [modes.COMMAND_LINE],
input: true,
ownsBuffer: true
});
},
mappings: function () {
var myModes = config.browserModes.concat(modes.OUTPUT_MULTILINE);
mappings.add(myModes, ["f"],
@@ -1097,25 +1110,23 @@ var Hints = Module("hints", {
mappings.add(modes.HINTS, ["<Return>"],
"Follow the selected hint",
function () { hints.hintSession.update(true); });
function ({ self }) { self.update(true); });
mappings.add(modes.HINTS, ["<Tab>"],
"Focus the next matching hint",
function () { hints.hintSession.tab(false); });
function ({ self }) { self.tab(false); });
mappings.add(modes.HINTS, ["<S-Tab>"],
"Focus the previous matching hint",
function () { hints.hintSession.tab(true); });
function ({ self }) { self.tab(true); });
mappings.add(modes.HINTS, ["<BS>", "<C-h>"],
"Delete the previous character",
function () hints.hintSession.backspace());
function ({ self }) self.backspace());
mappings.add(modes.HINTS, ["<Leader>"],
"Toggle hint filtering",
function () {
hints.hintSession.escapeNumbers = !hints.hintSession.escapeNumbers;
});
function ({ self }) { self.escapeNumbers = !self.escapeNumbers; });
},
options: function () {
const DEFAULT_HINTTAGS =

View File

@@ -113,9 +113,18 @@ var Map = Class("Map", {
if (this.executing)
util.dumpStack("Attempt to execute mapping recursively: " + args.command);
dactyl.assert(!this.executing, "Attempt to execute mapping recursively: " + args.command);
this.executing = true;
let res = dactyl.trapErrors(repeat);
this.executing = false;
try {
this.executing = true;
var res = repeat();
}
catch (e) {
events.feedingKeys = false;
dactyl.reportError(e, true);
}
finally {
this.executing = false;
}
return res;
}
@@ -295,6 +304,8 @@ var Mappings = Module("mappings", {
this.allHives = [this.user, this.builtin];
},
repeat: Modes.boundProperty(),
hives: Class.memoize(function () array(this.allHives.filter(function (h) h.filter(buffer.uri)))),
get userHives() this.allHives.filter(function (h) h !== this.builtin, this),

View File

@@ -119,12 +119,6 @@ var Modes = Module("modes", {
input: true,
ownsFocus: true
});
this.addMode("COMMAND_LINE", {
char: "c",
description: "Active when the command line is focused",
input: true
});
this.addMode("EMBED", {
input: true,
@@ -160,31 +154,9 @@ var Modes = Module("modes", {
input: true
});
// this._extended modes, can include multiple modes, and even main modes
this.addMode("EX", {
extended: true,
description: "Ex command mode, active when the command line is open for Ex commands",
input: true
}, { history: "command" });
this.addMode("HINTS", {
extended: true,
description: "Active when selecting elements in QuickHint or ExtendedHint mode",
count: false,
ownsBuffer: true
});
this.addMode("INPUT_MULTILINE", {
extended: true,
hidden: true,
input: true
});
this.addMode("LINE", {
extended: true, hidden: true
});
this.addMode("PROMPT", {
extended: true,
description: "Active when a prompt is open in the command line",
input: true
});
this.push(this.NORMAL, 0, {
enter: function (stack, prev) {
@@ -214,9 +186,9 @@ var Modes = Module("modes", {
_getModeMessage: function () {
// when recording a macro
let macromode = "";
if (modes.recording)
if (this.recording)
macromode = "recording";
else if (modes.replaying)
else if (this.replaying)
macromode = "replaying";
let val = this._modeMap[this._main].display();
@@ -292,11 +264,11 @@ var Modes = Module("modes", {
delayed: [],
delay: function (callback, self) { this.delayed.push([callback, self]); },
save: function save(id, obj, prop) {
save: function save(id, obj, prop, test) {
if (!(id in this.boundProperties))
for (let elem in array.iterValues(this._modeStack))
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop] };
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop };
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop], test: test };
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop, test: test };
},
// helper function to set both modes in one go
@@ -317,22 +289,26 @@ var Modes = Module("modes", {
}
if (stack && stack.pop && stack.pop.params.leave)
stack.pop.params.leave(stack, this.topOfStack);
dactyl.trapErrors("leave", stack.pop.params,
stack, this.topOfStack);
let push = mainMode != null && !(stack && stack.pop) &&
Modes.StackElement(this._main, this._extended, params, {});
if (push && this.topOfStack) {
if (this.topOfStack.params.leave)
this.topOfStack.params.leave({ push: push }, push);
for (let [id, { obj, prop }] in Iterator(this.boundProperties)) {
dactyl.trapErrors("leave", this.topOfStack.params,
{ push: push }, push);
for (let [id, { obj, prop, test }] in Iterator(this.boundProperties)) {
if (!obj.get())
delete this.boundProperties[id];
else
this.topOfStack.saved[id] = { obj: obj.get(), prop: prop, value: obj.get()[prop] };
this.topOfStack.saved[id] = { obj: obj.get(), prop: prop, value: obj.get()[prop], test: test };
}
}
this.delayed.forEach(function ([fn, self]) fn.call(self));
let delayed = this.delayed;
this.delayed = [];
let prev = stack && stack.pop || this.topOfStack;
@@ -340,12 +316,18 @@ var Modes = Module("modes", {
this._modeStack.push(push);
if (stack && stack.pop)
for (let { obj, prop, value } in values(this.topOfStack.saved))
obj[prop] = value;
for (let { obj, prop, value, test } in values(this.topOfStack.saved))
if (!test || !test(stack, prev))
obj[prop] = value;
this.show();
delayed.forEach(function ([fn, self]) dactyl.trapErrors(fn, self));
if (this.topOfStack.params.enter && prev)
this.topOfStack.params.enter(push ? { push: push } : stack || {},
prev);
dactyl.trapErrors("enter", this.topOfStack.params,
push ? { push: push } : stack || {},
prev);
dactyl.triggerObserver("modeChange", [oldMain, oldExtended], [this._main, this._extended], stack);
this.show();
@@ -439,7 +421,7 @@ var Modes = Module("modes", {
input: false,
passUnknown: false,
get passUnknown() this.input,
get mask() this,
@@ -476,7 +458,7 @@ var Modes = Module("modes", {
return val === undefined ? value : val;
},
set: function (val) {
modes.save(id, this, prop);
modes.save(id, this, prop, desc.test);
if (desc.set)
value = desc.set.call(this, val);
value = !desc.set || value === undefined ? val : value;

355
common/content/mow.js Normal file
View File

@@ -0,0 +1,355 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2011 by Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
var MOW = Module("mow", {
init: function () {
let fontSize = util.computedStyle(document.documentElement).fontSize;
styles.system.add("font-size", "dactyl://content/buffer.xhtml",
"body { font-size: " + fontSize + "; } \
html|html > xul|scrollbar { visibility: collapse !important; }",
true);
XML.ignoreWhitespace = true;
util.overlayWindow(window, {
objects: {
eventTarget: this
},
append: <e4x xmlns={XUL} xmlns:dactyl={NS}>
<window id={document.documentElement.id}>
<popupset>
<menupopup id="dactyl-contextmenu" highlight="Events" events="contextEvents">
<menuitem id="dactyl-context-copylink"
label="Copy Link Location" dactyl:group="link"
oncommand="goDoCommand('cmd_copyLink');"/>
<menuitem id="dactyl-context-copypath"
label="Copy File Path" dactyl:group="link path"
oncommand="dactyl.clipboardWrite(document.popupNode.getAttribute('path'));"/>
<menuitem id="dactyl-context-copy"
label="Copy" dactyl:group="selection"
command="cmd_copy"/>
<menuitem id="dactyl-context-selectall"
label="Select All"
command="cmd_selectAll"/>
</menupopup>
</popupset>
</window>
<vbox id={config.commandContainer}>
<vbox class="dactyl-container" id="dactyl-multiline-output-container" hidden="false" collapsed="true">
<iframe id="dactyl-multiline-output" src="dactyl://content/buffer.xhtml"
flex="1" hidden="false" collapsed="false" contextmenu="dactyl-contextmenu"
highlight="Events" />
</vbox>
</vbox>
</e4x>
});
},
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)),
get widget() this.widgets.multilineOutput,
widgets: Class.memoize(function () commandline.widgets),
body: Class.memoize(function () this.widget.contentDocument.documentElement),
document: Class.memoize(function () this.widget.contentDocument),
window: Class.memoize(function () this.widget.contentWindow),
/**
* Display a multi-line message.
*
* @param {string} data
* @param {string} highlightGroup
*/
echo: function echo(data, highlightGroup, silent) {
let body = this.document.body;
this.widgets.message = null;
if (!commandline.commandVisible)
commandline.hide();
this._startHints = false;
if (modes.main != modes.OUTPUT_MULTILINE) {
modes.push(modes.OUTPUT_MULTILINE, null, {
onKeyPress: this.closure.onKeyPress,
leave: this.closure(function leave(stack) {
if (stack.pop)
for (let message in values(this.messages))
if (message.leave)
message.leave(stack);
})
});
this.messages = [];
}
// If it's already XML, assume it knows what it's doing.
// Otherwise, white space is significant.
// The problem elsewhere is that E4X tends to insert new lines
// after interpolated data.
XML.ignoreWhitespace = XML.prettyPrinting = false;
if (isObject(data)) {
this.lastOutput = null;
var output = util.xmlToDom(<div class="ex-command-output" style="white-space: nowrap" highlight={highlightGroup}/>,
this.document);
data.document = this.document;
output.appendChild(data.message);
this.messages.push(data);
}
else {
let style = isString(data) ? "pre" : "nowrap";
this.lastOutput = <div class="ex-command-output" style={"white-space: " + style} highlight={highlightGroup}>{data}</div>;
var output = util.xmlToDom(this.lastOutput, this.document);
}
// FIXME: need to make sure an open MOW is closed when commands
// that don't generate output are executed
if (this.widgets.mowContainer.collapsed) {
this.body.scrollTop = 0;
while (body.firstChild)
body.removeChild(body.firstChild);
}
body.appendChild(output);
let str = typeof data !== "xml" && data.message || data;
if (!silent)
dactyl.triggerObserver("echoMultiline", data, highlightGroup, output);
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();
},
events: {
click: function onClick(event) {
if (event.getPreventDefault())
return;
const openLink = function openLink(where) {
event.preventDefault();
dactyl.open(event.target.href, where);
}
if (event.target instanceof HTMLAnchorElement)
switch (events.toString(event)) {
case "<LeftMouse>":
openLink(dactyl.CURRENT_TAB);
break;
case "<MiddleMouse>":
case "<C-LeftMouse>":
case "<C-M-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: true });
break;
case "<S-MiddleMouse>":
case "<C-S-LeftMouse>":
case "<C-M-S-LeftMouse>":
openLink({ where: dactyl.NEW_TAB, background: false });
break;
case "<S-LeftMouse>":
openLink(dactyl.NEW_WINDOW);
break;
}
},
unload: function onUnload(event) {
event.preventDefault();
}
},
contextEvents: {
popupshowing: function (event) {
let menu = commandline.widgets.contextMenu;
let enabled = {
link: window.document.popupNode instanceof HTMLAnchorElement,
path: window.document.popupNode.hasAttribute("path"),
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
};
for (let node in array.iterValues(menu.children)) {
let group = node.getAttributeNS(NS, "group");
node.hidden = group && !group.split(/\s+/).every(function (g) enabled[g]);
}
}
},
onKeyPress: function onKeyPress(event) {
const KILL = false, PASS = true;
if (options["more"] && mow.isScrollable(1))
commandline.updateMorePrompt(false, true);
else {
modes.pop();
events.feedkeys(events.toString(event));
return KILL;
}
return PASS;
},
/**
* Changes the height of the message window to fit in the available space.
*
* @param {boolean} open If true, the widget will be opened if it's not
* already so.
*/
resize: function updateOutputHeight(open, extra) {
if (!open && this.widgets.mowContainer.collapsed)
return;
let doc = this.widget.contentDocument;
let availableHeight = config.outputHeight;
if (!this.widgets.mowContainer.collapsed)
availableHeight += parseFloat(this.widgets.mowContainer.height);
availableHeight -= extra || 0;
doc.body.style.minWidth = this.widgets.commandbar.commandline.scrollWidth + "px";
this.widgets.mowContainer.height = Math.min(doc.body.clientHeight, availableHeight) + "px";
this.timeout(function ()
this.widgets.mowContainer.height = Math.min(doc.body.clientHeight, availableHeight) + "px",
0);
doc.body.style.minWidth = "";
this.visible = true;
},
get spaceNeeded() {
let rect = this.widgets.commandbar.commandline.getBoundingClientRect();
let offset = rect.bottom - window.innerHeight;
return Math.max(0, offset);
},
/**
* Update or remove the multi-line output widget's "MORE" prompt.
*
* @param {boolean} force If true, "-- More --" is shown even if we're
* at the end of the output.
* @param {boolean} showHelp When true, show the valid key sequences
* and what they do.
*/
updateMorePrompt: function updateMorePrompt(force, showHelp) {
if (this.widgets.mowContainer.collapsed)
return this.widgets.message = null;
let elem = this.widget.contentDocument.documentElement;
if (showHelp)
this.widgets.message = ["MoreMsg", "-- More -- SPACE/<C-f>/j: screen/page/line down, <C-b>/<C-u>/k: up, q: quit"];
else if (force || (options["more"] && Buffer.isScrollable(elem, 1)))
this.widgets.message = ["MoreMsg", "-- More --"];
else
this.widgets.message = ["Question", "Press ENTER or type command to continue"];
},
visible: Modes.boundProperty({
set: function set_mowVisible(value) {
this.widgets.mowContainer.collapsed = !value;
let elem = this.widget;
if (!value && elem && elem.contentWindow == document.commandDispatcher.focusedWindow)
document.commandDispatcher.focusedWindow = content;
}
}),
}, {
}, {
mappings: function () {
const PASS = true;
const DROP = false;
const BEEP = {};
mappings.add([modes.COMMAND],
["g<lt>"], "Redisplay the last command output",
function () {
dactyl.assert(commandline.lastOutput, "No previous command output");
mow.echo(mow.lastOutput, "Normal");
});
bind = function bind(keys, description, action, test, default_) {
mappings.add([modes.OUTPUT_MULTILINE],
keys, description,
function (command) {
if (!options["more"])
var res = PASS;
else if (test && !test(command))
res = default_;
else
res = action.call(command);
if (res === PASS || res === DROP)
modes.pop();
else
mow.updateMorePrompt();
if (res === BEEP)
dactyl.beep();
else if (res === PASS)
events.feedkeys(command);
});
}
bind(["j", "<C-e>", "<Down>"], "Scroll down one line",
function () { mow.scrollVertical("lines", 1); },
function () mow.isScrollable(1), BEEP);
bind(["k", "<C-y>", "<Up>"], "Scroll up one line",
function () { mow.scrollVertical("lines", -1); },
function () mow.isScrollable(-1), BEEP);
bind(["<C-j>", "<C-m>", "<Return>"], "Scroll down one line, exit on last line",
function () { mow.scrollVertical("lines", 1); },
function () mow.isScrollable(1), DROP);
// half page down
bind(["<C-d>"], "Scroll down half a page",
function () { mow.scrollVertical("pages", .5); },
function () mow.isScrollable(1), BEEP);
bind(["<C-f>", "<PageDown>"], "Scroll down one page",
function () { mow.scrollVertical("pages", 1); },
function () mow.isScrollable(1), BEEP);
bind(["<Space>"], "Scroll down one page",
function () { mow.scrollVertical("pages", 1); },
function () mow.isScrollable(1), DROP);
bind(["<C-u>"], "Scroll up half a page",
function () { mow.scrollVertical("pages", -.5); },
function () mow.isScrollable(-1), BEEP);
bind(["<C-b>", "<PageUp>"], "Scroll up half a page",
function () { mow.scrollVertical("pages", -1); },
function () mow.isScrollable(-1), BEEP);
bind(["gg"], "Scroll to the beginning of output",
function () { mow.scrollToPercent(null, 0); })
bind(["G"], "Scroll to the end of output",
function () { mow.body.scrollTop = mow.body.scrollHeight; })
// copy text to clipboard
bind(["<C-y>"], "Yank selection to clipboard",
function () { dactyl.clipboardWrite(buffer.getCurrentWord(mow.window)); });
// close the window
bind(["q"], "Close the output window",
function () {},
function () false, DROP);
},
options: function () {
options.add(["more"],
"Pause the message list window when the full output will not fit on one page",
"boolean", true);
}
});

View File

@@ -910,7 +910,7 @@ var Tabs = Module("tabs", {
if (count != null)
tabs.switchTo(String(count));
else
commandline.open(":", "buffer! ", modes.EX);
CommandExMode.open("buffer! ");
},
{ count: true });

View File

@@ -20,7 +20,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
&dactyl.host; or to a web page, you have two options:
<item>
<tags><![CDATA[pass-through <C-z> CTRL-Z]]></tags>
<tags><![CDATA[pass-through <pass-all-keys> <C-z> CTRL-Z]]></tags>
<spec>&lt;C-z></spec>
<description>
<p>
@@ -33,7 +33,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
</item>
<item>
<tags><![CDATA[send-key <C-v> CTRL-V]]></tags>
<tags><![CDATA[send-key <pass-next-key> <C-v> CTRL-V]]></tags>
<spec>&lt;C-v></spec>
<description>
<p>
@@ -171,7 +171,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
</item>
<item>
<tags><![CDATA[<MiddleMouse> p]]></tags>
<tags><![CDATA[<open-clipboard-url> <MiddleMouse> p]]></tags>
<strut/>
<spec>p</spec>
<description>
@@ -185,7 +185,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
</item>
<item>
<tags>P</tags>
<tags>&lt;tab-open-clipboard-url> P</tags>
<strut/>
<spec>P</spec>
<description>
@@ -343,7 +343,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
<h2 tag="reloading">Reloading</h2>
<item>
<tags>r</tags>
<tags>&lt;reload> r</tags>
<spec>r</spec>
<description short="true">
<p>Reload the current web page.</p>
@@ -351,7 +351,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
</item>
<item>
<tags>R</tags>
<tags>&lt;full-reload> R</tags>
<spec>R</spec>
<description short="true">
<p>Reload the current web page without using the cache.</p>

View File

@@ -22,7 +22,7 @@
<h2 tag="buffer-information">Buffer information</h2>
<item>
<tags><![CDATA[<C-g>]]></tags>
<tags><![CDATA[<page-info> <C-g>]]></tags>
<strut/>
<spec>&lt;C-g></spec>
<description>
@@ -35,7 +35,7 @@
</item>
<item>
<tags><![CDATA[g<C-g>]]></tags>
<tags><![CDATA[<more-page-info> g<C-g>]]></tags>
<spec>g&lt;C-g></spec>
<description short="true">
<p>Print file information. Same as <ex>:pa<oa>geinfo</oa></ex>.</p>
@@ -95,7 +95,7 @@
<h2 tag="motion scrolling">Motion commands</h2>
<item>
<tags>^ 0</tags>
<tags>&lt;scroll-begin> ^ 0</tags>
<strut/>
<spec>0</spec>
<description>
@@ -107,7 +107,7 @@
</item>
<item>
<tags>$</tags>
<tags>&lt;scroll-end> $</tags>
<spec>$</spec>
<description short="true">
<p>Scroll to the absolute right of the document</p>
@@ -140,7 +140,7 @@
</item>
<item>
<tags>N%</tags>
<tags>&lt;scroll-percent> N%</tags>
<spec><a>count</a>%</spec>
<description short="true">
<p>Scroll to <a>count</a> percent of the document.</p>
@@ -148,7 +148,7 @@
</item>
<item>
<tags><![CDATA[<Left> h]]></tags>
<tags><![CDATA[<scroll-column-left> <Left> h]]></tags>
<strut/>
<spec><oa>count</oa>h</spec>
<description>
@@ -160,7 +160,7 @@
</item>
<item>
<tags><![CDATA[<C-e> <Down> j]]></tags>
<tags><![CDATA[<scroll-line-down> <C-e> <Down> j]]></tags>
<strut/>
<spec><oa>count</oa>j</spec>
<description>
@@ -172,7 +172,7 @@
</item>
<item>
<tags><![CDATA[<C-y> <Up> k]]></tags>
<tags><![CDATA[<scroll-line-up> <C-y> <Up> k]]></tags>
<strut/>
<spec><oa>count</oa>k</spec>
<description>
@@ -184,7 +184,7 @@
</item>
<item>
<tags><![CDATA[<Right> l]]></tags>
<tags><![CDATA[<scroll-column-right> <Right> l]]></tags>
<strut/>
<spec><oa>count</oa>l</spec>
<description>
@@ -196,7 +196,7 @@
</item>
<item>
<tags><![CDATA[<C-d>]]></tags>
<tags><![CDATA[<scroll-down> <C-d>]]></tags>
<strut/>
<spec><oa>count</oa>&lt;C-d></spec>
<description>
@@ -209,7 +209,7 @@
</item>
<item>
<tags><![CDATA[<C-u>]]></tags>
<tags><![CDATA[<scroll-up> <C-u>]]></tags>
<strut/>
<spec><oa>count</oa>&lt;C-u></spec>
<description>
@@ -222,7 +222,7 @@
</item>
<item>
<tags><![CDATA[<S-Space> <PageUp> <C-b>]]></tags>
<tags><![CDATA[<scroll-page-up> <S-Space> <PageUp> <C-b>]]></tags>
<strut/>
<spec><oa>count</oa>&lt;C-b></spec>
<description>
@@ -234,7 +234,7 @@
</item>
<item>
<tags><![CDATA[<Space> <PageDown> <C-f>]]></tags>
<tags><![CDATA[<scroll-page-down> <Space> <PageDown> <C-f>]]></tags>
<strut/>
<spec><oa>count</oa>&lt;C-f></spec>
<description>
@@ -264,7 +264,7 @@
</item>
<item>
<tags>gi</tags>
<tags>&lt;focus-input> gi</tags>
<strut/>
<spec><oa>count</oa>gi</spec>
<description>
@@ -277,7 +277,7 @@
</item>
<item>
<tags>]f</tags>
<tags>&lt;next-frame> ]f</tags>
<strut/>
<spec><oa>count</oa>]f</spec>
<description>
@@ -290,7 +290,7 @@
</item>
<item>
<tags>[f</tags>
<tags>&lt;previous-frame> [f</tags>
<strut/>
<spec><oa>count</oa>[f</spec>
<description>
@@ -303,7 +303,7 @@
</item>
<item>
<tags>]]</tags>
<tags>&lt;next-page> ]]</tags>
<strut/>
<spec><oa>count</oa>]]</spec>
<description>
@@ -316,7 +316,7 @@
</item>
<item>
<tags>[[</tags>
<tags>&lt;previous-page> [[</tags>
<strut/>
<spec><oa>count</oa>[[</spec>
<description>
@@ -361,7 +361,7 @@
</note>
<item>
<tags>+ zi</tags>
<tags><![CDATA[<text-zoom-in> + zi]]></tags>
<spec><oa>count</oa>zi</spec>
<description short="true">
<p>Enlarge text zoom of current web page. Mnemonic: zoom in.</p>
@@ -369,7 +369,7 @@
</item>
<item>
<tags>zm</tags>
<tags><![CDATA[<text-zoom-more> zm]]></tags>
<strut/>
<spec><oa>count</oa>zm</spec>
<description>
@@ -378,7 +378,7 @@
</item>
<item>
<tags>- zo</tags>
<tags><![CDATA[<text-zoom-out> - zo]]></tags>
<spec><oa>count</oa>zo</spec>
<description short="true">
<p>Reduce text zoom of current web page. Mnemonic: zoom out.</p>
@@ -386,7 +386,7 @@
</item>
<item>
<tags>zr</tags>
<tags><![CDATA[<text-zoom-reduce> zr]]></tags>
<spec><oa>count</oa>zr</spec>
<description short="true">
<p>Reduce text zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p>
@@ -394,7 +394,7 @@
</item>
<item>
<tags>zz</tags>
<tags><![CDATA[<text-zoom> zz]]></tags>
<strut/>
<spec><oa>count</oa>zz</spec>
<description>
@@ -407,7 +407,7 @@
</item>
<item>
<tags>ZI zI</tags>
<tags><![CDATA[<full-zoom-in> ZI zI]]></tags>
<spec><oa>count</oa>ZI</spec>
<description short="true">
<p>Enlarge full zoom of current web page. Mnemonic: zoom in.</p>
@@ -415,7 +415,7 @@
</item>
<item>
<tags>ZM zM</tags>
<tags><![CDATA[<full-zoom-more> ZM zM]]></tags>
<strut/>
<spec><oa>count</oa>ZM</spec>
<description>
@@ -424,7 +424,7 @@
</item>
<item>
<tags>ZO zO</tags>
<tags><![CDATA[<full-zoom-out> ZO zO]]></tags>
<spec><oa>count</oa>ZO</spec>
<description short="true">
<p>Reduce full zoom of current web page. Mnemonic: zoom out.</p>
@@ -432,7 +432,7 @@
</item>
<item>
<tags>ZR zR</tags>
<tags><![CDATA[<full-zoom-reduce> ZR zR]]></tags>
<spec><oa>count</oa>ZR</spec>
<description short="true">
<p>Reduce full zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p>
@@ -440,7 +440,7 @@
</item>
<item>
<tags>zZ</tags>
<tags><![CDATA[<full-zoom> zZ]]></tags>
<strut/>
<spec><oa>count</oa>zZ</spec>
<description>
@@ -489,7 +489,7 @@
</p>
<item>
<tags>y</tags>
<tags>&lt;yank-location> y</tags>
<spec>y</spec>
<description short="true">
<p>Yank current location to the clipboard.</p>
@@ -497,7 +497,7 @@
</item>
<item>
<tags>Y</tags>
<tags>&lt;yank-word> Y</tags>
<spec>Y</spec>
<description short="true">
<p>Copy currently selected text to the system clipboard.</p>

View File

@@ -218,6 +218,14 @@
</description>
</item>
<h3 tag=":map-timeout map-timeout">Mapping timeout</h3>
<p>
When &dactyl.appName; receives a key event that has a separate binding and
at the same time is part of a key chain, values of the <o>timeout</o> and
<o>timeoutlen</o> options are used to decide what to do. See the
documentation of those options for more information.
</p>
<h3 tag=":map-arguments">Special arguments</h3>
<tags>:map-&lt;silent></tags>

View File

@@ -21,7 +21,7 @@
<h2 tag="single-repeat">Single repeats</h2>
<item>
<tags>.</tags>
<tags>&lt;repeat-key> .</tags>
<strut/>
<spec><oa>count</oa>.</spec>
<description>
@@ -45,7 +45,7 @@
<h2 tag="macros complex-repeat">Macros</h2>
<item>
<tags>q</tags>
<tags>&lt;record-macro> q</tags>
<strut/>
<spec>q<a>0-9a-zA-Z</a></spec>
<description>
@@ -82,7 +82,7 @@
</item>
<item>
<tags>@</tags>
<tags>&lt;play-macro> @</tags>
<spec><oa>count</oa>@<a>a-z0-9</a></spec>
<description>
<p>
@@ -100,6 +100,39 @@
</description>
</item>
<h2 tag="macro-utilities">Macro utilities</h2>
<p>
The following key bindings facilitate the recording of efficient
macros. They have no effect when typed normally, but are
recorded and take effect during macro playback.
</p>
<item>
<tags><sleep> <A-m>s</tags>
<strut/>
<spec><a>count</a>&lt;m>s</spec>
<description>
<p>
Sleep for <a>count</a> milliseconds before resuming playback.
</p>
</description>
</item>
<item>
<tags><![CDATA[<wait-for-page-load> <A-m>l]]></tags>
<strut/>
<spec><oa>count</oa><![CDATA[<A-m>l]]></spec>
<description>
<p>
Wait for the current page to finish loading before resuming
playback. If <oa>count</oa> is given, wait no more than
<oa>count</oa> seconds. Otherwise wait no more than 25 seconds.
</p>
</description>
</item>
<h2 tag="using-scripts">Using scripts</h2>
<item>

View File

@@ -31,17 +31,17 @@ var AddonListener = Class("AddonListener", {
this.dactyl = modules.dactyl;
},
onNewInstall: function (install) {},
onExternalInstall: function (addon, existingAddon, needsRestart) {},
onNewInstall: function (install) {},
onExternalInstall: function (addon, existingAddon, needsRestart) {},
onDownloadStarted: listener("download", "started"),
onDownloadEnded: listener("download", "complete"),
onDownloadCancelled: listener("download", "cancelled"),
onDownloadFailed: listener("download", "failed"),
onDownloadProgress: function (install) {},
onInstallStarted: function (install) {},
onInstallEnded: listener("installation", "complete"),
onInstallCancelled: listener("installation", "cancelled"),
onInstallFailed: listener("installation", "failed")
onInstallStarted: function (install) {},
onInstallEnded: listener("installation", "complete"),
onInstallCancelled: listener("installation", "cancelled"),
onInstallFailed: listener("installation", "failed")
});
var updateAddons = Class("UpgradeListener", AddonListener, {
@@ -302,7 +302,7 @@ var AddonList = Class("AddonList", {
if (addon && addon.id in this.addons)
this.addons[addon.id].update();
if (this.ready)
this.modules.commandline.updateOutputHeight(false);
this.modules.mow.resize(false);
},
onDisabled: function (addon) { this.update(addon); },

View File

@@ -804,9 +804,7 @@ var CompletionContext = Class("CompletionContext", {
* If 0 or null, wait indefinitely.
*/
wait: function wait(interruptable, timeout) {
let end = Date.now() + timeout;
util.waitFor(function () !this.incomplete || (this.timeout && Date.now() > end),
this);
util.waitFor(function () !this.incomplete, this, timeout);
return this.incomplete;
}
}, {

View File

@@ -614,6 +614,9 @@ var ConfigBase = Class("ConfigBase", {
HelpString[delim]::before content: attr(delim);
HelpString[delim]::after content: attr(delim);
HelpNews position: relative;
HelpNewsOld opacity: .7;
HelpNewsTag position: absolute; left: 100%; padding-left: 1em; color: #527BBD; opacity: .6; white-space: pre;
HelpHead;html|h1,html|h2,html|h3,html|h4;dactyl://help/* {
font-weight: bold;

View File

@@ -296,7 +296,7 @@ var DownloadList = Class("DownloadList",
else {
this.addDownload(download.id);
this.modules.commandline.updateOutputHeight(false);
this.modules.mow.resize(false);
this.nodes.list.scrollIntoView(false);
}
this.update();

View File

@@ -15,24 +15,25 @@ var RangeFinder = Module("rangefinder", {
Local: function (dactyl, modules, window) ({
init: function () {
this.dactyl = dactyl;
this.commandline = modules.commandline;
this.modes = modules.modes;
this.modules = modules;
this.window = window;
this.options = modules.options;
this.lastFindPattern = "";
},
get commandline() this.modules.commandline,
get modes() this.modules.modes,
get options() this.modules.options,
get rangeFind() modules.buffer.localStore.rangeFind,
set rangeFind(val) modules.buffer.localStore.rangeFind = val
}),
openPrompt: function (mode) {
let backwards = mode == this.modes.FIND_BACKWARD;
this.commandline.open(backwards ? "?" : "/", "", mode);
this.CommandMode(mode).open();
if (this.rangeFind && this.rangeFind.window.get() === this.window)
this.rangeFind.reset();
this.find("", backwards);
this.find("", mode === this.modes.FIND_BACKWARD);
},
bootstrap: function (str, backward) {
@@ -119,8 +120,12 @@ var RangeFinder = Module("rangefinder", {
this.rangeFind.focus();
},
// Called when the user types a key in the find dialog. Triggers a find attempt if 'incfind' is set
onKeyPress: function (command) {
onCancel: function () {
if (this.rangeFind)
this.rangeFind.cancel();
},
onChange: function (command) {
if (this.options["incfind"]) {
command = this.bootstrap(command);
this.rangeFind.find(command);
@@ -138,13 +143,6 @@ var RangeFinder = Module("rangefinder", {
this.rangeFind.focus();
},
// Called when the find is canceled - for example if someone presses
// escape while typing a find
onCancel: function () {
if (this.rangeFind)
this.rangeFind.cancel();
},
/**
* Highlights all occurrences of the last sought for string in the
* current buffer.
@@ -163,12 +161,12 @@ var RangeFinder = Module("rangefinder", {
}
}, {
}, {
/* Must come before commandline. */
modes: function (dactyl, modules, window) {
const { modes } = modules;
const { commandline, modes } = modules;
modes.addMode("FIND", {
extended: true,
description: "Find mode, active when typing search input",
bases: [modes.COMMAND_LINE],
input: true
});
modes.addMode("FIND_FORWARD", {
@@ -176,22 +174,13 @@ var RangeFinder = Module("rangefinder", {
description: "Forward Find mode, active when typing search input",
bases: [modes.FIND],
input: true
}, { history: "search" });
});
modes.addMode("FIND_BACKWARD", {
extended: true,
description: "Backward Find mode, active when typing search input",
bases: [modes.FIND],
input: true
}, { history: "search" });
},
commandline: function (dactyl, modules, window) {
const { commandline, modes, rangefinder } = modules;
commandline.registerCallback("change", modes.FIND_FORWARD, rangefinder.closure.onKeyPress);
commandline.registerCallback("submit", modes.FIND_FORWARD, rangefinder.closure.onSubmit);
commandline.registerCallback("cancel", modes.FIND_FORWARD, rangefinder.closure.onCancel);
commandline.registerCallback("change", modes.FIND_BACKWARD, rangefinder.closure.onKeyPress);
commandline.registerCallback("submit", modes.FIND_BACKWARD, rangefinder.closure.onSubmit);
commandline.registerCallback("cancel", modes.FIND_BACKWARD, rangefinder.closure.onCancel);
});
},
commands: function (dactyl, modules, window) {
const { commands, rangefinder } = modules;
@@ -200,6 +189,22 @@ var RangeFinder = Module("rangefinder", {
function () { rangefinder.clear(); },
{ argCount: "0" });
},
commandline: function (dactyl, modules, window) {
this.CommandMode = Class("CommandFindMode", modules.CommandMode, {
init: function init(mode) {
this.mode = mode;
init.supercall(this);
},
historyKey: "find",
get prompt() this.mode === modules.modes.FIND_BACKWARD ? "?" : "/",
onCancel: this.closure.onCancel,
onChange: this.closure.onChange,
onSubmit: this.closure.onSubmit
});
},
mappings: function (dactyl, modules, window) {
const { buffer, config, mappings, modes, rangefinder } = modules;
var myModes = config.browserModes.concat([modes.CARET]);

View File

@@ -61,6 +61,27 @@ var IO = Module("io", {
services.downloadManager.addListener(this.downloadListener);
},
CommandFileMode: Class("CommandFileMode", modules.CommandMode, {
init: function init(prompt, params) {
init.supercall(this);
this.prompt = isArray(prompt) ? prompt : ["Question", prompt];
update(this, params);
},
historyKey: "file",
get mode() modules.modes.FILE_INPUT,
complete: function (context) {
if (this.completer)
this.completer(context);
context = context.fork("files", 0);
modules.completion.file(context);
context.filters = context.filters.concat(this.filters || []);
}
}),
destroy: function destroy() {
services.downloadManager.removeListener(this.downloadListener);
for (let [, plugin] in Iterator(plugins.contexts))
@@ -1004,6 +1025,16 @@ unlet s:cpo_save
}]);
},
modes: function (dactyl, modules, window) {
const { commandline, modes } = modules;
modes.addMode("FILE_INPUT", {
extended: true,
description: "Active when selecting a file",
bases: [modes.COMMAND_LINE],
input: true
});
},
options: function (dactyl, modules, window) {
const { options } = modules;

View File

@@ -176,6 +176,7 @@ var Overlay = Module("Overlay", {
"io",
"mappings",
"marks",
"mow",
"options",
"statusline",
"styles",
@@ -203,12 +204,14 @@ var Overlay = Module("Overlay", {
modules.loaded = loaded;
function init(module) {
let name = module.constructor.className;
function init(func, mod)
function () defineModule.time(module.className || module.constructor.className, mod,
func, module,
func, modules[name],
modules.dactyl, modules, window);
set.add(loaded, module.constructor.className);
set.add(loaded, name);
for (let [mod, func] in Iterator(module.INIT)) {
if (mod in loaded)
init(func, mod)();
@@ -240,7 +243,7 @@ var Overlay = Module("Overlay", {
defineModule.loadLog.push("Load" + (isString(prereq) ? " " + prereq + " dependency: " : ": ") + module.className);
if (frame && frame.filename)
defineModule.loadLog.push(" from: " + frame.filename + ":" + frame.lineNumber);
defineModule.loadLog.push(" from: " + frame.filename.replace(/.* -> /, "") + ":" + frame.lineNumber);
delete modules[module.className];
modules[module.className] = defineModule.time(module.className, "init", module);

View File

@@ -311,8 +311,8 @@ var Styles = Module("Styles", {
matchFilter: function (filter) {
if (filter === "*")
var test = function test(uri) true;
else if (filter[0] == "^") {
let re = RegExp(filter[0]);
else if (filter[0] === "^") {
let re = RegExp(filter);
test = function test(uri) re.test(uri.spec);
}
else if (/[*]$/.test(filter)) {
@@ -331,9 +331,12 @@ var Styles = Module("Styles", {
propertyIter: function (str, always) {
let i = 0;
for (let match in this.propertyPattern.iterate(str))
if (always && !i++ || match[0] && match.value)
for (let match in this.propertyPattern.iterate(str)) {
if (match.value || always && match.name || match.wholeMatch === match.preSpace && always && !i++)
yield match;
if (!/;/.test(match.postSpace))
break;
}
},
propertyPattern: util.regexp(<![CDATA[

View File

@@ -1529,8 +1529,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
this.yielders--;
}
},
waitFor: function waitFor(test, self, interruptable) {
while (!test.call(self))
waitFor: function waitFor(test, self, timeout, interruptable) {
let end = timeout && Date.now() + timeout;
while ((!end || Date.now() < end) && !test.call(self))
this.threadYield(false, interruptable);
},

View File

@@ -1 +0,0 @@
- shared-modules should be synced with http://hg.mozilla.org/qa/mozmill-tests/