1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 08:27: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:
Kris Maglione
2011-01-21 05:27:15 -05:00
parent 2af9754509
commit d71320aa09
8 changed files with 68 additions and 47 deletions

View File

@@ -802,14 +802,24 @@ var Buffer = Module("buffer", {
* @param {nsIURI} uri The URI to save
* @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();
persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE
| 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), "",
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);
},
@@ -1130,7 +1140,7 @@ var Buffer = Module("buffer", {
},
onStateChange: function (progress, request, flag, status) {
if ((flag & Ci.nsIWebProgressListener.STATE_STOP) && status == 0) {
if ((flag & this.STATE_STOP) && status == 0) {
try {
var ok = this.callback(this.file, true);
}

View File

@@ -491,7 +491,7 @@ var Modes = Module("modes", {
}
}, {
mappings: function () {
mappings.add([modes.BASE],
mappings.add([modes.BASE, modes.NORMAL],
["<Esc>", "<C-[>"],
"Return to NORMAL mode",
function () { modes.reset(); });

View File

@@ -87,7 +87,10 @@ var RangeFinder = Module("rangefinder", {
find: function (pattern, backwards) {
let str = this.bootstrap(pattern, backwards);
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;
},
@@ -96,7 +99,8 @@ var RangeFinder = Module("rangefinder", {
if (!this.rangeFind || this.rangeFind.stale)
this.find(this.lastFindPattern);
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)
// hack needed, because wrapping causes a "scroll" event which
// clears our command line
@@ -380,7 +384,7 @@ var RangeFind = Class("RangeFind", {
focus: function () {
if (this.lastRange)
var node = util.evaluateXPath(RangeFind.selectNodePath, this.range.document,
var node = util.evaluateXPath(RangeFind.selectNodePath,
this.lastRange.commonAncestorContainer).snapshotItem(0);
if (node) {
node.focus()

View File

@@ -466,12 +466,12 @@ var IO = Module("io", {
res = this.run("/bin/sh", ["-e", cmd.path], true);
}
let output = stdout.read();
if (res > 0)
output += "\nshell returned " + res;
else if (output)
output = output.replace(/^(.*)\n$/, "$1");
return output;
return {
__noSuchMethod__: function (meth, args) this.output[meth].apply(this.output, args),
valueOf: function () this.output,
output: stdout.read().replace(/^(.*)\n$/, "$1"),
returnValue: res
};
}) || "";
},
@@ -831,10 +831,12 @@ unlet s:cpo_save
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.commandOutput(<span highlight="CmdOutput">{output}</span>);
modules.commandline.commandOutput(<span highlight="CmdOutput">{result.output}</span>);
modules.autocommands.trigger("ShellCmdPost", {});
}, {
@@ -873,7 +875,8 @@ unlet s:cpo_save
context.title = ["Environment Variable", "Value"];
context.generate = function ()
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));
};

View File

@@ -331,11 +331,6 @@ var File = Class("File", {
return f;
},
/**
* Returns a clone of this file.
*/
clone: function () File(this),
/**
* Reads this file's entire contents in "text" mode and returns the
* content as a string.

View File

@@ -450,10 +450,13 @@ var Styles = Module("Styles", {
bang: true,
completer: function (context, args) {
let compl = [];
if (args.completeArg == 0)
Styles.completeSite(context, window.content);
else if (args.completeArg == 1) {
let sheet = styles.user.get(args["-name"]);
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) {
if (sheet)
context.completions = [[sheet.css, "Current Value"]];
context.fork("css", 0, modules.completion, "css");

View File

@@ -80,6 +80,9 @@ var Template = Module("Template", {
},
helpLink: function (topic, text, type) {
if (!services["dactyl:"].initialized)
util.dactyl.initHelp();
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
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>
},
HelpLink: function (topic) {
if (!services["dactyl:"].initialized)
util.dactyl.initHelp();
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
return <>{topic}</>;
@@ -220,8 +226,6 @@ var Template = Module("Template", {
},
linkifyHelp: function linkifyHelp(str, help) {
util.dactyl.initHelp();
let re = util.regexp(<![CDATA[
([/\s]|^)
( '[\w-]+' | :(?:[\w-]+|!) | (?:._)?<[\w-]+> )

View File

@@ -567,20 +567,18 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* namespaces. The result may be used as an iterator.
*
* @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.
* @default *doc*
* @default The current document.
* @param {boolean} asIterator Whether to return the results as an
* XPath iterator.
* @returns {Object} Iterable result of the evaluation.
*/
evaluateXPath: update(
function evaluateXPath(expression, doc, elem, asIterator) {
if (!doc)
doc = util.activeWindow.content.document;
function evaluateXPath(expression, elem, asIterator) {
try {
if (!elem)
elem = doc;
elem = util.activeWindow.content.document;
let doc = elem.ownerDocument || elem;
if (isArray(expression))
expression = util.makeXPath(expression);
@@ -596,6 +594,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
: 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) ({