mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 11:08:09 +01:00
Allow \ line continuations in Ex files.
This commit is contained in:
@@ -791,7 +791,7 @@ const Commands = Module("commands", {
|
|||||||
str.replace(/\s*".*$/, "");
|
str.replace(/\s*".*$/, "");
|
||||||
|
|
||||||
// 0 - count, 1 - cmd, 2 - special, 3 - args
|
// 0 - count, 1 - cmd, 2 - special, 3 - args
|
||||||
let matches = str.match(/^([:\s]*(\d+|%)?([a-zA-Z]+|!)(!)?(\s*))(.*?)?$/);
|
let matches = str.match(/^([:\s]*(\d+|%)?([a-zA-Z]+|!)(!)?(\s*))((?:.|\n)*?)?$/);
|
||||||
//var matches = str.match(/^:*(\d+|%)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/);
|
//var matches = str.match(/^:*(\d+|%)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/);
|
||||||
if (!matches)
|
if (!matches)
|
||||||
return [];
|
return [];
|
||||||
@@ -1103,21 +1103,21 @@ const Commands = Module("commands", {
|
|||||||
completion.ex(context);
|
completion.ex(context);
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{ names: ["-bang"], description: "Command may be proceeded by a !" },
|
{ names: ["-bang", "-b"], description: "Command may be proceeded by a !" },
|
||||||
{ names: ["-count"], description: "Command may be preceeded by a count" },
|
{ names: ["-count", "-c"], description: "Command may be preceeded by a count" },
|
||||||
{
|
{
|
||||||
names: ["-description"],
|
names: ["-description", "-desc", "-d"],
|
||||||
description: "A user-visible description of the command",
|
description: "A user-visible description of the command",
|
||||||
type: CommandOption.STRING
|
type: CommandOption.STRING
|
||||||
}, {
|
}, {
|
||||||
// TODO: "E180: invalid complete value: " + arg
|
// TODO: "E180: invalid complete value: " + arg
|
||||||
names: ["-complete"],
|
names: ["-complete", "-C"],
|
||||||
description: "The argument completion function",
|
description: "The argument completion function",
|
||||||
completer: function (context) [[k, ""] for ([k, v] in Iterator(completeOptionMap))],
|
completer: function (context) [[k, ""] for ([k, v] in Iterator(completeOptionMap))],
|
||||||
type: CommandOption.STRING,
|
type: CommandOption.STRING,
|
||||||
validator: function (arg) arg in completeOptionMap || /custom,\w+/.test(arg),
|
validator: function (arg) arg in completeOptionMap || /custom,\w+/.test(arg),
|
||||||
}, {
|
}, {
|
||||||
names: ["-nargs"],
|
names: ["-nargs", "-a"],
|
||||||
description: "The allowed number of arguments",
|
description: "The allowed number of arguments",
|
||||||
completer: [["0", "No arguments are allowed (default)"],
|
completer: [["0", "No arguments are allowed (default)"],
|
||||||
["1", "One argument is allowed"],
|
["1", "One argument is allowed"],
|
||||||
|
|||||||
@@ -2022,17 +2022,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
// all gui options to their default values, if they have not been
|
// all gui options to their default values, if they have not been
|
||||||
// set before by any RC file
|
// set before by any RC file
|
||||||
for (let option in values(options.needInit))
|
for (let option in values(options.needInit))
|
||||||
// FIXME:
|
option.initValue();
|
||||||
// 'encoding' option should not be set at this timing.
|
|
||||||
// Probably a wrong value is set into the option,
|
|
||||||
// if current page's encoding is not UTF-8.
|
|
||||||
try {
|
|
||||||
if (option.name != "encoding");
|
|
||||||
option.value = option.value;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
dactyl.reportError(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dactyl.commandLineOptions.postCommands)
|
if (dactyl.commandLineOptions.postCommands)
|
||||||
dactyl.commandLineOptions.postCommands.forEach(function (cmd) {
|
dactyl.commandLineOptions.postCommands.forEach(function (cmd) {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ const Hints = Module("hints", {
|
|||||||
this._hintNumber = 0;
|
this._hintNumber = 0;
|
||||||
this._hintString = "";
|
this._hintString = "";
|
||||||
statusline.updateInputBuffer("");
|
statusline.updateInputBuffer("");
|
||||||
commandline.command = "";
|
commandline.widgets.command = "";
|
||||||
}
|
}
|
||||||
this._pageHints = [];
|
this._pageHints = [];
|
||||||
this._validHints = [];
|
this._validHints = [];
|
||||||
@@ -99,7 +99,7 @@ const Hints = Module("hints", {
|
|||||||
}
|
}
|
||||||
if (this.__continue && this._validHints.length <= 1) {
|
if (this.__continue && this._validHints.length <= 1) {
|
||||||
this._hintString = "";
|
this._hintString = "";
|
||||||
commandline.command = this._hintString;
|
commandline.widgets.command = this._hintString;
|
||||||
this._showHints();
|
this._showHints();
|
||||||
}
|
}
|
||||||
this._updateStatusline();
|
this._updateStatusline();
|
||||||
|
|||||||
@@ -358,10 +358,7 @@ lookup:
|
|||||||
else if (/\.css$/.test(filename))
|
else if (/\.css$/.test(filename))
|
||||||
storage.styles.registerSheet(uri.spec, false, true);
|
storage.styles.registerSheet(uri.spec, false, true);
|
||||||
else {
|
else {
|
||||||
let heredoc = "";
|
let lines = file.read().split(/\r\n|[\r\n]/);
|
||||||
let heredocEnd = null; // the string which ends the heredoc
|
|
||||||
let str = file.read();
|
|
||||||
let lines = str.split(/\r\n|[\r\n]/);
|
|
||||||
|
|
||||||
this.readHeredoc = function (end) {
|
this.readHeredoc = function (end) {
|
||||||
let res = [];
|
let res = [];
|
||||||
@@ -382,21 +379,26 @@ lookup:
|
|||||||
for (let [i, line] in iter) {
|
for (let [i, line] in iter) {
|
||||||
if (this.sourcing.finished)
|
if (this.sourcing.finished)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
this.sourcing.line = i + 1;
|
this.sourcing.line = i + 1;
|
||||||
// skip line comments and blank lines
|
|
||||||
|
// Deal with editors from Silly OSs.
|
||||||
line = line.replace(/\r$/, "");
|
line = line.replace(/\r$/, "");
|
||||||
|
|
||||||
if (!/^\s*(".*)?$/.test(line))
|
// Process escaped new lines
|
||||||
try {
|
for (; i < lines.length && /^\s*\\/.test(lines[i + 1]); i++)
|
||||||
dactyl.execute(line, { setFrom: file });
|
line += "\n" + iter.next()[1].replace(/^\s*\\/, "");
|
||||||
}
|
|
||||||
catch (e) {
|
try {
|
||||||
if (!silent) {
|
dactyl.execute(line, { setFrom: file });
|
||||||
dactyl.echoerr("Error detected while processing " + file.path);
|
}
|
||||||
dactyl.echomsg("line\t" + this.sourcing.line + ":");
|
catch (e) {
|
||||||
dactyl.reportError(e, true);
|
if (!silent) {
|
||||||
}
|
dactyl.echoerr("Error detected while processing " + file.path);
|
||||||
|
dactyl.echomsg("line\t" + this.sourcing.line + ":");
|
||||||
|
dactyl.reportError(e, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ const Option = Class("Option", {
|
|||||||
this.globalValue = this.parseValues(this.defaultValue);
|
this.globalValue = this.parseValues(this.defaultValue);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initValue: function () {
|
||||||
|
dactyl.trapErrors(function () this.values = this.values, this);
|
||||||
|
},
|
||||||
|
|
||||||
/** @property {value} The option's global value. @see #scope */
|
/** @property {value} The option's global value. @see #scope */
|
||||||
get globalValue() options.store.get(this.name, {}).value,
|
get globalValue() options.store.get(this.name, {}).value,
|
||||||
set globalValue(val) { options.store.set(this.name, { value: val, time: Date.now() }); },
|
set globalValue(val) { options.store.set(this.name, { value: val, time: Date.now() }); },
|
||||||
@@ -683,8 +687,11 @@ const Options = Module("options", {
|
|||||||
memoize(this._optionMap, name, function () Option(names, description, type, defaultValue, extraInfo));
|
memoize(this._optionMap, name, function () Option(names, description, type, defaultValue, extraInfo));
|
||||||
for (let alias in values(names.slice(1)))
|
for (let alias in values(names.slice(1)))
|
||||||
memoize(this._optionMap, alias, closure);
|
memoize(this._optionMap, alias, closure);
|
||||||
if (extraInfo.setter)
|
if (extraInfo.setter && (!extraInfo.scope || extraInfo.scope & Option.SCOPE_GLOBAL))
|
||||||
memoize(this.needInit, this.needInit.length, closure);
|
if (dactyl.initialized)
|
||||||
|
closure().initValue();
|
||||||
|
else
|
||||||
|
memoize(this.needInit, this.needInit.length, closure);
|
||||||
|
|
||||||
// quickly access options with options["wildmode"]:
|
// quickly access options with options["wildmode"]:
|
||||||
this.__defineGetter__(name, function () this._optionMap[name].values);
|
this.__defineGetter__(name, function () this._optionMap[name].values);
|
||||||
|
|||||||
@@ -18,7 +18,12 @@
|
|||||||
- Backtracks to the first successful match after pressing
|
- Backtracks to the first successful match after pressing
|
||||||
backspace.
|
backspace.
|
||||||
- Supports reverse incremental search.
|
- Supports reverse incremental search.
|
||||||
* Multiple Ex commands may now be separated by |
|
* Ex command parsing improvements, including:
|
||||||
|
- Multiple Ex commands may now be separated by |
|
||||||
|
- Commands can continue over multiple lines in RC files by
|
||||||
|
prefixing the continues lines with a \
|
||||||
|
- The \ character is no longer treated specially within single
|
||||||
|
quotes, i.e., 'fo\o''bar' ⇒ fo\o'bar
|
||||||
* Command-line is now hidden by default. Added C and M to
|
* Command-line is now hidden by default. Added C and M to
|
||||||
'guioptions'.
|
'guioptions'.
|
||||||
* Hint mode improvements, including:
|
* Hint mode improvements, including:
|
||||||
@@ -41,8 +46,6 @@
|
|||||||
directory in 'runtimepath' rather than 'plugin/'.
|
directory in 'runtimepath' rather than 'plugin/'.
|
||||||
* IMPORTANT: 'loadplugins' is now a regexlist option rather than
|
* IMPORTANT: 'loadplugins' is now a regexlist option rather than
|
||||||
a boolean.
|
a boolean.
|
||||||
* IMPORTANT: Single quotes no longer treat \ specially.
|
|
||||||
I.e., 'fo\o''bar' ≡ fo\o'bar
|
|
||||||
* IMPORTANT: 'cdpath' and 'runtimepath' no longer treat ",,"
|
* IMPORTANT: 'cdpath' and 'runtimepath' no longer treat ",,"
|
||||||
specially. Use "." instead.
|
specially. Use "." instead.
|
||||||
* IMPORTANT: Option value quoting has changed. List options will
|
* IMPORTANT: Option value quoting has changed. List options will
|
||||||
|
|||||||
Reference in New Issue
Block a user