1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:07:59 +01:00

Import some fixes from Vimperator. Thanks anekos, teramoko, and stepnem.

This commit is contained in:
Kris Maglione
2010-09-18 03:42:48 -04:00
parent bc7cff0442
commit 508cc08a8f
10 changed files with 36 additions and 28 deletions

View File

@@ -1142,8 +1142,9 @@ const CommandLine = Module("commandline", {
// Change the completion text. // Change the completion text.
// The second line is a hack to deal with some substring // The second line is a hack to deal with some substring
// preview corner cases. // preview corner cases.
commandline.widgets.command.value = this.prefix + completion + this.suffix; let value = this.prefix + completion + this.suffix;
this.editor.selection.focusNode.textContent = commandline.widgets.command.value; commandline.widgets.command.value = value;
this.editor.selection.focusNode.textContent = value;
// Reset the caret to one position after the completion. // Reset the caret to one position after the completion.
this.caret = this.prefix.length + completion.length; this.caret = this.prefix.length + completion.length;

View File

@@ -973,11 +973,11 @@ const Commands = Module("commands", {
bookmark: "bookmark", buffer: "buffer", color: "colorScheme", bookmark: "bookmark", buffer: "buffer", color: "colorScheme",
command: "command", dialog: "dialog", dir: "directory", command: "command", dialog: "dialog", dir: "directory",
environment: "environment", event: "autocmdEvent", file: "file", environment: "environment", event: "autocmdEvent", file: "file",
help: "help", highlight: "highlightGroup", javascript: "javascript", help: "help", highlight: "highlightGroup", history: "history",
macro: "macro", mapping: "userMapping", menu: "menuItem", javascript: "javascript", macro: "macro", mapping: "userMapping",
option: "option", preference: "preference", search: "search", menu: "menuItem", option: "option", preference: "preference",
shellcmd: "shellCommand", sidebar: "sidebar", url: "url", search: "search", shellcmd: "shellCommand", sidebar: "sidebar",
usercommand: "userCommand" url: "url", usercommand: "userCommand"
}; };
// TODO: Vim allows commands to be defined without {rep} if there are {attr}s // TODO: Vim allows commands to be defined without {rep} if there are {attr}s
@@ -1018,7 +1018,7 @@ const Commands = Module("commands", {
}; };
} }
else else
completeFunc = completion[completeOptionMap[completeOpt]]; completeFunc = completion.closure[completeOptionMap[completeOpt]];
} }
let added = commands.addUserCommand([cmd], let added = commands.addUserCommand([cmd],

View File

@@ -554,8 +554,8 @@ const Editor = Module("editor", {
getAbbreviations: function (filter, lhs) { getAbbreviations: function (filter, lhs) {
// ! -> list all, on c or i ! matches too // ! -> list all, on c or i ! matches too
let searchFilter = (filter == "!") ? "!ci" : filter + "!"; let searchFilter = (filter == "!") ? "!ci" : filter + "!";
return list = [[mode, left, right] for ([left, [mode, right]] in this.abbrevs()) return [[mode, left, right] for ([left, [mode, right]] in this.abbrevs())
if (searchFilter.indexOf(mode) >= 0 && left.indexOf(lhs || "") == 0)]; if (searchFilter.indexOf(mode) >= 0 && left.indexOf(lhs || "") == 0)];
}, },
/** /**
@@ -968,11 +968,8 @@ const Editor = Module("editor", {
editor.executeCommand("cmd_copy"); editor.executeCommand("cmd_copy");
modes.set(modes.TEXTAREA); modes.set(modes.TEXTAREA);
} }
else { else
let sel = window.content.document.getSelection(); dactyl.clipboardWrite(buffer.getCurrentWord(), true);
dactyl.assert(sel);
dactyl.clipboardWrite(sel, true);
}
}); });
mappings.add([modes.VISUAL, modes.TEXTAREA], mappings.add([modes.VISUAL, modes.TEXTAREA],

View File

@@ -194,7 +194,7 @@ const Events = Module("events", {
* Replays a macro. * Replays a macro.
* *
* @param {string} The name of the macro to replay. * @param {string} The name of the macro to replay.
* @return {boolean} * @returns {boolean}
*/ */
playMacro: function (macro) { playMacro: function (macro) {
let res = false; let res = false;
@@ -411,7 +411,7 @@ const Events = Module("events", {
* <S-@> where @ is a non-case-changable, non-space character. * <S-@> where @ is a non-case-changable, non-space character.
* *
* @param {string} keys The string to parse. * @param {string} keys The string to parse.
* @return {Array[Object]} * @returns {Array[Object]}
*/ */
fromString: function (input) { fromString: function (input) {
let out = []; let out = [];

View File

@@ -604,7 +604,7 @@ const JavaScript = Module("javascript", {
options.add(["jsdebugger", "jsd"], options.add(["jsdebugger", "jsd"],
"Switch on/off jsdebugger", "Switch on/off jsdebugger",
"boolean", false, { "boolean", false, {
setter: function(value) { setter: function (value) {
if (value) if (value)
services.get("debugger").on(); services.get("debugger").on();
else else

View File

@@ -283,8 +283,8 @@ const Tabs = Module("tabs", {
/** /**
* Removes the specified <b>tab</b> from the tab list. * Removes the specified <b>tab</b> from the tab list.
* *
* @param {Object} tab * @param {Object} tab The tab to remove.
* @param {number} count * @param {number} count How many tabs to remove.
* @param {boolean} focusLeftTab Focus the tab to the left of the removed tab. * @param {boolean} focusLeftTab Focus the tab to the left of the removed tab.
* @param {number} quitOnLastTab Whether to quit if the tab being * @param {number} quitOnLastTab Whether to quit if the tab being
* deleted is the only tab in the tab list: * deleted is the only tab in the tab list:

View File

@@ -487,7 +487,7 @@ function memoize(obj, key, getter) {
* function foo(a, b, c) [a, b, c].join(" "); * function foo(a, b, c) [a, b, c].join(" ");
* curry(foo)(1, 2, 3) -> "1 2 3"; * curry(foo)(1, 2, 3) -> "1 2 3";
* curry(foo)(4)(5, 6) -> "4 5 6"; * curry(foo)(4)(5, 6) -> "4 5 6";
* curry(foo)(4)(8)(9) -> "7 8 9"; * curry(foo)(7)(8)(9) -> "7 8 9";
* *
* @param {function} fn The function to curry. * @param {function} fn The function to curry.
* @param {integer} length The number of arguments expected. * @param {integer} length The number of arguments expected.
@@ -580,7 +580,7 @@ function update(target) {
/** /**
* Extends a subclass with a superclass. The subclass's * Extends a subclass with a superclass. The subclass's
* prototype is replaced with a new object, which inherits * prototype is replaced with a new object, which inherits
* from the super class's prototype, {@see update}d with the * from the superclass's prototype, {@see update}d with the
* members of 'overrides'. * members of 'overrides'.
* *
* @param {function} subclass * @param {function} subclass
@@ -720,7 +720,7 @@ Class.prototype = {
* @param {string} name The name of the instance. * @param {string} name The name of the instance.
* @param {Object} prototype The instance prototype. * @param {Object} prototype The instance prototype.
* @param {Object} classProperties Properties to be applied to the class constructor. * @param {Object} classProperties Properties to be applied to the class constructor.
* @return {Class} * @returns {Class}
*/ */
function Module(name, prototype) { function Module(name, prototype) {
let init = callable(prototype) ? 4 : 3; let init = callable(prototype) ? 4 : 3;
@@ -755,7 +755,7 @@ else
* a fixed set of named members. Each argument should be the name of * a fixed set of named members. Each argument should be the name of
* a member in the resulting objects. These names will correspond to * a member in the resulting objects. These names will correspond to
* the arguments passed to the resultant constructor. Instances of * the arguments passed to the resultant constructor. Instances of
* the new struct may be treated vary much like arrays, and provide * the new struct may be treated very much like arrays, and provide
* many of the same methods. * many of the same methods.
* *
* const Point = Struct("x", "y", "z"); * const Point = Struct("x", "y", "z");

View File

@@ -302,10 +302,10 @@ const Highlights = Module("Highlight", {
serialize: function () [ serialize: function () [
{ {
command: this.name, command: this.name,
arguments: [k], arguments: [v.class],
literalArg: v literalArg: v.value
} }
for ([k, v] in Iterator(highlight)) for (v in Iterator(highlight))
if (v.value != v.default) if (v.value != v.default)
] ]
}); });

View File

@@ -451,6 +451,16 @@ const Util = Module("Util", {
return idx > -1 && idx + domain.length == host.length && (idx == 0 || host[idx-1] == "."); return idx > -1 && idx + domain.length == host.length && (idx == 0 || host[idx-1] == ".");
}, },
/**
* Returns true if the given DOM node is currently visible.
*
* @param {Node} node
*/
isVisible: function (node) {
let style = util.computedStyle(node);
return style.visibility == "visible" && style.display != "none";
},
/** /**
* Returns an XPath union expression constructed from the specified node * Returns an XPath union expression constructed from the specified node
* tests. An expression is built with node tests for both the null and * tests. An expression is built with node tests for both the null and

View File

@@ -45,7 +45,7 @@ const Config = Module("config", ConfigBase, {
checkupdates: ["Check for updates", checkupdates: ["Check for updates",
function () { window.checkForUpdates(); }], function () { window.checkForUpdates(); }],
cleardata: ["Clear private data", cleardata: ["Clear private data",
function () { Cc[GLUE_CID].getService(Ci.nsIBrowserGlue).sanitize(window || null); }], function () { Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsIBrowserGlue).sanitize(window || null); }],
cookies: ["List your cookies", cookies: ["List your cookies",
function () { window.toOpenWindowByType("Browser:Cookies", "chrome://browser/content/preferences/cookies.xul", "chrome,dialog=no,resizable"); }], function () { window.toOpenWindowByType("Browser:Cookies", "chrome://browser/content/preferences/cookies.xul", "chrome,dialog=no,resizable"); }],
console: ["JavaScript console", console: ["JavaScript console",