mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-21 15:24:11 +01:00
Make Teledactyl minimally functional, albeit with quite a lot of errors on the console.
This commit is contained in:
@@ -1523,7 +1523,7 @@ var Buffer = Module("buffer", {
|
||||
"Go to the root of the website",
|
||||
function () { buffer.climbUrlPath(-1); });
|
||||
|
||||
mappings.add(modes.COMMAND, [".", "<repeat-key>"],
|
||||
mappings.add([modes.COMMAND], [".", "<repeat-key>"],
|
||||
"Repeat the last key event",
|
||||
function (args) {
|
||||
if (mappings.repeat) {
|
||||
@@ -1533,54 +1533,54 @@ var Buffer = Module("buffer", {
|
||||
},
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["i", "<Insert>"],
|
||||
mappings.add([modes.COMMAND], ["i", "<Insert>"],
|
||||
"Start caret mode",
|
||||
function () { modes.push(modes.CARET); });
|
||||
|
||||
mappings.add(modes.COMMAND, ["<C-c>"],
|
||||
mappings.add([modes.COMMAND], ["<C-c>"],
|
||||
"Stop loading the current web page",
|
||||
function () { ex.stop(); });
|
||||
|
||||
// scrolling
|
||||
mappings.add(modes.COMMAND, ["j", "<Down>", "<C-e>", "<scroll-down-line>"],
|
||||
mappings.add([modes.COMMAND], ["j", "<Down>", "<C-e>", "<scroll-down-line>"],
|
||||
"Scroll document down",
|
||||
function (args) { buffer.scrollVertical("lines", Math.max(args.count, 1)); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["k", "<Up>", "<C-y>", "<scroll-up-line>"],
|
||||
mappings.add([modes.COMMAND], ["k", "<Up>", "<C-y>", "<scroll-up-line>"],
|
||||
"Scroll document up",
|
||||
function (args) { buffer.scrollVertical("lines", -Math.max(args.count, 1)); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, dactyl.has("mail") ? ["h", "<scroll-left-column>"] : ["h", "<Left>", "<scroll-left-column>"],
|
||||
mappings.add([modes.COMMAND], dactyl.has("mail") ? ["h", "<scroll-left-column>"] : ["h", "<Left>", "<scroll-left-column>"],
|
||||
"Scroll document to the left",
|
||||
function (args) { buffer.scrollHorizontal("columns", -Math.max(args.count, 1)); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, dactyl.has("mail") ? ["l", "<scroll-right-column>"] : ["l", "<Right>", "<scroll-right-column>"],
|
||||
mappings.add([modes.COMMAND], dactyl.has("mail") ? ["l", "<scroll-right-column>"] : ["l", "<Right>", "<scroll-right-column>"],
|
||||
"Scroll document to the right",
|
||||
function (args) { buffer.scrollHorizontal("columns", Math.max(args.count, 1)); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["0", "^", "<scroll-begin>"],
|
||||
mappings.add([modes.COMMAND], ["0", "^", "<scroll-begin>"],
|
||||
"Scroll to the absolute left of the document",
|
||||
function () { buffer.scrollToPercent(0, null); });
|
||||
|
||||
mappings.add(modes.COMMAND, ["$", "<scroll-end>"],
|
||||
mappings.add([modes.COMMAND], ["$", "<scroll-end>"],
|
||||
"Scroll to the absolute right of the document",
|
||||
function () { buffer.scrollToPercent(100, null); });
|
||||
|
||||
mappings.add(modes.COMMAND, ["gg", "<Home>"],
|
||||
mappings.add([modes.COMMAND], ["gg", "<Home>"],
|
||||
"Go to the top of the document",
|
||||
function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 0); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["G", "<End>"],
|
||||
mappings.add([modes.COMMAND], ["G", "<End>"],
|
||||
"Go to the end of the document",
|
||||
function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 100); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["%", "<scroll-percent>"],
|
||||
mappings.add([modes.COMMAND], ["%", "<scroll-percent>"],
|
||||
"Scroll to {count} percent of the document",
|
||||
function (args) {
|
||||
dactyl.assert(args.count > 0 && args.count <= 100);
|
||||
@@ -1588,59 +1588,59 @@ var Buffer = Module("buffer", {
|
||||
},
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["<C-d>", "<scroll-down>"],
|
||||
mappings.add([modes.COMMAND], ["<C-d>", "<scroll-down>"],
|
||||
"Scroll window downwards in the buffer",
|
||||
function (args) { buffer._scrollByScrollSize(args.count, true); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["<C-u>", "<scroll-up>"],
|
||||
mappings.add([modes.COMMAND], ["<C-u>", "<scroll-up>"],
|
||||
"Scroll window upwards in the buffer",
|
||||
function (args) { buffer._scrollByScrollSize(args.count, false); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["<C-b>", "<PageUp>", "<S-Space>", "<scroll-page-up>"],
|
||||
mappings.add([modes.COMMAND], ["<C-b>", "<PageUp>", "<S-Space>", "<scroll-page-up>"],
|
||||
"Scroll up a full page",
|
||||
function (args) { buffer.scrollVertical("pages", -Math.max(args.count, 1)); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["<C-f>", "<PageDown>", "<Space>", "<scroll-page-down>"],
|
||||
mappings.add([modes.COMMAND], ["<C-f>", "<PageDown>", "<Space>", "<scroll-page-down>"],
|
||||
"Scroll down a full page",
|
||||
function (args) { buffer.scrollVertical("pages", Math.max(args.count, 1)); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["]f", "<previous-frame>"],
|
||||
mappings.add([modes.COMMAND], ["]f", "<previous-frame>"],
|
||||
"Focus next frame",
|
||||
function (args) { buffer.shiftFrameFocus(Math.max(args.count, 1)); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["[f", "<next-frame>"],
|
||||
mappings.add([modes.COMMAND], ["[f", "<next-frame>"],
|
||||
"Focus previous frame",
|
||||
function (args) { buffer.shiftFrameFocus(-Math.max(args.count, 1)); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["]]", "<next-page>"],
|
||||
mappings.add([modes.COMMAND], ["]]", "<next-page>"],
|
||||
"Follow the link labeled 'next' or '>' if it exists",
|
||||
function (args) {
|
||||
buffer.findLink("next", options["nextpattern"], (args.count || 1) - 1, true);
|
||||
},
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["[[", "<previous-page>"],
|
||||
mappings.add([modes.COMMAND], ["[[", "<previous-page>"],
|
||||
"Follow the link labeled 'prev', 'previous' or '<' if it exists",
|
||||
function (args) {
|
||||
buffer.findLink("previous", options["previouspattern"], (args.count || 1) - 1, true);
|
||||
},
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["gf", "<view-source>"],
|
||||
mappings.add([modes.COMMAND], ["gf", "<view-source>"],
|
||||
"Toggle between rendered and source view",
|
||||
function () { buffer.viewSource(null, false); });
|
||||
|
||||
mappings.add(modes.COMMAND, ["gF", "<view-source-externally>"],
|
||||
mappings.add([modes.COMMAND], ["gF", "<view-source-externally>"],
|
||||
"View source with an external editor",
|
||||
function () { buffer.viewSource(null, true); });
|
||||
|
||||
mappings.add(modes.COMMAND, ["gi", "<focus-input>"],
|
||||
mappings.add([modes.COMMAND], ["gi", "<focus-input>"],
|
||||
"Focus last used input field",
|
||||
function (args) {
|
||||
let elem = buffer.lastInputField;
|
||||
@@ -1672,15 +1672,15 @@ var Buffer = Module("buffer", {
|
||||
},
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["gP"],
|
||||
"Open (put) a URL based on the current clipboard contents in a new buffer",
|
||||
mappings.add([modes.COMMAND], ["gP"],
|
||||
"Open (]put) a URL based on the current clipboard contents in a new buffer",
|
||||
function () {
|
||||
let url = dactyl.clipboardRead();
|
||||
dactyl.assert(url, "No clipboard data");
|
||||
dactyl.open(url, { from: "paste", where: dactyl.NEW_TAB, background: true });
|
||||
});
|
||||
|
||||
mappings.add(modes.COMMAND, ["p", "<MiddleMouse>", "<open-clipboard-url>"],
|
||||
mappings.add([modes.COMMAND], ["p", "<MiddleMouse>", "<open-clipboard-url>"],
|
||||
"Open (put) a URL based on the current clipboard contents in the current buffer",
|
||||
function () {
|
||||
let url = dactyl.clipboardRead();
|
||||
@@ -1688,7 +1688,7 @@ var Buffer = Module("buffer", {
|
||||
dactyl.open(url);
|
||||
});
|
||||
|
||||
mappings.add(modes.COMMAND, ["P", "<tab-open-clipboard-url>"],
|
||||
mappings.add([modes.COMMAND], ["P", "<tab-open-clipboard-url>"],
|
||||
"Open (put) a URL based on the current clipboard contents in a new buffer",
|
||||
function () {
|
||||
let url = dactyl.clipboardRead();
|
||||
@@ -1697,16 +1697,16 @@ var Buffer = Module("buffer", {
|
||||
});
|
||||
|
||||
// reloading
|
||||
mappings.add(modes.COMMAND, ["r", "<reload>"],
|
||||
mappings.add([modes.COMMAND], ["r", "<reload>"],
|
||||
"Reload the current web page",
|
||||
function () { tabs.reload(tabs.getTab(), false); });
|
||||
|
||||
mappings.add(modes.COMMAND, ["R", "<full-reload>"],
|
||||
mappings.add([modes.COMMAND], ["R", "<full-reload>"],
|
||||
"Reload while skipping the cache",
|
||||
function () { tabs.reload(tabs.getTab(), true); });
|
||||
|
||||
// yanking
|
||||
mappings.add(modes.COMMAND, ["Y", "<yank-word>"],
|
||||
mappings.add([modes.COMMAND], ["Y", "<yank-word>"],
|
||||
"Copy selected text or current word",
|
||||
function () {
|
||||
let sel = buffer.currentWord;
|
||||
@@ -1715,62 +1715,62 @@ var Buffer = Module("buffer", {
|
||||
});
|
||||
|
||||
// zooming
|
||||
mappings.add(modes.COMMAND, ["zi", "+", "<text-zoom-in>"],
|
||||
mappings.add([modes.COMMAND], ["zi", "+", "<text-zoom-in>"],
|
||||
"Enlarge text zoom of current web page",
|
||||
function (args) { buffer.zoomIn(Math.max(args.count, 1), false); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["zm", "<text-zoom-more>"],
|
||||
mappings.add([modes.COMMAND], ["zm", "<text-zoom-more>"],
|
||||
"Enlarge text zoom of current web page by a larger amount",
|
||||
function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, false); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["zo", "-", "<text-zoom-out>"],
|
||||
mappings.add([modes.COMMAND], ["zo", "-", "<text-zoom-out>"],
|
||||
"Reduce text zoom of current web page",
|
||||
function (args) { buffer.zoomOut(Math.max(args.count, 1), false); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["zr", "<text-zoom-reduce>"],
|
||||
mappings.add([modes.COMMAND], ["zr", "<text-zoom-reduce>"],
|
||||
"Reduce text zoom of current web page by a larger amount",
|
||||
function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, false); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["zz", "<text-zoom>"],
|
||||
mappings.add([modes.COMMAND], ["zz", "<text-zoom>"],
|
||||
"Set text zoom value of current web page",
|
||||
function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, false); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["ZI", "zI", "<full-zoom-in>"],
|
||||
mappings.add([modes.COMMAND], ["ZI", "zI", "<full-zoom-in>"],
|
||||
"Enlarge full zoom of current web page",
|
||||
function (args) { buffer.zoomIn(Math.max(args.count, 1), true); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["ZM", "zM", "<full-zoom-more>"],
|
||||
mappings.add([modes.COMMAND], ["ZM", "zM", "<full-zoom-more>"],
|
||||
"Enlarge full zoom of current web page by a larger amount",
|
||||
function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, true); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["ZO", "zO", "<full-zoom-out>"],
|
||||
mappings.add([modes.COMMAND], ["ZO", "zO", "<full-zoom-out>"],
|
||||
"Reduce full zoom of current web page",
|
||||
function (args) { buffer.zoomOut(Math.max(args.count, 1), true); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["ZR", "zR", "<full-zoom-reduce>"],
|
||||
mappings.add([modes.COMMAND], ["ZR", "zR", "<full-zoom-reduce>"],
|
||||
"Reduce full zoom of current web page by a larger amount",
|
||||
function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, true); },
|
||||
{ count: true });
|
||||
|
||||
mappings.add(modes.COMMAND, ["zZ", "<full-zoom>"],
|
||||
mappings.add([modes.COMMAND], ["zZ", "<full-zoom>"],
|
||||
"Set full zoom value of current web page",
|
||||
function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, true); },
|
||||
{ count: true });
|
||||
|
||||
// page info
|
||||
mappings.add(modes.COMMAND, ["<C-g>", "<page-info>"],
|
||||
mappings.add([modes.COMMAND], ["<C-g>", "<page-info>"],
|
||||
"Print the current file name",
|
||||
function () { buffer.showPageInfo(false); });
|
||||
|
||||
mappings.add(modes.COMMAND, ["g<C-g>", "<more-page-info>"],
|
||||
mappings.add([modes.COMMAND], ["g<C-g>", "<more-page-info>"],
|
||||
"Print file information",
|
||||
function () { buffer.showPageInfo(true); });
|
||||
},
|
||||
|
||||
@@ -1193,7 +1193,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
if (urls.length == 0)
|
||||
return;
|
||||
|
||||
let browser = config.browser;
|
||||
let browser = config.tabbrowser;
|
||||
function open(urls, where) {
|
||||
try {
|
||||
let url = Array.concat(urls)[0];
|
||||
@@ -1214,7 +1214,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
case dactyl.NEW_WINDOW:
|
||||
let win = window.openDialog(document.documentURI, "_blank", "chrome,all,dialog=no");
|
||||
util.waitFor(function () win.document.readyState === "complete");
|
||||
browser = win.getBrowser();
|
||||
browser = win.dactyl && win.dactyl.modules.config.tabbrowser || win.getBrowser();
|
||||
// FALLTHROUGH
|
||||
case dactyl.CURRENT_TAB:
|
||||
browser.loadURIWithFlags(url, flags, null, null, postdata);
|
||||
@@ -1278,12 +1278,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
return url.replace(/\s+/g, "");
|
||||
|
||||
// Check for a matching search keyword.
|
||||
let searchURL = bookmarks.getSearchURL(url, false);
|
||||
let searchURL = loaded.bookmarks && bookmarks.getSearchURL(url, false);
|
||||
if (searchURL)
|
||||
return searchURL;
|
||||
|
||||
// If it looks like URL-ish (foo.com/bar), let Gecko figure it out.
|
||||
if (this.urlish.test(url))
|
||||
if (this.urlish.test(url) || !loaded.bookmarks)
|
||||
return util.createURI(url).spec;
|
||||
|
||||
// Pass it off to the default search engine or, failing
|
||||
@@ -1626,9 +1626,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
document.title = document.title.replace(RegExp("(.*)" + util.regexp.escape(old)), "$1" + current);
|
||||
}
|
||||
|
||||
// TODO: remove this FF3.5 test when we no longer support 3.0
|
||||
// : make this a config feature
|
||||
if (services.privateBrowsing) {
|
||||
if (services.has("privateBrowsing")) {
|
||||
let oldValue = win.getAttribute("titlemodifier_normal");
|
||||
let suffix = win.getAttribute("titlemodifier_privatebrowsing").substr(oldValue.length);
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
*/
|
||||
var Map = Class("Map", {
|
||||
init: function (modes, keys, description, action, extraInfo) {
|
||||
modes = Array.concat(modes).map(function (m) isObject(m) ? m.mask : m);
|
||||
modes = Array.concat(modes);
|
||||
if (!modes.every(util.identity))
|
||||
throw Error("Invalid modes");
|
||||
throw TypeError("Invalid modes: " + modes);
|
||||
|
||||
this.id = ++Map.id;
|
||||
this.modes = modes;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/** @scope modules */
|
||||
|
||||
var StatusLine = Module("statusline", {
|
||||
init: function () {
|
||||
init: function init() {
|
||||
this._statusLine = document.getElementById("status-bar");
|
||||
this.statusBar = document.getElementById("addon-bar") || this._statusLine;
|
||||
this.statusBar.collapsed = true;
|
||||
@@ -23,6 +23,8 @@ var StatusLine = Module("statusline", {
|
||||
#addon-bar > xul|toolbarspring { visibility: collapse; }
|
||||
]]></css>);
|
||||
|
||||
util.overlayWindow(window, { append: <><statusbar id="status-bar" ordinal="0"/></> });
|
||||
|
||||
highlight.loadCSS(util.compileMacro(<![CDATA[
|
||||
!AddonBar;#addon-bar {
|
||||
padding-left: 0 !important;
|
||||
@@ -50,7 +52,7 @@ var StatusLine = Module("statusline", {
|
||||
let prepend = <e4x xmlns={XUL} xmlns:dactyl={NS}>
|
||||
<button id="appmenu-button" label="" image="chrome://branding/content/icon16.png" highlight="AppmenuButton" />
|
||||
<toolbarbutton id="appmenu-toolbar-button" label="" image="chrome://branding/content/icon16.png" />
|
||||
<statusbar id="status-bar" highlight="StatusLine" ordinal="0">
|
||||
<statusbar id="status-bar" highlight="StatusLine">
|
||||
<!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
|
||||
<hbox key="container" hidden="false" align="center" flex="1">
|
||||
<stack orient="horizontal" align="stretch" flex="1" highlight="CmdLine StatusCmdLine" class="dactyl-container">
|
||||
@@ -82,7 +84,10 @@ var StatusLine = Module("statusline", {
|
||||
prepend: prepend.elements()
|
||||
});
|
||||
|
||||
this.security = content.document.dactylSecurity || "insecure";
|
||||
try {
|
||||
this.security = content.document.dactylSecurity || "insecure";
|
||||
}
|
||||
catch (e) {}
|
||||
},
|
||||
|
||||
get visible() !this.statusBar.collapsed && !this.statusBar.hidden,
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
var Tabs = Module("tabs", {
|
||||
init: function () {
|
||||
this._alternates = [config.tabbrowser.mCurrentTab, null];
|
||||
|
||||
// used for the "gb" and "gB" mappings to remember the last :buffer[!] command
|
||||
this._lastBufferSwitchArgs = "";
|
||||
this._lastBufferSwitchSpecial = true;
|
||||
@@ -27,9 +25,9 @@ var Tabs = Module("tabs", {
|
||||
config.tabStrip.collapsed = true;
|
||||
|
||||
this.tabStyle = styles.system.add("tab-strip-hiding", config.styleableChrome,
|
||||
(config.tabStrip.id ? "#" + config.tabStrip.id : ".tabbrowser-strip") +
|
||||
"{ visibility: collapse; }",
|
||||
false, true);
|
||||
(config.tabStrip.id ? "#" + config.tabStrip.id : ".tabbrowser-strip") +
|
||||
"{ visibility: collapse; }",
|
||||
false, true);
|
||||
|
||||
dactyl.commands["tabs.select"] = function (event) {
|
||||
tabs.select(event.originalTarget.getAttribute("identifier"));
|
||||
@@ -47,6 +45,8 @@ var Tabs = Module("tabs", {
|
||||
});
|
||||
},
|
||||
|
||||
_alternates: Class.memoize(function () [config.tabbrowser.mCurrentTab, null]),
|
||||
|
||||
cleanup: function cleanup() {
|
||||
for (let [i, tab] in Iterator(this.allTabs)) {
|
||||
let node = function node(class_) document.getAnonymousElementByAttribute(tab, "class", class_);
|
||||
|
||||
@@ -465,7 +465,7 @@ var Addons = Module("addons", {
|
||||
}
|
||||
});
|
||||
|
||||
if (!("nsIExtensionManager" in Ci) || !services.extensionManager)
|
||||
if (!services.has("extensionManager"))
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
else
|
||||
var AddonManager = {
|
||||
|
||||
@@ -873,7 +873,7 @@ Class.prototype = {
|
||||
return services.Timer(timeout_notify, timeout || 0, services.Timer.TYPE_ONE_SHOT);
|
||||
}
|
||||
};
|
||||
memoize(Class.prototype, "closure", function closure() {
|
||||
Class.makeClosure = function makeClosure() {
|
||||
const self = this;
|
||||
function closure(fn) function _closure() {
|
||||
try {
|
||||
@@ -896,7 +896,8 @@ memoize(Class.prototype, "closure", function closure() {
|
||||
});
|
||||
}, this);
|
||||
return closure;
|
||||
});
|
||||
};
|
||||
memoize(Class.prototype, "closure", Class.makeClosure);
|
||||
|
||||
/**
|
||||
* A base class generator for classes which implement XPCOM interfaces.
|
||||
|
||||
@@ -151,6 +151,8 @@ var ConfigBase = Class("ConfigBase", {
|
||||
return version;
|
||||
}),
|
||||
|
||||
get fileExt() this.name.slice(0, -5),
|
||||
|
||||
dtd: memoize({
|
||||
get name() config.name,
|
||||
get home() "http://dactyl.sourceforge.net/",
|
||||
@@ -243,8 +245,6 @@ var ConfigBase = Class("ConfigBase", {
|
||||
*/
|
||||
autocommands: {},
|
||||
|
||||
commandContainer: "browser-bottombox",
|
||||
|
||||
/**
|
||||
* @property {Object} A map of :command-complete option values to completer
|
||||
* function names.
|
||||
@@ -350,6 +350,8 @@ var ConfigBase = Class("ConfigBase", {
|
||||
*/
|
||||
scripts: [],
|
||||
|
||||
sidebars: {},
|
||||
|
||||
/**
|
||||
* @property {string} The leaf name of any temp files created by
|
||||
* {@link io.createTempFile}.
|
||||
|
||||
@@ -166,8 +166,10 @@ var RangeFinder = Module("rangefinder", {
|
||||
}
|
||||
}, {
|
||||
}, {
|
||||
modes: function (dactyl, modules, window) {
|
||||
modes: function initModes(dactyl, modules, window) {
|
||||
const { modes } = modules;
|
||||
initModes.superapply("commandline", arguments);
|
||||
|
||||
modes.addMode("FIND", {
|
||||
description: "Find mode, active when typing search input",
|
||||
bases: [modes.COMMAND_LINE],
|
||||
@@ -181,14 +183,14 @@ var RangeFinder = Module("rangefinder", {
|
||||
bases: [modes.FIND]
|
||||
});
|
||||
},
|
||||
commands: function (dactyl, modules, window) {
|
||||
commands: function initCommands(dactyl, modules, window) {
|
||||
const { commands, rangefinder } = modules;
|
||||
commands.add(["noh[lfind]"],
|
||||
"Remove the find highlighting",
|
||||
function () { rangefinder.clear(); },
|
||||
{ argCount: "0" });
|
||||
},
|
||||
commandline: function (dactyl, modules, window) {
|
||||
commandline: function initCommandline(dactyl, modules, window) {
|
||||
const { rangefinder } = modules;
|
||||
rangefinder.CommandMode = Class("CommandFindMode", modules.CommandMode, {
|
||||
init: function init(mode) {
|
||||
|
||||
@@ -69,7 +69,10 @@ var Option = Class("Option", {
|
||||
if (extraInfo)
|
||||
update(this, extraInfo);
|
||||
|
||||
if (arguments.length > 3) {
|
||||
if (set.has(this.modules.config.defaults, this.name))
|
||||
defaultValue = this.modules.config.defaults[this.name];
|
||||
|
||||
if (defaultValue !== undefined) {
|
||||
if (this.type == "string")
|
||||
defaultValue = Commands.quote(defaultValue);
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ var ModuleBase = Class("ModuleBase", {
|
||||
});
|
||||
|
||||
var Overlay = Module("Overlay", {
|
||||
init: function () {
|
||||
init: function init() {
|
||||
services["dactyl:"]; // Hack. Force module initialization.
|
||||
|
||||
config.loadStyles();
|
||||
|
||||
util.overlayWindow(config.overlayChrome, function (window) ({
|
||||
init: function (document) {
|
||||
util.overlayWindow(config.overlayChrome, function overlay(window) ({
|
||||
init: function onInit(document) {
|
||||
/**
|
||||
* @constructor Module
|
||||
*
|
||||
@@ -187,48 +187,20 @@ var Overlay = Module("Overlay", {
|
||||
"mow",
|
||||
"statusline"
|
||||
].forEach(function (name) defineModule.time("load", name, modules.load, modules, name));
|
||||
|
||||
config.scripts.forEach(modules.load);
|
||||
}, this);
|
||||
},
|
||||
load: function (document) {
|
||||
load: function onLoad(document) {
|
||||
// This is getting to be horrible. --Kris
|
||||
|
||||
var { modules, Module } = window.dactyl.modules;
|
||||
delete window.dactyl;
|
||||
|
||||
Module.list.forEach(function (module) {
|
||||
modules.__defineGetter__(module.className, function () {
|
||||
delete modules[module.className];
|
||||
return load(module.className, null, Components.stack.caller);
|
||||
});
|
||||
});
|
||||
|
||||
const start = Date.now();
|
||||
const deferredInit = { load: [] };
|
||||
const deferredInit = { load: {} };
|
||||
const seen = set();
|
||||
const loaded = set();
|
||||
modules.loaded = loaded;
|
||||
|
||||
function init(module) {
|
||||
let name = module.constructor.className;
|
||||
|
||||
function init(func, mod)
|
||||
function () defineModule.time(module.className || module.constructor.className, mod,
|
||||
func, modules[name],
|
||||
modules.dactyl, modules, window);
|
||||
|
||||
set.add(loaded, name);
|
||||
for (let [mod, func] in Iterator(module.INIT)) {
|
||||
if (mod in loaded)
|
||||
init(func, mod)();
|
||||
else {
|
||||
deferredInit[mod] = deferredInit[mod] || [];
|
||||
deferredInit[mod].push(init(func, mod));
|
||||
}
|
||||
}
|
||||
for (let [, fn] in iter(deferredInit[module.constructor.className] || []))
|
||||
fn();
|
||||
}
|
||||
|
||||
function load(module, prereq, frame) {
|
||||
if (isString(module)) {
|
||||
if (!Module.constructors.hasOwnProperty(module))
|
||||
@@ -255,8 +227,6 @@ var Overlay = Module("Overlay", {
|
||||
loaded[module.className] = true;
|
||||
|
||||
frob(module.className);
|
||||
|
||||
// init(modules[module.className]);
|
||||
}
|
||||
catch (e) {
|
||||
util.dump("Loading " + (module && module.className) + ":");
|
||||
@@ -265,36 +235,48 @@ var Overlay = Module("Overlay", {
|
||||
return modules[module.className];
|
||||
}
|
||||
|
||||
Module.list.forEach(function (mod) {
|
||||
Object.keys(mod.prototype.INIT).forEach(function (name) {
|
||||
deferredInit[name] = deferredInit[name] || [];
|
||||
deferredInit[name].push(function () {
|
||||
// util.dump("INIT: " + mod.className + ":" + name);
|
||||
defineModule.time(mod.className, name,
|
||||
name, mod.prototype.INIT,
|
||||
function deferInit(name, INIT, mod) {
|
||||
let init = deferredInit[name] = deferredInit[name] || {};
|
||||
let className = mod.className || mod.constructor.className;
|
||||
|
||||
init[className] = function callee() {
|
||||
if (!callee.frobbed)
|
||||
defineModule.time(className, name, INIT[name], mod,
|
||||
modules.dactyl, modules, window);
|
||||
});
|
||||
callee.frobbed = true;
|
||||
};
|
||||
|
||||
if (name !== "init" && name !== "load")
|
||||
INIT[name].superapply = function (name) { init[name](); };
|
||||
}
|
||||
|
||||
function frobModules() {
|
||||
Module.list.forEach(function frobModule(mod) {
|
||||
if (!mod.frobbed) {
|
||||
modules.__defineGetter__(mod.className, function () {
|
||||
delete modules[mod.className];
|
||||
return load(mod.className, null, Components.stack.caller);
|
||||
});
|
||||
Object.keys(mod.prototype.INIT).forEach(function (name) { deferInit(name, mod.prototype.INIT, mod); });
|
||||
}
|
||||
mod.frobbed = true;
|
||||
});
|
||||
});
|
||||
defineModule.modules.forEach(function (mod) {
|
||||
}
|
||||
defineModule.modules.forEach(function defModule(mod) {
|
||||
let names = set(Object.keys(mod.INIT));
|
||||
if ("init" in mod.INIT)
|
||||
set.add(names, "init");
|
||||
|
||||
keys(names).forEach(function (name) {
|
||||
deferredInit[name] = deferredInit[name] || [];
|
||||
deferredInit[name].push(function () {
|
||||
// util.dump("INIT: " + mod.constructor.className + ":" + name);
|
||||
defineModule.time(mod.constructor.className, name,
|
||||
mod.INIT[name], mod,
|
||||
modules.dactyl, modules, window);
|
||||
});
|
||||
});
|
||||
keys(names).forEach(function (name) { deferInit(name, mod.INIT, mod); });
|
||||
});
|
||||
|
||||
function frob(name) { (deferredInit[name] || []).forEach(call); }
|
||||
function frob(name) { values(deferredInit[name] || {}).forEach(call); }
|
||||
|
||||
frobModules();
|
||||
frob("init");
|
||||
modules.config.scripts.forEach(modules.load);
|
||||
frobModules();
|
||||
|
||||
defineModule.modules.forEach(function ({ lazyInit, constructor: { className } }) {
|
||||
if (!lazyInit) {
|
||||
frob(className);
|
||||
@@ -316,10 +298,13 @@ var Overlay = Module("Overlay", {
|
||||
|
||||
modules.events.listen(window, "unload", function onUnload() {
|
||||
window.removeEventListener("unload", onUnload.wrapped, false);
|
||||
|
||||
for (let prop in properties(modules)) {
|
||||
let mod = Object.getOwnPropertyDescriptor(modules, prop).value;
|
||||
|
||||
if (mod instanceof ModuleBase || mod && mod.isLocalModule) {
|
||||
mod.stale = true;
|
||||
|
||||
if ("destroy" in mod)
|
||||
util.trapErrors("destroy", mod);
|
||||
}
|
||||
|
||||
@@ -114,13 +114,14 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
},
|
||||
override: true
|
||||
});
|
||||
this.addItem("host", {
|
||||
description: "All data from the given host",
|
||||
action: function (range, host) {
|
||||
if (host)
|
||||
services.privateBrowsing.removeDataFromDomain(host);
|
||||
}
|
||||
});
|
||||
if (services.has("privateBrowsing"))
|
||||
this.addItem("host", {
|
||||
description: "All data from the given host",
|
||||
action: function (range, host) {
|
||||
if (host)
|
||||
services.privateBrowsing.removeDataFromDomain(host);
|
||||
}
|
||||
});
|
||||
this.addItem("sitesettings", {
|
||||
builtin: true,
|
||||
description: "Site preferences",
|
||||
@@ -547,7 +548,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
},
|
||||
options: function (dactyl, modules) {
|
||||
const options = modules.options;
|
||||
if (services.privateBrowsing)
|
||||
if (services.has("privateBrowsing"))
|
||||
options.add(["private", "pornmode"],
|
||||
"Set the 'private browsing' option",
|
||||
"boolean", false,
|
||||
|
||||
@@ -18,7 +18,6 @@ defineModule("services", {
|
||||
*/
|
||||
var Services = Module("Services", {
|
||||
init: function () {
|
||||
this.classes = {};
|
||||
this.services = {};
|
||||
|
||||
this.add("annotation", "@mozilla.org/browser/annotation-service;1", Ci.nsIAnnotationService);
|
||||
@@ -129,6 +128,7 @@ var Services = Module("Services", {
|
||||
*/
|
||||
add: function (name, class_, ifaces, meth) {
|
||||
const self = this;
|
||||
this.services[name] = { class: class_, interfaces: Array.concat(ifaces || []) };
|
||||
if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
|
||||
throw TypeError();
|
||||
memoize(this, name, function () self._create(class_, ifaces, meth));
|
||||
@@ -164,11 +164,18 @@ var Services = Module("Services", {
|
||||
* @param {string} name The service's cache key.
|
||||
*/
|
||||
get: function (name) this[name],
|
||||
|
||||
/**
|
||||
* Returns true if the given service is available.
|
||||
*
|
||||
* @param {string} name The service's cache key.
|
||||
*/
|
||||
has: function (name) set.has(this.services, name) && this.services[name].class in Cc &&
|
||||
this.services[name].interfaces.every(function (iface) iface in Ci)
|
||||
}, {
|
||||
}, {
|
||||
javascript: function (dactyl, modules) {
|
||||
modules.JavaScript.setCompleter(this.get, [function () [[k, v] for ([k, v] in Iterator(services)) if (v instanceof Ci.nsISupports)]]);
|
||||
modules.JavaScript.setCompleter(this.create, [function () [[c, ""] for (c in services.classes)]]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1430,6 +1430,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
if (error.noTrace)
|
||||
return;
|
||||
|
||||
if (isString(error))
|
||||
error = Error(error);
|
||||
|
||||
if (Cu.reportError)
|
||||
Cu.reportError(error);
|
||||
|
||||
|
||||
@@ -156,8 +156,11 @@ statusbarpanel {
|
||||
.statusbar-resizerpanel {
|
||||
display: none;
|
||||
}
|
||||
#statusbar-display, #statusbar-progresspanel {
|
||||
#statusbar-display,
|
||||
#statusbar-progresspanel,
|
||||
#status-bar > #statusTextBox > #statusText {
|
||||
display: none;
|
||||
visibility: collapse;
|
||||
}
|
||||
|
||||
.dactyl-commandline-prompt {
|
||||
|
||||
Reference in New Issue
Block a user