1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-05 07:04:12 +01:00

Make Teledactyl minimally functional, albeit with quite a lot of errors on the console.

This commit is contained in:
Kris Maglione
2011-02-19 22:02:01 -05:00
parent b648a061c8
commit d37e8159ed
23 changed files with 373 additions and 412 deletions

View File

@@ -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); });
},

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,

View File

@@ -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_);