mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 01:14:10 +01:00
Merge key-processing.
This commit is contained in:
@@ -115,9 +115,8 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
if (charset != null && charset !== "UTF-8")
|
if (charset != null && charset !== "UTF-8")
|
||||||
options["-charset"] = charset;
|
options["-charset"] = charset;
|
||||||
|
|
||||||
commandline.open(":",
|
CommandExMode().open(
|
||||||
commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword ",
|
commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword ");
|
||||||
modes.EX);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -213,7 +212,7 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
return iter(services.browserSearch.getVisibleEngines({})).map(function ([, engine]) {
|
return iter(services.browserSearch.getVisibleEngines({})).map(function ([, engine]) {
|
||||||
let alias = engine.alias;
|
let alias = engine.alias;
|
||||||
if (!alias || !/^[a-z-]+$/.test(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)
|
if (!alias)
|
||||||
alias = "search"; // for search engines which we can't find a suitable 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))
|
if (engine && engine.supportsResponseType(responseType))
|
||||||
var queryURI = engine.getSubmission(query, responseType).uri.spec;
|
var queryURI = engine.getSubmission(query, responseType).uri.spec;
|
||||||
if (!queryURI)
|
if (!queryURI)
|
||||||
return [];
|
return (callback || util.identity)([]);
|
||||||
|
|
||||||
function process(resp) {
|
function process(resp) {
|
||||||
let results = [];
|
let results = [];
|
||||||
@@ -582,9 +581,8 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
options["-charset"] = content.document.characterSet;
|
options["-charset"] = content.document.characterSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
commandline.open(":",
|
CommandExMode().open(
|
||||||
commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] }),
|
commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] }));
|
||||||
modes.EX);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add(myModes, ["A"],
|
mappings.add(myModes, ["A"],
|
||||||
|
|||||||
@@ -65,33 +65,33 @@ var Browser = Module("browser", {
|
|||||||
|
|
||||||
mappings: function () {
|
mappings: function () {
|
||||||
mappings.add([modes.NORMAL],
|
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); });
|
function () { dactyl.clipboardWrite(buffer.uri.spec, true); });
|
||||||
|
|
||||||
// opening websites
|
// opening websites
|
||||||
mappings.add([modes.NORMAL],
|
mappings.add([modes.NORMAL],
|
||||||
["o"], "Open one or more URLs",
|
["o"], "Open one or more URLs",
|
||||||
function () { commandline.open(":", "open ", modes.EX); });
|
function () { CommandExMode().open("open "); });
|
||||||
|
|
||||||
mappings.add([modes.NORMAL], ["O"],
|
mappings.add([modes.NORMAL], ["O"],
|
||||||
"Open one or more URLs, based on current location",
|
"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"],
|
mappings.add([modes.NORMAL], ["t"],
|
||||||
"Open one or more URLs in a new tab",
|
"Open one or more URLs in a new tab",
|
||||||
function () { commandline.open(":", "tabopen ", modes.EX); });
|
function () { CommandExMode().open("tabopen "); });
|
||||||
|
|
||||||
mappings.add([modes.NORMAL], ["T"],
|
mappings.add([modes.NORMAL], ["T"],
|
||||||
"Open one or more URLs in a new tab, based on current location",
|
"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"],
|
mappings.add([modes.NORMAL], ["w"],
|
||||||
"Open one or more URLs in a new window",
|
"Open one or more URLs in a new window",
|
||||||
function () { commandline.open(":", "winopen ", modes.EX); });
|
function () { CommandExMode().open("winopen "); });
|
||||||
|
|
||||||
mappings.add([modes.NORMAL], ["W"],
|
mappings.add([modes.NORMAL], ["W"],
|
||||||
"Open one or more URLs in a new window, based on current location",
|
"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],
|
mappings.add([modes.NORMAL],
|
||||||
["<C-a>"], "Increment last number in URL",
|
["<C-a>"], "Increment last number in URL",
|
||||||
|
|||||||
@@ -766,25 +766,25 @@ var Buffer = Module("buffer", {
|
|||||||
try {
|
try {
|
||||||
window.urlSecurityCheck(uri.spec, doc.nodePrincipal);
|
window.urlSecurityCheck(uri.spec, doc.nodePrincipal);
|
||||||
|
|
||||||
commandline.input("Save link: ", function (path) {
|
io.CommandFileMode("Save link: ", {
|
||||||
let file = io.File(path);
|
onSubmit: function (path) {
|
||||||
if (file.exists() && file.isDirectory())
|
let file = io.File(path);
|
||||||
file.append(buffer.getDefaultNames(elem)[0][0]);
|
if (file.exists() && file.isDirectory())
|
||||||
|
file.append(buffer.getDefaultNames(elem)[0][0]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
file.create(File.NORMAL_FILE_TYPE, octal(644));
|
file.create(File.NORMAL_FILE_TYPE, octal(644));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
util.assert(false, "Invalid destination: " + e.name);
|
util.assert(false, "Invalid destination: " + e.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.saveURI(uri, file);
|
buffer.saveURI(uri, file);
|
||||||
}, {
|
},
|
||||||
autocomplete: true,
|
|
||||||
completer: function (context) completion.savePage(context, elem),
|
completer: function (context) completion.savePage(context, elem)
|
||||||
history: "file"
|
}).open();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
dactyl.echoerr(e);
|
dactyl.echoerr(e);
|
||||||
@@ -1360,17 +1360,15 @@ var Buffer = Module("buffer", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
openUploadPrompt: function openUploadPrompt(elem) {
|
openUploadPrompt: function openUploadPrompt(elem) {
|
||||||
commandline.input("Upload file: ", function (path) {
|
io.CommandFileMode("Upload file: ", {
|
||||||
let file = io.File(path);
|
onSubmit: function (path) {
|
||||||
dactyl.assert(file.exists());
|
let file = io.File(path);
|
||||||
|
dactyl.assert(file.exists());
|
||||||
|
|
||||||
elem.value = file.path;
|
elem.value = file.path;
|
||||||
events.dispatch(elem, events.create(elem.ownerDocument, "change", {}));
|
events.dispatch(elem, events.create(elem.ownerDocument, "change", {}));
|
||||||
}, {
|
}
|
||||||
completer: function (context) completion.file(context),
|
}).open(elem.value);
|
||||||
default: elem.value,
|
|
||||||
history: "file"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
commands: function () {
|
commands: function () {
|
||||||
@@ -1422,7 +1420,7 @@ var Buffer = Module("buffer", {
|
|||||||
let arg = args[0];
|
let arg = args[0];
|
||||||
let opt = options.get("pageinfo");
|
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);
|
buffer.showPageInfo(true, arg);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1530,7 +1528,8 @@ var Buffer = Module("buffer", {
|
|||||||
if (/^>>/.test(context.filter))
|
if (/^>>/.test(context.filter))
|
||||||
context.advance(/^>>\s*/.exec(context.filter)[0].length);
|
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
|
literal: 0
|
||||||
});
|
});
|
||||||
@@ -1642,7 +1641,6 @@ var Buffer = Module("buffer", {
|
|||||||
this, function (context) {
|
this, function (context) {
|
||||||
context.completions = buffer.getDefaultNames(node);
|
context.completions = buffer.getDefaultNames(node);
|
||||||
});
|
});
|
||||||
return context.fork("files", 0, completion, "file");
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
events: function () {
|
events: function () {
|
||||||
@@ -1653,7 +1651,7 @@ var Buffer = Module("buffer", {
|
|||||||
mappings: function () {
|
mappings: function () {
|
||||||
var myModes = config.browserModes;
|
var myModes = config.browserModes;
|
||||||
|
|
||||||
mappings.add(myModes, ["."],
|
mappings.add(myModes, [".", "<repeat-key>"],
|
||||||
"Repeat the last key event",
|
"Repeat the last key event",
|
||||||
function (args) {
|
function (args) {
|
||||||
if (mappings.repeat) {
|
if (mappings.repeat) {
|
||||||
@@ -1672,31 +1670,31 @@ var Buffer = Module("buffer", {
|
|||||||
function () { ex.stop(); });
|
function () { ex.stop(); });
|
||||||
|
|
||||||
// scrolling
|
// scrolling
|
||||||
mappings.add(myModes, ["j", "<Down>", "<C-e>"],
|
mappings.add(myModes, ["j", "<Down>", "<C-e>", "<scroll-down-line>"],
|
||||||
"Scroll document down",
|
"Scroll document down",
|
||||||
function (args) { buffer.scrollVertical("lines", Math.max(args.count, 1)); },
|
function (args) { buffer.scrollVertical("lines", Math.max(args.count, 1)); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["k", "<Up>", "<C-y>"],
|
mappings.add(myModes, ["k", "<Up>", "<C-y>", "<scroll-up-line>"],
|
||||||
"Scroll document up",
|
"Scroll document up",
|
||||||
function (args) { buffer.scrollVertical("lines", -Math.max(args.count, 1)); },
|
function (args) { buffer.scrollVertical("lines", -Math.max(args.count, 1)); },
|
||||||
{ count: true });
|
{ 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",
|
"Scroll document to the left",
|
||||||
function (args) { buffer.scrollHorizontal("columns", -Math.max(args.count, 1)); },
|
function (args) { buffer.scrollHorizontal("columns", -Math.max(args.count, 1)); },
|
||||||
{ count: true });
|
{ 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",
|
"Scroll document to the right",
|
||||||
function (args) { buffer.scrollHorizontal("columns", Math.max(args.count, 1)); },
|
function (args) { buffer.scrollHorizontal("columns", Math.max(args.count, 1)); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["0", "^"],
|
mappings.add(myModes, ["0", "^", "<scroll-begin>"],
|
||||||
"Scroll to the absolute left of the document",
|
"Scroll to the absolute left of the document",
|
||||||
function () { buffer.scrollToPercent(0, null); });
|
function () { buffer.scrollToPercent(0, null); });
|
||||||
|
|
||||||
mappings.add(myModes, ["$"],
|
mappings.add(myModes, ["$", "<scroll-end>"],
|
||||||
"Scroll to the absolute right of the document",
|
"Scroll to the absolute right of the document",
|
||||||
function () { buffer.scrollToPercent(100, null); });
|
function () { buffer.scrollToPercent(100, null); });
|
||||||
|
|
||||||
@@ -1710,7 +1708,7 @@ var Buffer = Module("buffer", {
|
|||||||
function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 100); },
|
function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 100); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["%"],
|
mappings.add(myModes, ["%", "<scroll-percent>"],
|
||||||
"Scroll to {count} percent of the document",
|
"Scroll to {count} percent of the document",
|
||||||
function (args) {
|
function (args) {
|
||||||
dactyl.assert(args.count > 0 && args.count <= 100);
|
dactyl.assert(args.count > 0 && args.count <= 100);
|
||||||
@@ -1718,59 +1716,59 @@ var Buffer = Module("buffer", {
|
|||||||
},
|
},
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["<C-d>"],
|
mappings.add(myModes, ["<C-d>", "<scroll-down>"],
|
||||||
"Scroll window downwards in the buffer",
|
"Scroll window downwards in the buffer",
|
||||||
function (args) { buffer._scrollByScrollSize(args.count, true); },
|
function (args) { buffer._scrollByScrollSize(args.count, true); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["<C-u>"],
|
mappings.add(myModes, ["<C-u>", "<scroll-up>"],
|
||||||
"Scroll window upwards in the buffer",
|
"Scroll window upwards in the buffer",
|
||||||
function (args) { buffer._scrollByScrollSize(args.count, false); },
|
function (args) { buffer._scrollByScrollSize(args.count, false); },
|
||||||
{ count: true });
|
{ 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",
|
"Scroll up a full page",
|
||||||
function (args) { buffer.scrollVertical("pages", -Math.max(args.count, 1)); },
|
function (args) { buffer.scrollVertical("pages", -Math.max(args.count, 1)); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["<C-f>", "<PageDown>", "<Space>"],
|
mappings.add(myModes, ["<C-f>", "<PageDown>", "<Space>", "<scroll-page-down>"],
|
||||||
"Scroll down a full page",
|
"Scroll down a full page",
|
||||||
function (args) { buffer.scrollVertical("pages", Math.max(args.count, 1)); },
|
function (args) { buffer.scrollVertical("pages", Math.max(args.count, 1)); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["]f"],
|
mappings.add(myModes, ["]f", "<previous-frame>"],
|
||||||
"Focus next frame",
|
"Focus next frame",
|
||||||
function (args) { buffer.shiftFrameFocus(Math.max(args.count, 1)); },
|
function (args) { buffer.shiftFrameFocus(Math.max(args.count, 1)); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["[f"],
|
mappings.add(myModes, ["[f", "<next-frame>"],
|
||||||
"Focus previous frame",
|
"Focus previous frame",
|
||||||
function (args) { buffer.shiftFrameFocus(-Math.max(args.count, 1)); },
|
function (args) { buffer.shiftFrameFocus(-Math.max(args.count, 1)); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["]]"],
|
mappings.add(myModes, ["]]", "<next-page>"],
|
||||||
"Follow the link labeled 'next' or '>' if it exists",
|
"Follow the link labeled 'next' or '>' if it exists",
|
||||||
function (args) {
|
function (args) {
|
||||||
buffer.findLink("next", options["nextpattern"], (args.count || 1) - 1, true);
|
buffer.findLink("next", options["nextpattern"], (args.count || 1) - 1, true);
|
||||||
},
|
},
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["[["],
|
mappings.add(myModes, ["[[", "<previous-page>"],
|
||||||
"Follow the link labeled 'prev', 'previous' or '<' if it exists",
|
"Follow the link labeled 'prev', 'previous' or '<' if it exists",
|
||||||
function (args) {
|
function (args) {
|
||||||
buffer.findLink("previous", options["previouspattern"], (args.count || 1) - 1, true);
|
buffer.findLink("previous", options["previouspattern"], (args.count || 1) - 1, true);
|
||||||
},
|
},
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["gf"],
|
mappings.add(myModes, ["gf", "<view-source>"],
|
||||||
"Toggle between rendered and source view",
|
"Toggle between rendered and source view",
|
||||||
function () { buffer.viewSource(null, false); });
|
function () { buffer.viewSource(null, false); });
|
||||||
|
|
||||||
mappings.add(myModes, ["gF"],
|
mappings.add(myModes, ["gF", "<view-source-externally>"],
|
||||||
"View source with an external editor",
|
"View source with an external editor",
|
||||||
function () { buffer.viewSource(null, true); });
|
function () { buffer.viewSource(null, true); });
|
||||||
|
|
||||||
mappings.add(myModes, ["gi"],
|
mappings.add(myModes, ["gi", "<focus-input>"],
|
||||||
"Focus last used input field",
|
"Focus last used input field",
|
||||||
function (args) {
|
function (args) {
|
||||||
let elem = buffer.lastInputField;
|
let elem = buffer.lastInputField;
|
||||||
@@ -1810,7 +1808,7 @@ var Buffer = Module("buffer", {
|
|||||||
dactyl.open(url, { from: "paste", where: dactyl.NEW_TAB, background: true });
|
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",
|
"Open (put) a URL based on the current clipboard contents in the current buffer",
|
||||||
function () {
|
function () {
|
||||||
let url = dactyl.clipboardRead();
|
let url = dactyl.clipboardRead();
|
||||||
@@ -1818,7 +1816,7 @@ var Buffer = Module("buffer", {
|
|||||||
dactyl.open(url);
|
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",
|
"Open (put) a URL based on the current clipboard contents in a new buffer",
|
||||||
function () {
|
function () {
|
||||||
let url = dactyl.clipboardRead();
|
let url = dactyl.clipboardRead();
|
||||||
@@ -1827,16 +1825,16 @@ var Buffer = Module("buffer", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// reloading
|
// reloading
|
||||||
mappings.add(myModes, ["r"],
|
mappings.add(myModes, ["r", "<reload>"],
|
||||||
"Reload the current web page",
|
"Reload the current web page",
|
||||||
function () { tabs.reload(tabs.getTab(), false); });
|
function () { tabs.reload(tabs.getTab(), false); });
|
||||||
|
|
||||||
mappings.add(myModes, ["R"],
|
mappings.add(myModes, ["R", "<full-reload>"],
|
||||||
"Reload while skipping the cache",
|
"Reload while skipping the cache",
|
||||||
function () { tabs.reload(tabs.getTab(), true); });
|
function () { tabs.reload(tabs.getTab(), true); });
|
||||||
|
|
||||||
// yanking
|
// yanking
|
||||||
mappings.add(myModes, ["Y"],
|
mappings.add(myModes, ["Y", "<yank-word>"],
|
||||||
"Copy selected text or current word",
|
"Copy selected text or current word",
|
||||||
function () {
|
function () {
|
||||||
let sel = buffer.getCurrentWord();
|
let sel = buffer.getCurrentWord();
|
||||||
@@ -1845,62 +1843,62 @@ var Buffer = Module("buffer", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// zooming
|
// zooming
|
||||||
mappings.add(myModes, ["zi", "+"],
|
mappings.add(myModes, ["zi", "+", "<text-zoom-in>"],
|
||||||
"Enlarge text zoom of current web page",
|
"Enlarge text zoom of current web page",
|
||||||
function (args) { buffer.zoomIn(Math.max(args.count, 1), false); },
|
function (args) { buffer.zoomIn(Math.max(args.count, 1), false); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["zm"],
|
mappings.add(myModes, ["zm", "<text-zoom-more>"],
|
||||||
"Enlarge text zoom of current web page by a larger amount",
|
"Enlarge text zoom of current web page by a larger amount",
|
||||||
function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, false); },
|
function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, false); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["zo", "-"],
|
mappings.add(myModes, ["zo", "-", "<text-zoom-out>"],
|
||||||
"Reduce text zoom of current web page",
|
"Reduce text zoom of current web page",
|
||||||
function (args) { buffer.zoomOut(Math.max(args.count, 1), false); },
|
function (args) { buffer.zoomOut(Math.max(args.count, 1), false); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["zr"],
|
mappings.add(myModes, ["zr", "<text-zoom-reduce>"],
|
||||||
"Reduce text zoom of current web page by a larger amount",
|
"Reduce text zoom of current web page by a larger amount",
|
||||||
function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, false); },
|
function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, false); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["zz"],
|
mappings.add(myModes, ["zz", "<text-zoom>"],
|
||||||
"Set text zoom value of current web page",
|
"Set text zoom value of current web page",
|
||||||
function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, false); },
|
function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, false); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["ZI", "zI"],
|
mappings.add(myModes, ["ZI", "zI", "<full-zoom-in>"],
|
||||||
"Enlarge full zoom of current web page",
|
"Enlarge full zoom of current web page",
|
||||||
function (args) { buffer.zoomIn(Math.max(args.count, 1), true); },
|
function (args) { buffer.zoomIn(Math.max(args.count, 1), true); },
|
||||||
{ count: 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",
|
"Enlarge full zoom of current web page by a larger amount",
|
||||||
function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, true); },
|
function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, true); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["ZO", "zO"],
|
mappings.add(myModes, ["ZO", "zO", "<full-zoom-out>"],
|
||||||
"Reduce full zoom of current web page",
|
"Reduce full zoom of current web page",
|
||||||
function (args) { buffer.zoomOut(Math.max(args.count, 1), true); },
|
function (args) { buffer.zoomOut(Math.max(args.count, 1), true); },
|
||||||
{ count: 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",
|
"Reduce full zoom of current web page by a larger amount",
|
||||||
function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, true); },
|
function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, true); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes, ["zZ"],
|
mappings.add(myModes, ["zZ", "<full-zoom>"],
|
||||||
"Set full zoom value of current web page",
|
"Set full zoom value of current web page",
|
||||||
function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, true); },
|
function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, true); },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
// page info
|
// page info
|
||||||
mappings.add(myModes, ["<C-g>"],
|
mappings.add(myModes, ["<C-g>", "<page-info>"],
|
||||||
"Print the current file name",
|
"Print the current file name",
|
||||||
function () { buffer.showPageInfo(false); });
|
function () { buffer.showPageInfo(false); });
|
||||||
|
|
||||||
mappings.add(myModes, ["g<C-g>"],
|
mappings.add(myModes, ["g<C-g>", "<more-page-info>"],
|
||||||
"Print file information",
|
"Print file information",
|
||||||
function () { buffer.showPageInfo(true); });
|
function () { buffer.showPageInfo(true); });
|
||||||
},
|
},
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1334,6 +1334,7 @@ var Commands = Module("commands", {
|
|||||||
bang: args["-bang"],
|
bang: args["-bang"],
|
||||||
count: args["-count"],
|
count: args["-count"],
|
||||||
completer: completerFunc,
|
completer: completerFunc,
|
||||||
|
literal: args["-count"] == "*" ? 0 : null,
|
||||||
persist: !args["-nopersist"],
|
persist: !args["-nopersist"],
|
||||||
replacementText: args.literalArg,
|
replacementText: args.literalArg,
|
||||||
sourcing: io.sourcing && update({}, io.sourcing)
|
sourcing: io.sourcing && update({}, io.sourcing)
|
||||||
|
|||||||
@@ -40,11 +40,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
this.commands["dactyl.restart"] = function (event) {
|
this.commands["dactyl.restart"] = function (event) {
|
||||||
dactyl.restart();
|
dactyl.restart();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
styles.registerSheet("resource://dactyl-skin/dactyl.css");
|
||||||
},
|
},
|
||||||
|
|
||||||
cleanup: function () {
|
cleanup: function () {
|
||||||
delete window.dactyl;
|
delete window.dactyl;
|
||||||
delete window.liberator;
|
delete window.liberator;
|
||||||
|
|
||||||
|
styles.unregisterSheet("resource://dactyl-skin/dactyl.css");
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
@@ -1333,6 +1337,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
*/
|
*/
|
||||||
trapErrors: function trapErrors(func, self) {
|
trapErrors: function trapErrors(func, self) {
|
||||||
try {
|
try {
|
||||||
|
if (isString(func))
|
||||||
|
func = self[func];
|
||||||
return func.apply(self || this, Array.slice(arguments, 2));
|
return func.apply(self || this, Array.slice(arguments, 2));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|||||||
@@ -11,15 +11,17 @@
|
|||||||
var ProcessorStack = Class("ProcessorStack", {
|
var ProcessorStack = Class("ProcessorStack", {
|
||||||
init: function (mode, hives, keyModes) {
|
init: function (mode, hives, keyModes) {
|
||||||
this.main = mode.main;
|
this.main = mode.main;
|
||||||
|
this._actions = [];
|
||||||
this.actions = [];
|
this.actions = [];
|
||||||
this.buffer = "";
|
this.buffer = "";
|
||||||
this.events = [];
|
this.events = [];
|
||||||
|
|
||||||
this.processors = keyModes.map(function (m) hives.map(function (h) KeyProcessor(m, h)))
|
this.processors = keyModes.map(function (m) hives.map(function (h) KeyProcessor(m, h)))
|
||||||
.flatten().array;
|
.flatten().array;
|
||||||
|
this.ownsBuffer = !this.processors.some(function (p) p.main.ownsBuffer);
|
||||||
|
|
||||||
for (let [i, input] in Iterator(this.processors)) {
|
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)
|
if (params.preExecute)
|
||||||
input.preExecute = params.preExecute;
|
input.preExecute = params.preExecute;
|
||||||
if (params.postExecute)
|
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) {
|
process: function process(event) {
|
||||||
function dbg() {}
|
function dbg() {}
|
||||||
|
|
||||||
|
if (this.timer)
|
||||||
|
this.timer.cancel();
|
||||||
|
|
||||||
let key = events.toString(event);
|
let key = events.toString(event);
|
||||||
this.events.push(event);
|
this.events.push(event);
|
||||||
|
|
||||||
@@ -70,9 +134,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
dbg("ACTIONS: " + actions.length + " " + this.actions.length);
|
dbg("ACTIONS: " + actions.length + " " + this.actions.length);
|
||||||
dbg("PROCESSORS:", processors);
|
dbg("PROCESSORS:", processors);
|
||||||
|
|
||||||
if (!processors.some(function (p) p.main.ownsBuffer))
|
this._actions = actions;
|
||||||
statusline.updateInputBuffer(processors.length ? this.buffer : "");
|
|
||||||
|
|
||||||
this.actions = actions.concat(this.actions);
|
this.actions = actions.concat(this.actions);
|
||||||
|
|
||||||
if (result === Events.KILL)
|
if (result === Events.KILL)
|
||||||
@@ -87,41 +149,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
|
|
||||||
this.processors = processors;
|
this.processors = processors;
|
||||||
|
|
||||||
if (processors.length)
|
return this.execute(result, options["timeout"] && options["timeoutlen"] === 0)
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -157,12 +185,13 @@ var KeyProcessor = Class("KeyProcessor", {
|
|||||||
return this.onKeyPress(event);
|
return this.onKeyPress(event);
|
||||||
},
|
},
|
||||||
|
|
||||||
execute: function execute(map)
|
execute: function execute(map, args)
|
||||||
let (self = this, args = arguments)
|
let (self = this)
|
||||||
function execute() {
|
function execute() {
|
||||||
if (self.preExecute)
|
if (self.preExecute)
|
||||||
self.preExecute.apply(self, args);
|
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)
|
if (self.postExecute)
|
||||||
self.postExecute.apply(self, args);
|
self.postExecute.apply(self, args);
|
||||||
return res;
|
return res;
|
||||||
@@ -487,6 +516,7 @@ var Events = Module("events", {
|
|||||||
util.threadYield(1, true);
|
util.threadYield(1, true);
|
||||||
|
|
||||||
for (let [, evt_obj] in Iterator(events.fromString(keys))) {
|
for (let [, evt_obj] in Iterator(events.fromString(keys))) {
|
||||||
|
let now = Date.now();
|
||||||
for (let type in values(["keydown", "keyup", "keypress"])) {
|
for (let type in values(["keydown", "keyup", "keypress"])) {
|
||||||
let evt = update({}, evt_obj, { type: type });
|
let evt = update({}, evt_obj, { type: type });
|
||||||
|
|
||||||
@@ -587,9 +617,14 @@ var Events = Module("events", {
|
|||||||
* of x.
|
* of x.
|
||||||
*
|
*
|
||||||
* @param {string} keys Messy form.
|
* @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.
|
* @returns {string} Canonical form.
|
||||||
*/
|
*/
|
||||||
canonicalKeys: function (keys, unknownOk) {
|
canonicalKeys: function (keys, unknownOk) {
|
||||||
|
if (arguments.length === 1)
|
||||||
|
unknownOk = true;
|
||||||
return events.fromString(keys, unknownOk).map(events.closure.toString).join("");
|
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.
|
* <S-@> where @ is a non-case-changeable, non-space character.
|
||||||
*
|
*
|
||||||
* @param {string} keys The string to parse.
|
* @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]}
|
* @returns {Array[Object]}
|
||||||
*/
|
*/
|
||||||
fromString: function (input, unknownOk) {
|
fromString: function (input, unknownOk) {
|
||||||
let out = [];
|
|
||||||
|
|
||||||
|
if (arguments.length === 1)
|
||||||
|
unknownOk = true;
|
||||||
|
|
||||||
|
let out = [];
|
||||||
let re = RegExp("<.*?>?>|[^<]|<(?!.*>)", "g");
|
let re = RegExp("<.*?>?>|[^<]|<(?!.*>)", "g");
|
||||||
let match;
|
let match;
|
||||||
while ((match = re.exec(input))) {
|
while ((match = re.exec(input))) {
|
||||||
@@ -855,10 +896,7 @@ var Events = Module("events", {
|
|||||||
|
|
||||||
isContentNode: function isContentNode(node) {
|
isContentNode: function isContentNode(node) {
|
||||||
let win = (node.ownerDocument || node).defaultView || node;
|
let win = (node.ownerDocument || node).defaultView || node;
|
||||||
for (; win; win = win.parent != win && win.parent)
|
return XPCNativeWrapper(win).top == content;
|
||||||
if (win == content)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -867,39 +905,20 @@ var Events = Module("events", {
|
|||||||
*
|
*
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
waitForPageLoad: function () {
|
waitForPageLoad: function (time) {
|
||||||
util.threadYield(true); // clear queue
|
util.threadYield(true); // clear queue
|
||||||
|
|
||||||
if (buffer.loaded == 1)
|
if (buffer.loaded)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const maxWaitTime = 25;
|
dactyl.echo("Waiting for page to load...", commandline.DISALLOW_MULTILINE);
|
||||||
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();
|
|
||||||
|
|
||||||
if (!events.feedingKeys)
|
const maxWaitTime = (time || 25);
|
||||||
return false;
|
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)
|
if (!buffer.loaded)
|
||||||
dactyl.echoerr("Page did not load completely in " + maxWaitTime + " seconds. Macro stopped.");
|
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;
|
return buffer.loaded;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -992,7 +1011,7 @@ var Events = Module("events", {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
input: function onInput(event) {
|
input: function onInput(event) {
|
||||||
if (event.originalTarget.dactylKeyPress)
|
if ("dactylKeyPress" in event.originalTarget)
|
||||||
delete event.originalTarget.dactylKeyPress;
|
delete event.originalTarget.dactylKeyPress;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1017,18 +1036,17 @@ var Events = Module("events", {
|
|||||||
let duringFeed = this.duringFeed || [];
|
let duringFeed = this.duringFeed || [];
|
||||||
this.duringFeed = [];
|
this.duringFeed = [];
|
||||||
try {
|
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))
|
for (let [k, v] in Iterator(this.feedingEvent))
|
||||||
if (!(k in event))
|
if (!(k in event))
|
||||||
event[k] = v;
|
event[k] = v;
|
||||||
this.feedingEvent = null;
|
this.feedingEvent = null;
|
||||||
}
|
|
||||||
|
|
||||||
let key = events.toString(event);
|
let key = events.toString(event);
|
||||||
if (!key)
|
if (!key)
|
||||||
return null;
|
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);
|
events._macroKeys.push(key);
|
||||||
|
|
||||||
// feedingKeys needs to be separate from interrupted so
|
// 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 whatever it's started and a real <C-c>
|
||||||
// interrupting our playback.
|
// interrupting our playback.
|
||||||
if (events.feedingKeys && !event.isMacro) {
|
if (events.feedingKeys && !event.isMacro) {
|
||||||
if (!event.originalTarget)
|
|
||||||
util.dumpStack();
|
|
||||||
if (key == "<C-c>") {
|
if (key == "<C-c>") {
|
||||||
events.feedingKeys = false;
|
events.feedingKeys = false;
|
||||||
if (modes.replaying) {
|
if (modes.replaying) {
|
||||||
@@ -1087,7 +1103,8 @@ var Events = Module("events", {
|
|||||||
|
|
||||||
let hives = mappings.hives.slice(event.noremap ? -1 : 0);
|
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);
|
this.processor = ProcessorStack(mode, hives, keyModes);
|
||||||
}
|
}
|
||||||
@@ -1169,10 +1186,6 @@ var Events = Module("events", {
|
|||||||
// access to the real focus target
|
// access to the real focus target
|
||||||
// Huh? --djk
|
// Huh? --djk
|
||||||
onFocusChange: function onFocusChange(event) {
|
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
|
function hasHTMLDocument(win) win && win.document && win.document instanceof HTMLDocument
|
||||||
|
|
||||||
let win = window.document.commandDispatcher.focusedWindow;
|
let win = window.document.commandDispatcher.focusedWindow;
|
||||||
@@ -1193,22 +1206,13 @@ var Events = Module("events", {
|
|||||||
return;
|
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")
|
if (elem instanceof HTMLTextAreaElement || (elem && util.computedStyle(elem).MozUserModify == "read-write")
|
||||||
|| elem == null && win && Editor.getEditor(win)) {
|
|| elem == null && win && Editor.getEditor(win)) {
|
||||||
|
|
||||||
if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart)
|
if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart)
|
||||||
modes.pop();
|
modes.pop();
|
||||||
|
|
||||||
if (!(modes.main & (modes.INSERT | modes.TEXT_EDIT | modes.VISUAL)))
|
if (!modes.main.input)
|
||||||
if (options["insertmode"])
|
if (options["insertmode"])
|
||||||
modes.push(modes.INSERT);
|
modes.push(modes.INSERT);
|
||||||
else {
|
else {
|
||||||
@@ -1222,6 +1226,15 @@ var Events = Module("events", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Events.isInputElement(elem)) {
|
||||||
|
if (!modes.main.input)
|
||||||
|
modes.push(modes.INSERT);
|
||||||
|
|
||||||
|
if (hasHTMLDocument(win))
|
||||||
|
buffer.lastInputField = elem;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (config.focusChange) {
|
if (config.focusChange) {
|
||||||
config.focusChange(win);
|
config.focusChange(win);
|
||||||
return;
|
return;
|
||||||
@@ -1314,39 +1327,59 @@ var Events = Module("events", {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mappings: function () {
|
mappings: function () {
|
||||||
mappings.add(modes.all,
|
mappings.add(modes.MAIN,
|
||||||
["<C-z>"], "Temporarily ignore all " + config.appName + " key bindings",
|
["<C-z>", "<pass-all-keys>"], "Temporarily ignore all " + config.appName + " key bindings",
|
||||||
function () { modes.push(modes.PASS_THROUGH); });
|
function () { modes.push(modes.PASS_THROUGH); });
|
||||||
|
|
||||||
mappings.add(modes.all,
|
mappings.add(modes.MAIN,
|
||||||
["<C-v>"], "Pass through next key",
|
["<C-v>", "<pass-next-key>"], "Pass through next key",
|
||||||
function () {
|
function () {
|
||||||
if (modes.main == modes.QUOTE)
|
if (modes.main == modes.QUOTE)
|
||||||
return Events.PASS;
|
return Events.PASS;
|
||||||
modes.push(modes.QUOTE);
|
modes.push(modes.QUOTE);
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add(modes.all,
|
mappings.add(modes.BASE,
|
||||||
["<Nop>"], "Do nothing",
|
["<Nop>"], "Do nothing",
|
||||||
function () {});
|
function () {});
|
||||||
|
|
||||||
// macros
|
// macros
|
||||||
mappings.add([modes.NORMAL, modes.TEXT_AREA, modes.PLAYER].filter(util.identity),
|
mappings.add([modes.COMMAND],
|
||||||
["q"], "Record a key sequence into a macro",
|
["q", "<record-macro>"], "Record a key sequence into a macro",
|
||||||
function ({ arg }) {
|
function ({ arg }) {
|
||||||
events._macroKeys.pop();
|
events._macroKeys.pop();
|
||||||
events[modes.recording ? "finishRecording" : "startRecording"](arg);
|
events[modes.recording ? "finishRecording" : "startRecording"](arg);
|
||||||
},
|
},
|
||||||
{ get arg() !modes.recording });
|
{ get arg() !modes.recording });
|
||||||
|
|
||||||
mappings.add([modes.NORMAL, modes.TEXT_AREA, modes.PLAYER].filter(util.identity),
|
mappings.add([modes.COMMAND],
|
||||||
["@"], "Play a macro",
|
["@", "<play-macro>"], "Play a macro",
|
||||||
function ({ arg, count }) {
|
function ({ arg, count }) {
|
||||||
count = Math.max(count, 1);
|
count = Math.max(count, 1);
|
||||||
while (count-- && events.playMacro(arg))
|
while (count-- && events.playMacro(arg))
|
||||||
;
|
;
|
||||||
},
|
},
|
||||||
{ arg: true, count: true });
|
{ 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: function () {
|
||||||
options.add(["passkeys", "pk"],
|
options.add(["passkeys", "pk"],
|
||||||
@@ -1367,9 +1400,18 @@ var Events = Module("events", {
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["strictfocus", "sf"],
|
options.add(["strictfocus", "sf"],
|
||||||
"Prevent scripts from focusing input elements without user intervention",
|
"Prevent scripts from focusing input elements without user intervention",
|
||||||
"boolean", true);
|
"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: function () {
|
||||||
sanitizer.addItem("macros", {
|
sanitizer.addItem("macros", {
|
||||||
|
|||||||
@@ -9,16 +9,18 @@
|
|||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
/** @instance hints */
|
/** @instance hints */
|
||||||
|
|
||||||
var HintSession = Class("HintSession", {
|
var HintSession = Class("HintSession", CommandMode, {
|
||||||
init: function init(mode, opts) {
|
init: function init(mode, opts) {
|
||||||
|
init.supercall(this);
|
||||||
|
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
// Hack.
|
// Hack.
|
||||||
if (!opts.window && modes.main == modes.OUTPUT_MULTILINE)
|
if (!opts.window && modes.main == modes.OUTPUT_MULTILINE)
|
||||||
opts.window = commandline.widgets.multilineOutput.contentWindow;
|
opts.window = commandline.widgets.multilineOutput.contentWindow;
|
||||||
|
|
||||||
this.mode = hints.modes[mode];
|
this.hintMode = hints.modes[mode];
|
||||||
dactyl.assert(this.mode);
|
dactyl.assert(this.hintMode);
|
||||||
|
|
||||||
this.activeTimeout = null; // needed for hinttimeout > 0
|
this.activeTimeout = null; // needed for hinttimeout > 0
|
||||||
this.continue = Boolean(opts.continue);
|
this.continue = Boolean(opts.continue);
|
||||||
@@ -31,8 +33,7 @@ var HintSession = Class("HintSession", {
|
|||||||
this.usedTabKey = false;
|
this.usedTabKey = false;
|
||||||
this.validHints = []; // store the indices of the "hints" array with valid elements
|
this.validHints = []; // store the indices of the "hints" array with valid elements
|
||||||
|
|
||||||
commandline.input(UTF8(this.mode.prompt) + ": ", null, this.closure);
|
this.open();
|
||||||
modes.extended = modes.HINTS;
|
|
||||||
|
|
||||||
this.top = opts.window || content;
|
this.top = opts.window || content;
|
||||||
this.top.addEventListener("resize", hints.resizeTimer.closure.tell, true);
|
this.top.addEventListener("resize", hints.resizeTimer.closure.tell, true);
|
||||||
@@ -51,7 +52,22 @@ var HintSession = Class("HintSession", {
|
|||||||
this.checkUnique();
|
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() {
|
checkUnique: function _checkUnique() {
|
||||||
if (this.hintNumber == 0)
|
if (this.hintNumber == 0)
|
||||||
@@ -236,7 +252,7 @@ var HintSession = Class("HintSession", {
|
|||||||
|
|
||||||
let baseNodeAbsolute = util.xmlToDom(<span highlight="Hint" style="display: none"/>, doc);
|
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 res = util.evaluateXPath(mode.xpath, doc, true);
|
||||||
|
|
||||||
let start = this.pageHints.length;
|
let start = this.pageHints.length;
|
||||||
@@ -289,18 +305,6 @@ var HintSession = Class("HintSession", {
|
|||||||
return true;
|
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.
|
* Handle user input.
|
||||||
*
|
*
|
||||||
@@ -429,7 +433,7 @@ var HintSession = Class("HintSession", {
|
|||||||
if ((modes.extended & modes.HINTS) && !this.continue)
|
if ((modes.extended & modes.HINTS) && !this.continue)
|
||||||
modes.pop();
|
modes.pop();
|
||||||
commandline.lastEcho = null; // Hack.
|
commandline.lastEcho = null; // Hack.
|
||||||
dactyl.trapErrors(this.mode.action, this.mode,
|
dactyl.trapErrors("action", this.hintMode,
|
||||||
elem, elem.href || elem.src || "",
|
elem, elem.href || elem.src || "",
|
||||||
this.extendedhintCount, top);
|
this.extendedhintCount, top);
|
||||||
if (this.continue && this.top)
|
if (this.continue && this.top)
|
||||||
@@ -662,6 +666,7 @@ var Hints = Module("hints", {
|
|||||||
if (modes.extended & modes.HINTS)
|
if (modes.extended & modes.HINTS)
|
||||||
modes.getStack(0).params.onResize();
|
modes.getStack(0).params.onResize();
|
||||||
});
|
});
|
||||||
|
|
||||||
let appContent = document.getElementById("appcontent");
|
let appContent = document.getElementById("appcontent");
|
||||||
if (appContent)
|
if (appContent)
|
||||||
events.addSessionListener(appContent, "scroll", this.resizeTimer.closure.tell, false);
|
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("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("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("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("O", "Generate an ‘:open URL’ prompt", function (elem, loc) CommandExMode.open("open " + loc));
|
||||||
this.addMode("T", "Generate a ‘:tabopen URL’ prompt", function (elem, loc) commandline.open(":", "tabopen " + loc, modes.EX));
|
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) commandline.open(":", "winopen " + loc, modes.EX));
|
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("a", "Add a bookmark", function (elem) bookmarks.addSearchKeyword(elem));
|
||||||
this.addMode("S", "Add a search keyword", 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));
|
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) {
|
open: function open(mode, opts) {
|
||||||
this._extendedhintCount = opts.count;
|
this._extendedhintCount = opts.count;
|
||||||
commandline.input(mode, null, {
|
commandline.input(["Normal", mode], "", {
|
||||||
completer: function (context) {
|
completer: function (context) {
|
||||||
context.compare = function () 0;
|
context.compare = function () 0;
|
||||||
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints.modes))];
|
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints.modes))];
|
||||||
},
|
},
|
||||||
onAccept: function (arg) {
|
onSubmit: function (arg) {
|
||||||
if (arg)
|
if (arg)
|
||||||
util.timeout(function () {
|
hints.show(arg, opts);
|
||||||
dactyl.trapErrors(hints.show, hints, 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")
|
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 () {
|
mappings: function () {
|
||||||
var myModes = config.browserModes.concat(modes.OUTPUT_MULTILINE);
|
var myModes = config.browserModes.concat(modes.OUTPUT_MULTILINE);
|
||||||
mappings.add(myModes, ["f"],
|
mappings.add(myModes, ["f"],
|
||||||
@@ -1097,25 +1110,23 @@ var Hints = Module("hints", {
|
|||||||
|
|
||||||
mappings.add(modes.HINTS, ["<Return>"],
|
mappings.add(modes.HINTS, ["<Return>"],
|
||||||
"Follow the selected hint",
|
"Follow the selected hint",
|
||||||
function () { hints.hintSession.update(true); });
|
function ({ self }) { self.update(true); });
|
||||||
|
|
||||||
mappings.add(modes.HINTS, ["<Tab>"],
|
mappings.add(modes.HINTS, ["<Tab>"],
|
||||||
"Focus the next matching hint",
|
"Focus the next matching hint",
|
||||||
function () { hints.hintSession.tab(false); });
|
function ({ self }) { self.tab(false); });
|
||||||
|
|
||||||
mappings.add(modes.HINTS, ["<S-Tab>"],
|
mappings.add(modes.HINTS, ["<S-Tab>"],
|
||||||
"Focus the previous matching hint",
|
"Focus the previous matching hint",
|
||||||
function () { hints.hintSession.tab(true); });
|
function ({ self }) { self.tab(true); });
|
||||||
|
|
||||||
mappings.add(modes.HINTS, ["<BS>", "<C-h>"],
|
mappings.add(modes.HINTS, ["<BS>", "<C-h>"],
|
||||||
"Delete the previous character",
|
"Delete the previous character",
|
||||||
function () hints.hintSession.backspace());
|
function ({ self }) self.backspace());
|
||||||
|
|
||||||
mappings.add(modes.HINTS, ["<Leader>"],
|
mappings.add(modes.HINTS, ["<Leader>"],
|
||||||
"Toggle hint filtering",
|
"Toggle hint filtering",
|
||||||
function () {
|
function ({ self }) { self.escapeNumbers = !self.escapeNumbers; });
|
||||||
hints.hintSession.escapeNumbers = !hints.hintSession.escapeNumbers;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
options: function () {
|
options: function () {
|
||||||
const DEFAULT_HINTTAGS =
|
const DEFAULT_HINTTAGS =
|
||||||
|
|||||||
@@ -113,9 +113,18 @@ var Map = Class("Map", {
|
|||||||
if (this.executing)
|
if (this.executing)
|
||||||
util.dumpStack("Attempt to execute mapping recursively: " + args.command);
|
util.dumpStack("Attempt to execute mapping recursively: " + args.command);
|
||||||
dactyl.assert(!this.executing, "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);
|
try {
|
||||||
this.executing = false;
|
this.executing = true;
|
||||||
|
var res = repeat();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
events.feedingKeys = false;
|
||||||
|
dactyl.reportError(e, true);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
this.executing = false;
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +304,8 @@ var Mappings = Module("mappings", {
|
|||||||
this.allHives = [this.user, this.builtin];
|
this.allHives = [this.user, this.builtin];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
repeat: Modes.boundProperty(),
|
||||||
|
|
||||||
hives: Class.memoize(function () array(this.allHives.filter(function (h) h.filter(buffer.uri)))),
|
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),
|
get userHives() this.allHives.filter(function (h) h !== this.builtin, this),
|
||||||
|
|||||||
@@ -119,12 +119,6 @@ var Modes = Module("modes", {
|
|||||||
input: true,
|
input: true,
|
||||||
ownsFocus: true
|
ownsFocus: true
|
||||||
});
|
});
|
||||||
this.addMode("COMMAND_LINE", {
|
|
||||||
char: "c",
|
|
||||||
description: "Active when the command line is focused",
|
|
||||||
input: true
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
this.addMode("EMBED", {
|
this.addMode("EMBED", {
|
||||||
input: true,
|
input: true,
|
||||||
@@ -160,31 +154,9 @@ var Modes = Module("modes", {
|
|||||||
input: true
|
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", {
|
this.addMode("LINE", {
|
||||||
extended: true, hidden: true
|
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, {
|
this.push(this.NORMAL, 0, {
|
||||||
enter: function (stack, prev) {
|
enter: function (stack, prev) {
|
||||||
@@ -214,9 +186,9 @@ var Modes = Module("modes", {
|
|||||||
_getModeMessage: function () {
|
_getModeMessage: function () {
|
||||||
// when recording a macro
|
// when recording a macro
|
||||||
let macromode = "";
|
let macromode = "";
|
||||||
if (modes.recording)
|
if (this.recording)
|
||||||
macromode = "recording";
|
macromode = "recording";
|
||||||
else if (modes.replaying)
|
else if (this.replaying)
|
||||||
macromode = "replaying";
|
macromode = "replaying";
|
||||||
|
|
||||||
let val = this._modeMap[this._main].display();
|
let val = this._modeMap[this._main].display();
|
||||||
@@ -292,11 +264,11 @@ var Modes = Module("modes", {
|
|||||||
delayed: [],
|
delayed: [],
|
||||||
delay: function (callback, self) { this.delayed.push([callback, self]); },
|
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))
|
if (!(id in this.boundProperties))
|
||||||
for (let elem in array.iterValues(this._modeStack))
|
for (let elem in array.iterValues(this._modeStack))
|
||||||
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop] };
|
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop], test: test };
|
||||||
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop };
|
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop, test: test };
|
||||||
},
|
},
|
||||||
|
|
||||||
// helper function to set both modes in one go
|
// 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)
|
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) &&
|
let push = mainMode != null && !(stack && stack.pop) &&
|
||||||
Modes.StackElement(this._main, this._extended, params, {});
|
Modes.StackElement(this._main, this._extended, params, {});
|
||||||
|
|
||||||
if (push && this.topOfStack) {
|
if (push && this.topOfStack) {
|
||||||
if (this.topOfStack.params.leave)
|
if (this.topOfStack.params.leave)
|
||||||
this.topOfStack.params.leave({ push: push }, push);
|
dactyl.trapErrors("leave", this.topOfStack.params,
|
||||||
for (let [id, { obj, prop }] in Iterator(this.boundProperties)) {
|
{ push: push }, push);
|
||||||
|
|
||||||
|
for (let [id, { obj, prop, test }] in Iterator(this.boundProperties)) {
|
||||||
if (!obj.get())
|
if (!obj.get())
|
||||||
delete this.boundProperties[id];
|
delete this.boundProperties[id];
|
||||||
else
|
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 = [];
|
this.delayed = [];
|
||||||
|
|
||||||
let prev = stack && stack.pop || this.topOfStack;
|
let prev = stack && stack.pop || this.topOfStack;
|
||||||
@@ -340,12 +316,18 @@ var Modes = Module("modes", {
|
|||||||
this._modeStack.push(push);
|
this._modeStack.push(push);
|
||||||
|
|
||||||
if (stack && stack.pop)
|
if (stack && stack.pop)
|
||||||
for (let { obj, prop, value } in values(this.topOfStack.saved))
|
for (let { obj, prop, value, test } in values(this.topOfStack.saved))
|
||||||
obj[prop] = value;
|
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)
|
if (this.topOfStack.params.enter && prev)
|
||||||
this.topOfStack.params.enter(push ? { push: push } : stack || {},
|
dactyl.trapErrors("enter", this.topOfStack.params,
|
||||||
prev);
|
push ? { push: push } : stack || {},
|
||||||
|
prev);
|
||||||
|
|
||||||
dactyl.triggerObserver("modeChange", [oldMain, oldExtended], [this._main, this._extended], stack);
|
dactyl.triggerObserver("modeChange", [oldMain, oldExtended], [this._main, this._extended], stack);
|
||||||
this.show();
|
this.show();
|
||||||
@@ -439,7 +421,7 @@ var Modes = Module("modes", {
|
|||||||
|
|
||||||
input: false,
|
input: false,
|
||||||
|
|
||||||
passUnknown: false,
|
get passUnknown() this.input,
|
||||||
|
|
||||||
get mask() this,
|
get mask() this,
|
||||||
|
|
||||||
@@ -476,7 +458,7 @@ var Modes = Module("modes", {
|
|||||||
return val === undefined ? value : val;
|
return val === undefined ? value : val;
|
||||||
},
|
},
|
||||||
set: function (val) {
|
set: function (val) {
|
||||||
modes.save(id, this, prop);
|
modes.save(id, this, prop, desc.test);
|
||||||
if (desc.set)
|
if (desc.set)
|
||||||
value = desc.set.call(this, val);
|
value = desc.set.call(this, val);
|
||||||
value = !desc.set || value === undefined ? val : value;
|
value = !desc.set || value === undefined ? val : value;
|
||||||
|
|||||||
355
common/content/mow.js
Normal file
355
common/content/mow.js
Normal 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -910,7 +910,7 @@ var Tabs = Module("tabs", {
|
|||||||
if (count != null)
|
if (count != null)
|
||||||
tabs.switchTo(String(count));
|
tabs.switchTo(String(count));
|
||||||
else
|
else
|
||||||
commandline.open(":", "buffer! ", modes.EX);
|
CommandExMode.open("buffer! ");
|
||||||
},
|
},
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
&dactyl.host; or to a web page, you have two options:
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[pass-through <C-z> CTRL-Z]]></tags>
|
<tags><![CDATA[pass-through <pass-all-keys> <C-z> CTRL-Z]]></tags>
|
||||||
<spec><C-z></spec>
|
<spec><C-z></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
@@ -33,7 +33,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[send-key <C-v> CTRL-V]]></tags>
|
<tags><![CDATA[send-key <pass-next-key> <C-v> CTRL-V]]></tags>
|
||||||
<spec><C-v></spec>
|
<spec><C-v></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
@@ -171,7 +171,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<MiddleMouse> p]]></tags>
|
<tags><![CDATA[<open-clipboard-url> <MiddleMouse> p]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec>p</spec>
|
<spec>p</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -185,7 +185,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>P</tags>
|
<tags><tab-open-clipboard-url> P</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec>P</spec>
|
<spec>P</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -343,7 +343,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
<h2 tag="reloading">Reloading</h2>
|
<h2 tag="reloading">Reloading</h2>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>r</tags>
|
<tags><reload> r</tags>
|
||||||
<spec>r</spec>
|
<spec>r</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Reload the current web page.</p>
|
<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>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>R</tags>
|
<tags><full-reload> R</tags>
|
||||||
<spec>R</spec>
|
<spec>R</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Reload the current web page without using the cache.</p>
|
<p>Reload the current web page without using the cache.</p>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<h2 tag="buffer-information">Buffer information</h2>
|
<h2 tag="buffer-information">Buffer information</h2>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<C-g>]]></tags>
|
<tags><![CDATA[<page-info> <C-g>]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><C-g></spec>
|
<spec><C-g></spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[g<C-g>]]></tags>
|
<tags><![CDATA[<more-page-info> g<C-g>]]></tags>
|
||||||
<spec>g<C-g></spec>
|
<spec>g<C-g></spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Print file information. Same as <ex>:pa<oa>geinfo</oa></ex>.</p>
|
<p>Print file information. Same as <ex>:pa<oa>geinfo</oa></ex>.</p>
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
<h2 tag="motion scrolling">Motion commands</h2>
|
<h2 tag="motion scrolling">Motion commands</h2>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>^ 0</tags>
|
<tags><scroll-begin> ^ 0</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec>0</spec>
|
<spec>0</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>$</tags>
|
<tags><scroll-end> $</tags>
|
||||||
<spec>$</spec>
|
<spec>$</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Scroll to the absolute right of the document</p>
|
<p>Scroll to the absolute right of the document</p>
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>N%</tags>
|
<tags><scroll-percent> N%</tags>
|
||||||
<spec><a>count</a>%</spec>
|
<spec><a>count</a>%</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Scroll to <a>count</a> percent of the document.</p>
|
<p>Scroll to <a>count</a> percent of the document.</p>
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<Left> h]]></tags>
|
<tags><![CDATA[<scroll-column-left> <Left> h]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>h</spec>
|
<spec><oa>count</oa>h</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -160,7 +160,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<C-e> <Down> j]]></tags>
|
<tags><![CDATA[<scroll-line-down> <C-e> <Down> j]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>j</spec>
|
<spec><oa>count</oa>j</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -172,7 +172,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<C-y> <Up> k]]></tags>
|
<tags><![CDATA[<scroll-line-up> <C-y> <Up> k]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>k</spec>
|
<spec><oa>count</oa>k</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -184,7 +184,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<Right> l]]></tags>
|
<tags><![CDATA[<scroll-column-right> <Right> l]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>l</spec>
|
<spec><oa>count</oa>l</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -196,7 +196,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<C-d>]]></tags>
|
<tags><![CDATA[<scroll-down> <C-d>]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa><C-d></spec>
|
<spec><oa>count</oa><C-d></spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<C-u>]]></tags>
|
<tags><![CDATA[<scroll-up> <C-u>]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa><C-u></spec>
|
<spec><oa>count</oa><C-u></spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -222,7 +222,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<S-Space> <PageUp> <C-b>]]></tags>
|
<tags><![CDATA[<scroll-page-up> <S-Space> <PageUp> <C-b>]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa><C-b></spec>
|
<spec><oa>count</oa><C-b></spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -234,7 +234,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<Space> <PageDown> <C-f>]]></tags>
|
<tags><![CDATA[<scroll-page-down> <Space> <PageDown> <C-f>]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa><C-f></spec>
|
<spec><oa>count</oa><C-f></spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -264,7 +264,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>gi</tags>
|
<tags><focus-input> gi</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>gi</spec>
|
<spec><oa>count</oa>gi</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -277,7 +277,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>]f</tags>
|
<tags><next-frame> ]f</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>]f</spec>
|
<spec><oa>count</oa>]f</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -290,7 +290,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>[f</tags>
|
<tags><previous-frame> [f</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>[f</spec>
|
<spec><oa>count</oa>[f</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -303,7 +303,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>]]</tags>
|
<tags><next-page> ]]</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>]]</spec>
|
<spec><oa>count</oa>]]</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -316,7 +316,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>[[</tags>
|
<tags><previous-page> [[</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>[[</spec>
|
<spec><oa>count</oa>[[</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -361,7 +361,7 @@
|
|||||||
</note>
|
</note>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>+ zi</tags>
|
<tags><![CDATA[<text-zoom-in> + zi]]></tags>
|
||||||
<spec><oa>count</oa>zi</spec>
|
<spec><oa>count</oa>zi</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Enlarge text zoom of current web page. Mnemonic: zoom in.</p>
|
<p>Enlarge text zoom of current web page. Mnemonic: zoom in.</p>
|
||||||
@@ -369,7 +369,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>zm</tags>
|
<tags><![CDATA[<text-zoom-more> zm]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>zm</spec>
|
<spec><oa>count</oa>zm</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -378,7 +378,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>- zo</tags>
|
<tags><![CDATA[<text-zoom-out> - zo]]></tags>
|
||||||
<spec><oa>count</oa>zo</spec>
|
<spec><oa>count</oa>zo</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Reduce text zoom of current web page. Mnemonic: zoom out.</p>
|
<p>Reduce text zoom of current web page. Mnemonic: zoom out.</p>
|
||||||
@@ -386,7 +386,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>zr</tags>
|
<tags><![CDATA[<text-zoom-reduce> zr]]></tags>
|
||||||
<spec><oa>count</oa>zr</spec>
|
<spec><oa>count</oa>zr</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Reduce text zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p>
|
<p>Reduce text zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p>
|
||||||
@@ -394,7 +394,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>zz</tags>
|
<tags><![CDATA[<text-zoom> zz]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>zz</spec>
|
<spec><oa>count</oa>zz</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -407,7 +407,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>ZI zI</tags>
|
<tags><![CDATA[<full-zoom-in> ZI zI]]></tags>
|
||||||
<spec><oa>count</oa>ZI</spec>
|
<spec><oa>count</oa>ZI</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Enlarge full zoom of current web page. Mnemonic: zoom in.</p>
|
<p>Enlarge full zoom of current web page. Mnemonic: zoom in.</p>
|
||||||
@@ -415,7 +415,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>ZM zM</tags>
|
<tags><![CDATA[<full-zoom-more> ZM zM]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>ZM</spec>
|
<spec><oa>count</oa>ZM</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -424,7 +424,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>ZO zO</tags>
|
<tags><![CDATA[<full-zoom-out> ZO zO]]></tags>
|
||||||
<spec><oa>count</oa>ZO</spec>
|
<spec><oa>count</oa>ZO</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Reduce full zoom of current web page. Mnemonic: zoom out.</p>
|
<p>Reduce full zoom of current web page. Mnemonic: zoom out.</p>
|
||||||
@@ -432,7 +432,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>ZR zR</tags>
|
<tags><![CDATA[<full-zoom-reduce> ZR zR]]></tags>
|
||||||
<spec><oa>count</oa>ZR</spec>
|
<spec><oa>count</oa>ZR</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Reduce full zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p>
|
<p>Reduce full zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p>
|
||||||
@@ -440,7 +440,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>zZ</tags>
|
<tags><![CDATA[<full-zoom> zZ]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>zZ</spec>
|
<spec><oa>count</oa>zZ</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -489,7 +489,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>y</tags>
|
<tags><yank-location> y</tags>
|
||||||
<spec>y</spec>
|
<spec>y</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Yank current location to the clipboard.</p>
|
<p>Yank current location to the clipboard.</p>
|
||||||
@@ -497,7 +497,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>Y</tags>
|
<tags><yank-word> Y</tags>
|
||||||
<spec>Y</spec>
|
<spec>Y</spec>
|
||||||
<description short="true">
|
<description short="true">
|
||||||
<p>Copy currently selected text to the system clipboard.</p>
|
<p>Copy currently selected text to the system clipboard.</p>
|
||||||
|
|||||||
@@ -218,6 +218,14 @@
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</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>
|
<h3 tag=":map-arguments">Special arguments</h3>
|
||||||
|
|
||||||
<tags>:map-<silent></tags>
|
<tags>:map-<silent></tags>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<h2 tag="single-repeat">Single repeats</h2>
|
<h2 tag="single-repeat">Single repeats</h2>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>.</tags>
|
<tags><repeat-key> .</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><oa>count</oa>.</spec>
|
<spec><oa>count</oa>.</spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
<h2 tag="macros complex-repeat">Macros</h2>
|
<h2 tag="macros complex-repeat">Macros</h2>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>q</tags>
|
<tags><record-macro> q</tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec>q<a>0-9a-zA-Z</a></spec>
|
<spec>q<a>0-9a-zA-Z</a></spec>
|
||||||
<description>
|
<description>
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>@</tags>
|
<tags><play-macro> @</tags>
|
||||||
<spec><oa>count</oa>@<a>a-z0-9</a></spec>
|
<spec><oa>count</oa>@<a>a-z0-9</a></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
@@ -100,6 +100,39 @@
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</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><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>
|
<h2 tag="using-scripts">Using scripts</h2>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -31,17 +31,17 @@ var AddonListener = Class("AddonListener", {
|
|||||||
this.dactyl = modules.dactyl;
|
this.dactyl = modules.dactyl;
|
||||||
},
|
},
|
||||||
|
|
||||||
onNewInstall: function (install) {},
|
onNewInstall: function (install) {},
|
||||||
onExternalInstall: function (addon, existingAddon, needsRestart) {},
|
onExternalInstall: function (addon, existingAddon, needsRestart) {},
|
||||||
onDownloadStarted: listener("download", "started"),
|
onDownloadStarted: listener("download", "started"),
|
||||||
onDownloadEnded: listener("download", "complete"),
|
onDownloadEnded: listener("download", "complete"),
|
||||||
onDownloadCancelled: listener("download", "cancelled"),
|
onDownloadCancelled: listener("download", "cancelled"),
|
||||||
onDownloadFailed: listener("download", "failed"),
|
onDownloadFailed: listener("download", "failed"),
|
||||||
onDownloadProgress: function (install) {},
|
onDownloadProgress: function (install) {},
|
||||||
onInstallStarted: function (install) {},
|
onInstallStarted: function (install) {},
|
||||||
onInstallEnded: listener("installation", "complete"),
|
onInstallEnded: listener("installation", "complete"),
|
||||||
onInstallCancelled: listener("installation", "cancelled"),
|
onInstallCancelled: listener("installation", "cancelled"),
|
||||||
onInstallFailed: listener("installation", "failed")
|
onInstallFailed: listener("installation", "failed")
|
||||||
});
|
});
|
||||||
|
|
||||||
var updateAddons = Class("UpgradeListener", AddonListener, {
|
var updateAddons = Class("UpgradeListener", AddonListener, {
|
||||||
@@ -302,7 +302,7 @@ var AddonList = Class("AddonList", {
|
|||||||
if (addon && addon.id in this.addons)
|
if (addon && addon.id in this.addons)
|
||||||
this.addons[addon.id].update();
|
this.addons[addon.id].update();
|
||||||
if (this.ready)
|
if (this.ready)
|
||||||
this.modules.commandline.updateOutputHeight(false);
|
this.modules.mow.resize(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
onDisabled: function (addon) { this.update(addon); },
|
onDisabled: function (addon) { this.update(addon); },
|
||||||
|
|||||||
@@ -804,9 +804,7 @@ var CompletionContext = Class("CompletionContext", {
|
|||||||
* If 0 or null, wait indefinitely.
|
* If 0 or null, wait indefinitely.
|
||||||
*/
|
*/
|
||||||
wait: function wait(interruptable, timeout) {
|
wait: function wait(interruptable, timeout) {
|
||||||
let end = Date.now() + timeout;
|
util.waitFor(function () !this.incomplete, this, timeout);
|
||||||
util.waitFor(function () !this.incomplete || (this.timeout && Date.now() > end),
|
|
||||||
this);
|
|
||||||
return this.incomplete;
|
return this.incomplete;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -614,6 +614,9 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
HelpString[delim]::before content: attr(delim);
|
HelpString[delim]::before content: attr(delim);
|
||||||
HelpString[delim]::after 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/* {
|
HelpHead;html|h1,html|h2,html|h3,html|h4;dactyl://help/* {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ var DownloadList = Class("DownloadList",
|
|||||||
else {
|
else {
|
||||||
this.addDownload(download.id);
|
this.addDownload(download.id);
|
||||||
|
|
||||||
this.modules.commandline.updateOutputHeight(false);
|
this.modules.mow.resize(false);
|
||||||
this.nodes.list.scrollIntoView(false);
|
this.nodes.list.scrollIntoView(false);
|
||||||
}
|
}
|
||||||
this.update();
|
this.update();
|
||||||
|
|||||||
@@ -15,24 +15,25 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
Local: function (dactyl, modules, window) ({
|
Local: function (dactyl, modules, window) ({
|
||||||
init: function () {
|
init: function () {
|
||||||
this.dactyl = dactyl;
|
this.dactyl = dactyl;
|
||||||
this.commandline = modules.commandline;
|
this.modules = modules;
|
||||||
this.modes = modules.modes;
|
|
||||||
this.window = window;
|
this.window = window;
|
||||||
this.options = modules.options;
|
|
||||||
this.lastFindPattern = "";
|
this.lastFindPattern = "";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get commandline() this.modules.commandline,
|
||||||
|
get modes() this.modules.modes,
|
||||||
|
get options() this.modules.options,
|
||||||
|
|
||||||
get rangeFind() modules.buffer.localStore.rangeFind,
|
get rangeFind() modules.buffer.localStore.rangeFind,
|
||||||
set rangeFind(val) modules.buffer.localStore.rangeFind = val
|
set rangeFind(val) modules.buffer.localStore.rangeFind = val
|
||||||
}),
|
}),
|
||||||
|
|
||||||
openPrompt: function (mode) {
|
openPrompt: function (mode) {
|
||||||
let backwards = mode == this.modes.FIND_BACKWARD;
|
this.CommandMode(mode).open();
|
||||||
this.commandline.open(backwards ? "?" : "/", "", mode);
|
|
||||||
|
|
||||||
if (this.rangeFind && this.rangeFind.window.get() === this.window)
|
if (this.rangeFind && this.rangeFind.window.get() === this.window)
|
||||||
this.rangeFind.reset();
|
this.rangeFind.reset();
|
||||||
this.find("", backwards);
|
this.find("", mode === this.modes.FIND_BACKWARD);
|
||||||
},
|
},
|
||||||
|
|
||||||
bootstrap: function (str, backward) {
|
bootstrap: function (str, backward) {
|
||||||
@@ -119,8 +120,12 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
this.rangeFind.focus();
|
this.rangeFind.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
// Called when the user types a key in the find dialog. Triggers a find attempt if 'incfind' is set
|
onCancel: function () {
|
||||||
onKeyPress: function (command) {
|
if (this.rangeFind)
|
||||||
|
this.rangeFind.cancel();
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange: function (command) {
|
||||||
if (this.options["incfind"]) {
|
if (this.options["incfind"]) {
|
||||||
command = this.bootstrap(command);
|
command = this.bootstrap(command);
|
||||||
this.rangeFind.find(command);
|
this.rangeFind.find(command);
|
||||||
@@ -138,13 +143,6 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
this.rangeFind.focus();
|
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
|
* Highlights all occurrences of the last sought for string in the
|
||||||
* current buffer.
|
* current buffer.
|
||||||
@@ -163,12 +161,12 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
}, {
|
}, {
|
||||||
/* Must come before commandline. */
|
|
||||||
modes: function (dactyl, modules, window) {
|
modes: function (dactyl, modules, window) {
|
||||||
const { modes } = modules;
|
const { commandline, modes } = modules;
|
||||||
modes.addMode("FIND", {
|
modes.addMode("FIND", {
|
||||||
extended: true,
|
extended: true,
|
||||||
description: "Find mode, active when typing search input",
|
description: "Find mode, active when typing search input",
|
||||||
|
bases: [modes.COMMAND_LINE],
|
||||||
input: true
|
input: true
|
||||||
});
|
});
|
||||||
modes.addMode("FIND_FORWARD", {
|
modes.addMode("FIND_FORWARD", {
|
||||||
@@ -176,22 +174,13 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
description: "Forward Find mode, active when typing search input",
|
description: "Forward Find mode, active when typing search input",
|
||||||
bases: [modes.FIND],
|
bases: [modes.FIND],
|
||||||
input: true
|
input: true
|
||||||
}, { history: "search" });
|
});
|
||||||
modes.addMode("FIND_BACKWARD", {
|
modes.addMode("FIND_BACKWARD", {
|
||||||
extended: true,
|
extended: true,
|
||||||
description: "Backward Find mode, active when typing search input",
|
description: "Backward Find mode, active when typing search input",
|
||||||
bases: [modes.FIND],
|
bases: [modes.FIND],
|
||||||
input: true
|
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) {
|
commands: function (dactyl, modules, window) {
|
||||||
const { commands, rangefinder } = modules;
|
const { commands, rangefinder } = modules;
|
||||||
@@ -200,6 +189,22 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
function () { rangefinder.clear(); },
|
function () { rangefinder.clear(); },
|
||||||
{ argCount: "0" });
|
{ 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) {
|
mappings: function (dactyl, modules, window) {
|
||||||
const { buffer, config, mappings, modes, rangefinder } = modules;
|
const { buffer, config, mappings, modes, rangefinder } = modules;
|
||||||
var myModes = config.browserModes.concat([modes.CARET]);
|
var myModes = config.browserModes.concat([modes.CARET]);
|
||||||
|
|||||||
@@ -61,6 +61,27 @@ var IO = Module("io", {
|
|||||||
services.downloadManager.addListener(this.downloadListener);
|
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() {
|
destroy: function destroy() {
|
||||||
services.downloadManager.removeListener(this.downloadListener);
|
services.downloadManager.removeListener(this.downloadListener);
|
||||||
for (let [, plugin] in Iterator(plugins.contexts))
|
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) {
|
options: function (dactyl, modules, window) {
|
||||||
const { options } = modules;
|
const { options } = modules;
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ var Overlay = Module("Overlay", {
|
|||||||
"io",
|
"io",
|
||||||
"mappings",
|
"mappings",
|
||||||
"marks",
|
"marks",
|
||||||
|
"mow",
|
||||||
"options",
|
"options",
|
||||||
"statusline",
|
"statusline",
|
||||||
"styles",
|
"styles",
|
||||||
@@ -203,12 +204,14 @@ var Overlay = Module("Overlay", {
|
|||||||
modules.loaded = loaded;
|
modules.loaded = loaded;
|
||||||
|
|
||||||
function init(module) {
|
function init(module) {
|
||||||
|
let name = module.constructor.className;
|
||||||
|
|
||||||
function init(func, mod)
|
function init(func, mod)
|
||||||
function () defineModule.time(module.className || module.constructor.className, mod,
|
function () defineModule.time(module.className || module.constructor.className, mod,
|
||||||
func, module,
|
func, modules[name],
|
||||||
modules.dactyl, modules, window);
|
modules.dactyl, modules, window);
|
||||||
|
|
||||||
set.add(loaded, module.constructor.className);
|
set.add(loaded, name);
|
||||||
for (let [mod, func] in Iterator(module.INIT)) {
|
for (let [mod, func] in Iterator(module.INIT)) {
|
||||||
if (mod in loaded)
|
if (mod in loaded)
|
||||||
init(func, mod)();
|
init(func, mod)();
|
||||||
@@ -240,7 +243,7 @@ var Overlay = Module("Overlay", {
|
|||||||
|
|
||||||
defineModule.loadLog.push("Load" + (isString(prereq) ? " " + prereq + " dependency: " : ": ") + module.className);
|
defineModule.loadLog.push("Load" + (isString(prereq) ? " " + prereq + " dependency: " : ": ") + module.className);
|
||||||
if (frame && frame.filename)
|
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];
|
delete modules[module.className];
|
||||||
modules[module.className] = defineModule.time(module.className, "init", module);
|
modules[module.className] = defineModule.time(module.className, "init", module);
|
||||||
|
|||||||
@@ -311,8 +311,8 @@ var Styles = Module("Styles", {
|
|||||||
matchFilter: function (filter) {
|
matchFilter: function (filter) {
|
||||||
if (filter === "*")
|
if (filter === "*")
|
||||||
var test = function test(uri) true;
|
var test = function test(uri) true;
|
||||||
else if (filter[0] == "^") {
|
else if (filter[0] === "^") {
|
||||||
let re = RegExp(filter[0]);
|
let re = RegExp(filter);
|
||||||
test = function test(uri) re.test(uri.spec);
|
test = function test(uri) re.test(uri.spec);
|
||||||
}
|
}
|
||||||
else if (/[*]$/.test(filter)) {
|
else if (/[*]$/.test(filter)) {
|
||||||
@@ -331,9 +331,12 @@ var Styles = Module("Styles", {
|
|||||||
|
|
||||||
propertyIter: function (str, always) {
|
propertyIter: function (str, always) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let match in this.propertyPattern.iterate(str))
|
for (let match in this.propertyPattern.iterate(str)) {
|
||||||
if (always && !i++ || match[0] && match.value)
|
if (match.value || always && match.name || match.wholeMatch === match.preSpace && always && !i++)
|
||||||
yield match;
|
yield match;
|
||||||
|
if (!/;/.test(match.postSpace))
|
||||||
|
break;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
propertyPattern: util.regexp(<![CDATA[
|
propertyPattern: util.regexp(<![CDATA[
|
||||||
|
|||||||
@@ -1529,8 +1529,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
this.yielders--;
|
this.yielders--;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
waitFor: function waitFor(test, self, interruptable) {
|
waitFor: function waitFor(test, self, timeout, interruptable) {
|
||||||
while (!test.call(self))
|
let end = timeout && Date.now() + timeout;
|
||||||
|
while ((!end || Date.now() < end) && !test.call(self))
|
||||||
this.threadYield(false, interruptable);
|
this.threadYield(false, interruptable);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
- shared-modules should be synced with http://hg.mozilla.org/qa/mozmill-tests/
|
|
||||||
Reference in New Issue
Block a user