mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 06:07:59 +01:00
Don't force help initialization until we see something that looks like a help link. Other small interface changes.
This commit is contained in:
@@ -802,14 +802,24 @@ var Buffer = Module("buffer", {
|
|||||||
* @param {nsIURI} uri The URI to save
|
* @param {nsIURI} uri The URI to save
|
||||||
* @param {nsIFile} file The file into which to write the result.
|
* @param {nsIFile} file The file into which to write the result.
|
||||||
*/
|
*/
|
||||||
saveURI: function (uri, file) {
|
saveURI: function (uri, file, callback, self) {
|
||||||
var persist = services.Persist();
|
var persist = services.Persist();
|
||||||
persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE
|
persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE
|
||||||
| persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
|
| persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
|
||||||
|
|
||||||
persist.progressListener = new window.DownloadListener(window,
|
let downloadListener = new window.DownloadListener(window,
|
||||||
services.Transfer(uri, services.io.newFileURI(file), "",
|
services.Transfer(uri, services.io.newFileURI(file), "",
|
||||||
null, null, null, persist));
|
null, null, null, persist));
|
||||||
|
|
||||||
|
persist.progressListener = update(Object.create(downloadListener), {
|
||||||
|
onStateChange: function onStateChange(progress, request, flag, status) {
|
||||||
|
if (callback && (flag & Ci.nsIWebProgressListener.STATE_STOP) && status == 0)
|
||||||
|
dactyl.trapErrors(callback, self, uri, file, progress, request, flag, status);
|
||||||
|
|
||||||
|
return onStateChange.superapply(this, arguments);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
persist.saveURI(uri, null, null, null, null, file);
|
persist.saveURI(uri, null, null, null, null, file);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1130,7 +1140,7 @@ var Buffer = Module("buffer", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onStateChange: function (progress, request, flag, status) {
|
onStateChange: function (progress, request, flag, status) {
|
||||||
if ((flag & Ci.nsIWebProgressListener.STATE_STOP) && status == 0) {
|
if ((flag & this.STATE_STOP) && status == 0) {
|
||||||
try {
|
try {
|
||||||
var ok = this.callback(this.file, true);
|
var ok = this.callback(this.file, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ var Modes = Module("modes", {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
mappings: function () {
|
mappings: function () {
|
||||||
mappings.add([modes.BASE],
|
mappings.add([modes.BASE, modes.NORMAL],
|
||||||
["<Esc>", "<C-[>"],
|
["<Esc>", "<C-[>"],
|
||||||
"Return to NORMAL mode",
|
"Return to NORMAL mode",
|
||||||
function () { modes.reset(); });
|
function () { modes.reset(); });
|
||||||
|
|||||||
@@ -87,7 +87,10 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
find: function (pattern, backwards) {
|
find: function (pattern, backwards) {
|
||||||
let str = this.bootstrap(pattern, backwards);
|
let str = this.bootstrap(pattern, backwards);
|
||||||
if (!this.rangeFind.find(str))
|
if (!this.rangeFind.find(str))
|
||||||
this.timeout(function () { this.dactyl.echoerr("E486: Pattern not found: " + pattern); }, 0);
|
this.timeout(function () {
|
||||||
|
this.dactyl.echoerr("E486: Pattern not found: " + pattern,
|
||||||
|
this.commandline.FORCE_SINGLELINE);
|
||||||
|
});
|
||||||
|
|
||||||
return this.rangeFind.found;
|
return this.rangeFind.found;
|
||||||
},
|
},
|
||||||
@@ -96,7 +99,8 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
if (!this.rangeFind || this.rangeFind.stale)
|
if (!this.rangeFind || this.rangeFind.stale)
|
||||||
this.find(this.lastFindPattern);
|
this.find(this.lastFindPattern);
|
||||||
else if (!this.rangeFind.find(null, reverse))
|
else if (!this.rangeFind.find(null, reverse))
|
||||||
this.dactyl.echoerr("E486: Pattern not found: " + this.lastFindPattern);
|
this.dactyl.echoerr("E486: Pattern not found: " + this.lastFindPattern,
|
||||||
|
this.commandline.FORCE_SINGLELINE);
|
||||||
else if (this.rangeFind.wrapped)
|
else if (this.rangeFind.wrapped)
|
||||||
// hack needed, because wrapping causes a "scroll" event which
|
// hack needed, because wrapping causes a "scroll" event which
|
||||||
// clears our command line
|
// clears our command line
|
||||||
@@ -380,7 +384,7 @@ var RangeFind = Class("RangeFind", {
|
|||||||
|
|
||||||
focus: function () {
|
focus: function () {
|
||||||
if (this.lastRange)
|
if (this.lastRange)
|
||||||
var node = util.evaluateXPath(RangeFind.selectNodePath, this.range.document,
|
var node = util.evaluateXPath(RangeFind.selectNodePath,
|
||||||
this.lastRange.commonAncestorContainer).snapshotItem(0);
|
this.lastRange.commonAncestorContainer).snapshotItem(0);
|
||||||
if (node) {
|
if (node) {
|
||||||
node.focus()
|
node.focus()
|
||||||
|
|||||||
@@ -466,12 +466,12 @@ var IO = Module("io", {
|
|||||||
res = this.run("/bin/sh", ["-e", cmd.path], true);
|
res = this.run("/bin/sh", ["-e", cmd.path], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = stdout.read();
|
return {
|
||||||
if (res > 0)
|
__noSuchMethod__: function (meth, args) this.output[meth].apply(this.output, args),
|
||||||
output += "\nshell returned " + res;
|
valueOf: function () this.output,
|
||||||
else if (output)
|
output: stdout.read().replace(/^(.*)\n$/, "$1"),
|
||||||
output = output.replace(/^(.*)\n$/, "$1");
|
returnValue: res
|
||||||
return output;
|
};
|
||||||
}) || "";
|
}) || "";
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -831,10 +831,12 @@ unlet s:cpo_save
|
|||||||
|
|
||||||
io._lastRunCommand = arg;
|
io._lastRunCommand = arg;
|
||||||
|
|
||||||
let output = io.system(arg);
|
let result = io.system(arg);
|
||||||
|
if (result.returnValue != 0)
|
||||||
|
result.output += "\nshell returned " + res;
|
||||||
|
|
||||||
modules.commandline.command = "!" + arg;
|
modules.commandline.command = "!" + arg;
|
||||||
modules.commandline.commandOutput(<span highlight="CmdOutput">{output}</span>);
|
modules.commandline.commandOutput(<span highlight="CmdOutput">{result.output}</span>);
|
||||||
|
|
||||||
modules.autocommands.trigger("ShellCmdPost", {});
|
modules.autocommands.trigger("ShellCmdPost", {});
|
||||||
}, {
|
}, {
|
||||||
@@ -873,7 +875,8 @@ unlet s:cpo_save
|
|||||||
context.title = ["Environment Variable", "Value"];
|
context.title = ["Environment Variable", "Value"];
|
||||||
context.generate = function ()
|
context.generate = function ()
|
||||||
io.system(util.OS.isWindows ? "set" : "env")
|
io.system(util.OS.isWindows ? "set" : "env")
|
||||||
.split("\n").filter(function (line) line.indexOf("=") > 0)
|
.output.split("\n")
|
||||||
|
.filter(function (line) line.indexOf("=") > 0)
|
||||||
.map(function (line) line.match(/([^=]+)=(.*)/).slice(1));
|
.map(function (line) line.match(/([^=]+)=(.*)/).slice(1));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -331,11 +331,6 @@ var File = Class("File", {
|
|||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a clone of this file.
|
|
||||||
*/
|
|
||||||
clone: function () File(this),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads this file's entire contents in "text" mode and returns the
|
* Reads this file's entire contents in "text" mode and returns the
|
||||||
* content as a string.
|
* content as a string.
|
||||||
|
|||||||
@@ -450,10 +450,13 @@ var Styles = Module("Styles", {
|
|||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context, args) {
|
completer: function (context, args) {
|
||||||
let compl = [];
|
let compl = [];
|
||||||
if (args.completeArg == 0)
|
let sheet = styles.user.get(args["-name"]);
|
||||||
Styles.completeSite(context, window.content);
|
if (args.completeArg == 0) {
|
||||||
|
if (sheet)
|
||||||
|
context.completions = [[sheet.sites.join(","), "Current Value"]];
|
||||||
|
context.fork("sites", 0, Styles, "completeSite", window.content);
|
||||||
|
}
|
||||||
else if (args.completeArg == 1) {
|
else if (args.completeArg == 1) {
|
||||||
let sheet = styles.user.get(args["-name"]);
|
|
||||||
if (sheet)
|
if (sheet)
|
||||||
context.completions = [[sheet.css, "Current Value"]];
|
context.completions = [[sheet.css, "Current Value"]];
|
||||||
context.fork("css", 0, modules.completion, "css");
|
context.fork("css", 0, modules.completion, "css");
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ var Template = Module("Template", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
helpLink: function (topic, text, type) {
|
helpLink: function (topic, text, type) {
|
||||||
|
if (!services["dactyl:"].initialized)
|
||||||
|
util.dactyl.initHelp();
|
||||||
|
|
||||||
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
|
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
|
||||||
return <span highlight={type || ""}>{text || topic}</span>;
|
return <span highlight={type || ""}>{text || topic}</span>;
|
||||||
|
|
||||||
@@ -89,6 +92,9 @@ var Template = Module("Template", {
|
|||||||
return <a highlight={type} tag={topic} href={"dactyl://help-tag/" + topic} dactyl:command="dactyl.help" xmlns:dactyl={NS}>{text || topic}</a>
|
return <a highlight={type} tag={topic} href={"dactyl://help-tag/" + topic} dactyl:command="dactyl.help" xmlns:dactyl={NS}>{text || topic}</a>
|
||||||
},
|
},
|
||||||
HelpLink: function (topic) {
|
HelpLink: function (topic) {
|
||||||
|
if (!services["dactyl:"].initialized)
|
||||||
|
util.dactyl.initHelp();
|
||||||
|
|
||||||
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
|
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
|
||||||
return <>{topic}</>;
|
return <>{topic}</>;
|
||||||
|
|
||||||
@@ -220,8 +226,6 @@ var Template = Module("Template", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
linkifyHelp: function linkifyHelp(str, help) {
|
linkifyHelp: function linkifyHelp(str, help) {
|
||||||
util.dactyl.initHelp();
|
|
||||||
|
|
||||||
let re = util.regexp(<![CDATA[
|
let re = util.regexp(<![CDATA[
|
||||||
([/\s]|^)
|
([/\s]|^)
|
||||||
( '[\w-]+' | :(?:[\w-]+|!) | (?:._)?<[\w-]+> )
|
( '[\w-]+' | :(?:[\w-]+|!) | (?:._)?<[\w-]+> )
|
||||||
|
|||||||
@@ -567,35 +567,37 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* namespaces. The result may be used as an iterator.
|
* namespaces. The result may be used as an iterator.
|
||||||
*
|
*
|
||||||
* @param {string} expression The XPath expression to evaluate.
|
* @param {string} expression The XPath expression to evaluate.
|
||||||
* @param {Document} doc The document to evaluate the expression in.
|
|
||||||
* @default The current document.
|
|
||||||
* @param {Node} elem The context element.
|
* @param {Node} elem The context element.
|
||||||
* @default *doc*
|
* @default The current document.
|
||||||
* @param {boolean} asIterator Whether to return the results as an
|
* @param {boolean} asIterator Whether to return the results as an
|
||||||
* XPath iterator.
|
* XPath iterator.
|
||||||
* @returns {Object} Iterable result of the evaluation.
|
* @returns {Object} Iterable result of the evaluation.
|
||||||
*/
|
*/
|
||||||
evaluateXPath: update(
|
evaluateXPath: update(
|
||||||
function evaluateXPath(expression, doc, elem, asIterator) {
|
function evaluateXPath(expression, elem, asIterator) {
|
||||||
if (!doc)
|
try {
|
||||||
doc = util.activeWindow.content.document;
|
if (!elem)
|
||||||
if (!elem)
|
elem = util.activeWindow.content.document;
|
||||||
elem = doc;
|
let doc = elem.ownerDocument || elem;
|
||||||
if (isArray(expression))
|
if (isArray(expression))
|
||||||
expression = util.makeXPath(expression);
|
expression = util.makeXPath(expression);
|
||||||
|
|
||||||
let result = doc.evaluate(expression, elem,
|
let result = doc.evaluate(expression, elem,
|
||||||
evaluateXPath.resolver,
|
evaluateXPath.resolver,
|
||||||
asIterator ? Ci.nsIDOMXPathResult.ORDERED_NODE_ITERATOR_TYPE : Ci.nsIDOMXPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
|
asIterator ? Ci.nsIDOMXPathResult.ORDERED_NODE_ITERATOR_TYPE : Ci.nsIDOMXPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
return Object.create(result, {
|
return Object.create(result, {
|
||||||
__iterator__: {
|
__iterator__: {
|
||||||
value: asIterator ? function () { let elem; while ((elem = this.iterateNext())) yield elem; }
|
value: asIterator ? function () { let elem; while ((elem = this.iterateNext())) yield elem; }
|
||||||
: function () { for (let i = 0; i < this.snapshotLength; i++) yield this.snapshotItem(i); }
|
: function () { for (let i = 0; i < this.snapshotLength; i++) yield this.snapshotItem(i); }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw e.stack ? e : Error(e);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
resolver: function lookupNamespaceURI(prefix) ({
|
resolver: function lookupNamespaceURI(prefix) ({
|
||||||
|
|||||||
Reference in New Issue
Block a user