mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 16:47:58 +01:00
Add :feedkeys (perhaps to replace :normal?)
This commit is contained in:
@@ -685,7 +685,7 @@ const Dactyl = Module("dactyl", {
|
||||
* @param {XMLList} extraHelp Extra help text beyond the description.
|
||||
* @returns {string}
|
||||
*/
|
||||
generateHelp: function generateHelp(obj, extraHelp, str) {
|
||||
generateHelp: function generateHelp(obj, extraHelp, str, specOnly) {
|
||||
default xml namespace = "";
|
||||
|
||||
let link, tag, spec;
|
||||
@@ -696,6 +696,7 @@ const Dactyl = Module("dactyl", {
|
||||
tag = spec = function (cmd) <>:{cmd}</>;
|
||||
link = function (cmd) <ex>:{cmd}</ex>;
|
||||
args = obj.parseArgs("", CompletionContext(str || ""));
|
||||
spec = function (cmd) cmd + (obj.bang ? <oa>!</oa> : <></>);
|
||||
}
|
||||
else if (obj instanceof Map && obj.count) {
|
||||
spec = function (map) <><oa>count</oa>{map}</>;
|
||||
@@ -715,10 +716,16 @@ const Dactyl = Module("dactyl", {
|
||||
</>;
|
||||
|
||||
let res = <res>
|
||||
<dt>{link(obj.name)}</dt> <dd>{obj.description ? obj.description.replace(/\.$/, "") : ""}</dd>
|
||||
<dt>{link(obj.name)}</dt> <dd>{obj.description ? obj.description.replace(/\.$/, "") : ""}</dd></res>;
|
||||
if (!specOnly) {
|
||||
res.* += <>
|
||||
<item>
|
||||
<tags>{template.map(obj.names.slice().reverse(), tag, " ")}</tags>
|
||||
<spec>{spec((obj.specs || obj.names)[0])}</spec>{
|
||||
<spec>{
|
||||
spec(template.highlightRegexp((obj.specs || obj.names)[0],
|
||||
/\[(.*?)\]/g,
|
||||
function (m, n0) <oa>{n0}</oa>))
|
||||
}</spec>{
|
||||
!obj.type ? "" : <>
|
||||
<type>{obj.type}</type>
|
||||
<default>{obj.stringDefaultValue}</default></>}
|
||||
@@ -727,32 +734,33 @@ const Dactyl = Module("dactyl", {
|
||||
extraHelp ? br + extraHelp : "" }{
|
||||
!(extraHelp || obj.description) ? br + <p>Sorry, no help available.</p> : "" }
|
||||
</description>
|
||||
</item></res>;
|
||||
</item></>;
|
||||
|
||||
function add(ary) {
|
||||
res.item.description.* += br +
|
||||
let (br = br + <> </>)
|
||||
<><dl>{ br + template.map(ary, function ([a, b]) <><dt>{a}</dt> <dd>{b}</dd></>, br) }
|
||||
</dl>
|
||||
</>;
|
||||
function add(ary) {
|
||||
res.item.description.* += br +
|
||||
let (br = br + <> </>)
|
||||
<><dl>{ br + template.map(ary, function ([a, b]) <><dt>{a}</dt> <dd>{b}</dd></>, br) }
|
||||
</dl>
|
||||
</>;
|
||||
}
|
||||
|
||||
if (obj.completer)
|
||||
add(completion._runCompleter(obj.completer, "", null, args).items
|
||||
.map(function (i) [i.text, i.description]));
|
||||
|
||||
if (obj.options && obj.options.some(function (o) o.description))
|
||||
add(obj.options.filter(function (o) o.description)
|
||||
.map(function (o) [
|
||||
o.names[0],
|
||||
<>{o.description}{
|
||||
o.names.length == 1 ? "" :
|
||||
<> (short name: {
|
||||
template.map(o.names.slice(1), function (n) <em>{n}</em>, <>, </>)
|
||||
})</>
|
||||
}</>
|
||||
]));
|
||||
}
|
||||
|
||||
if (obj.completer)
|
||||
add(completion._runCompleter(obj.completer, "", null, args).items
|
||||
.map(function (i) [i.text, i.description]));
|
||||
|
||||
if (obj.options && obj.options.some(function (o) o.description))
|
||||
add(obj.options.filter(function (o) o.description)
|
||||
.map(function (o) [
|
||||
o.names[0],
|
||||
<>{o.description}{
|
||||
o.names.length == 1 ? "" :
|
||||
<> (short name: {
|
||||
template.map(o.names.slice(1), function (n) <em>{n}</em>, <>, </>)
|
||||
})</>
|
||||
}</>
|
||||
]));
|
||||
return res.*.toXMLString().replace(/^ {12}|[ \t]+$/gm, "");
|
||||
return res.*.toXMLString().replace(/^ {12}|[ \t]+$/gm, "").replace(/^.*\n|\n.*$/g, "") + "\n";
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1764,9 +1772,9 @@ const Dactyl = Module("dactyl", {
|
||||
|
||||
commands.add(["norm[al]"],
|
||||
"Execute Normal mode commands",
|
||||
function (args) { events.feedkeys(args[0] || "", args.bang, false, modes.NORMAL); },
|
||||
function (args) { events.feedkeys(args[0], args.bang, false, modes.NORMAL); },
|
||||
{
|
||||
argCount: "+",
|
||||
argCount: "1",
|
||||
bang: true,
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -419,15 +419,12 @@ const Mappings = Module("mappings", {
|
||||
names: ["-javascript", "-js", "-j"],
|
||||
description: "Execute this mapping as JavaScript rather than keys"
|
||||
},
|
||||
{
|
||||
update({}, modeFlag, {
|
||||
names: ["-modes", "-mode", "-m"],
|
||||
type: CommandOption.LIST,
|
||||
description: "Create this mapping in the given modes",
|
||||
default: mapmodes || ["n", "v"],
|
||||
validator: function (list) !list || list.every(findMode),
|
||||
completer: function () [[array.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.disp]
|
||||
for (mode in values(modes.all))],
|
||||
},
|
||||
}),
|
||||
{
|
||||
names: ["-nopersist", "-n"],
|
||||
description: "Do not save this mapping to an auto-generated RC file"
|
||||
@@ -501,10 +498,20 @@ const Mappings = Module("mappings", {
|
||||
});
|
||||
}
|
||||
|
||||
let modeFlag = {
|
||||
names: ["-mode", "-m"],
|
||||
type: CommandOption.STRING,
|
||||
validator: function (value) Array.concat(value).every(findMode),
|
||||
completer: function () [[array.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.disp]
|
||||
for (mode in values(modes.all))],
|
||||
};
|
||||
|
||||
function findMode(name) {
|
||||
for (let mode in values(modes.all))
|
||||
if (name == mode || name == mode.char || String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase())
|
||||
return mode.mask;
|
||||
if (name)
|
||||
for (let mode in values(modes.all))
|
||||
if (name == mode || name == mode.char
|
||||
|| String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase())
|
||||
return mode.mask;
|
||||
return null;
|
||||
}
|
||||
function uniqueModes(modes) {
|
||||
@@ -514,6 +521,20 @@ const Mappings = Module("mappings", {
|
||||
return array.uniq(modes.filter(function (m) chars.indexOf(m.char) < 0).concat(chars));
|
||||
}
|
||||
|
||||
commands.add(["feedkeys", "fk"],
|
||||
"Fake key events",
|
||||
function (args) { events.feedkeys(args[0] || "", args.bang, false, findMode(args["-mode"])); },
|
||||
{
|
||||
argCount: "1",
|
||||
bang: true,
|
||||
literal: 0,
|
||||
options: [
|
||||
update({}, modeFlag, {
|
||||
description: "The in which to feed the keys"
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
addMapCommands("", [modes.NORMAL, modes.VISUAL], "");
|
||||
|
||||
let args = {
|
||||
@@ -540,15 +561,10 @@ const Mappings = Module("mappings", {
|
||||
name: ["listk[eys]", "lk"],
|
||||
description: "List all mappings along with their short descriptions",
|
||||
options: [
|
||||
{
|
||||
names: ["-mode", "-m"],
|
||||
type: CommandOption.STRING,
|
||||
description: "The mode for which to list mappings",
|
||||
update({}, modeFlag, {
|
||||
default: "n",
|
||||
completer: function () [[array.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.disp]
|
||||
for (mode in values(modes.all))],
|
||||
validator: function (m) findMode(m)
|
||||
}
|
||||
description: "The mode for which to list mappings"
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
@@ -255,6 +255,7 @@ This file contains a list of all available commands, mappings and options.
|
||||
<dt><ex>:extensions</ex></dt> <dd>List all installed extensions</dd>
|
||||
<dt><ex>:extoptions</ex></dt> <dd>Open an extension's preference dialog</dd>
|
||||
<dt><ex>:extupdate</ex></dt> <dd>Update an extension</dd>
|
||||
<dt><ex>:feedkeys</ex></dt> <dd>Fake key events</dd>
|
||||
<dt><ex>:finish</ex></dt> <dd>Stop sourcing a script file</dd>
|
||||
<dt><ex>:forward</ex></dt> <dd>Go forward in the browser history</dd>
|
||||
<dt><ex>:frameonly</ex></dt> <dd>Show only the current frame's page</dd>
|
||||
|
||||
@@ -23,14 +23,26 @@
|
||||
arguments. These context names may be used to tune the function of
|
||||
the completion system via options like <o>autocomplete</o> and
|
||||
<o>wildcase</o>. Note that completion must be triggered in order
|
||||
for this command to be effective, so if autocompletion is not
|
||||
for this command to be effective, so if auto-completion is not
|
||||
active, you'll need to press the <k name="Tab" mode="c"/> key at
|
||||
least once. You should also be aware that this command is only
|
||||
useful from the commandline.
|
||||
useful from the command line.
|
||||
</p>
|
||||
</description>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<tags>:fk :feedkeys</tags>
|
||||
<spec>feedkeys<oa>!</oa></spec>
|
||||
<description>
|
||||
<p>Fake key events.</p>
|
||||
|
||||
<dl>
|
||||
<dt>-mode</dt> <dd>The in which to feed the keys (short name: <em>-m</em>)</dd>
|
||||
</dl>
|
||||
</description>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<tags>:norm :normal</tags>
|
||||
<spec>:norm<oa>al</oa><oa>!</oa> <a>keys</a></spec>
|
||||
|
||||
@@ -153,7 +153,7 @@ const Template = Module("Template", {
|
||||
return this.highlightSubstrings(str, (function () {
|
||||
let res;
|
||||
while ((res = re.exec(str)) && res[0].length)
|
||||
yield [res.index, res[0].length];
|
||||
yield [res.index, res[0].length, res];
|
||||
})(), highlight || template.filter);
|
||||
},
|
||||
|
||||
@@ -168,12 +168,12 @@ const Template = Module("Template", {
|
||||
let s = <></>;
|
||||
let start = 0;
|
||||
let n = 0;
|
||||
for (let [i, length] in iter) {
|
||||
for (let [i, length, args] in iter) {
|
||||
if (n++ > 50) // Prevent infinite loops.
|
||||
break;
|
||||
XML.ignoreWhitespace = false;
|
||||
s += <>{str.substring(start, i)}</>;
|
||||
s += highlight(str.substr(i, length));
|
||||
s += highlight.apply(this, Array.slice(args || str.substr(i, length)));
|
||||
start = i + length;
|
||||
}
|
||||
return s + <>{str.substr(start)}</>;
|
||||
|
||||
@@ -49,12 +49,31 @@
|
||||
* The concept of completion contexts is now exposed to the user
|
||||
(see :h :contexts), allowing for powerful and fine-grained
|
||||
completion system customization.
|
||||
* :viusage, :optionusage and :exusage were replaced with :listkeys,
|
||||
:listoptions and :listcommands, providing more powerful and
|
||||
consistent interactive help facility (improvements include
|
||||
listing keys for modes other than Normal, filtering the output
|
||||
and linking to source locations).
|
||||
* Added :mksyntax command.
|
||||
* Command changes:
|
||||
- :viusage, :optionusage and :exusage were replaced with :listkeys,
|
||||
:listoptions and :listcommands, providing more powerful and
|
||||
consistent interactive help facility (improvements include
|
||||
listing keys for modes other than Normal, filtering the output
|
||||
and linking to source locations).
|
||||
- Added :cookies command.
|
||||
* :extadd now supports remote URLs as well as local files on Firefox 4.
|
||||
* Added :if/:elseif/:else/:endif conditionals.
|
||||
- Added -keyword, -tags, -title to :delbmarks.
|
||||
- Added :extupdate command.
|
||||
- Added :feedkeys command.
|
||||
- Added several new options, including -javascript, to :abbrev and :map.
|
||||
- Added :mksyntax command.
|
||||
- :open now only opens files beginning with /, ./, ../, or ~/
|
||||
- Added :write !cmd and :write >>file.
|
||||
- Added :yank command.
|
||||
* Improvements to :style and :highlight:
|
||||
- Added -agent flag to :style.
|
||||
- The -append flag now updates existing properties rather than
|
||||
simply appending its arguments to the previous value.
|
||||
- Active filters are not highlighted in :style listings
|
||||
- :style-related commands now divide their completions between
|
||||
those active and inactive for the current site.
|
||||
- CSS property name completion is not available
|
||||
* IMPORTANT option changes:
|
||||
- 'cdpath' and 'runtimepath' no longer treat ",,"
|
||||
specially. Use "." instead.
|
||||
@@ -80,36 +99,26 @@
|
||||
operators, and = sign may no longer be quoted. This will break
|
||||
certain automatically-generated configuration files.
|
||||
See :help stringlist
|
||||
* Added "bookmarks", "diverted", and "links" to 'activate'
|
||||
option.
|
||||
* Added 'altwildmode' and <A-Tab> command-line key binding.
|
||||
* Added 'autocomplete' option for specifying which completion
|
||||
groups should be auto-completed.
|
||||
* Added 'banghist' option.
|
||||
* Option changes:
|
||||
- Added "bookmarks", "diverted", and "links" to 'activate'
|
||||
option.
|
||||
- Added 'altwildmode' and <A-Tab> command-line key binding.
|
||||
- Added 'autocomplete' option for specifying which completion
|
||||
groups should be auto-completed.
|
||||
- Added 'banghist' option.
|
||||
- Replaced 'focuscontent' with 'strictfocus'.
|
||||
- 'complete' now defaults to "slf" but file completion only
|
||||
triggers when the URL begins as above.
|
||||
- Added 'passkeys' option.
|
||||
- Changed 'urlseparator' default value to '|'.
|
||||
- Added "passwords" and "venkman" dialogs to :dialog.
|
||||
- Added 'wildanchor' option.
|
||||
- Added 'cookies', 'cookieaccept', and 'cookielifetime' options.
|
||||
* Added BookmarkChange, BookmarkRemove autocommands.
|
||||
* Added :cookies, 'cookies', 'cookieaccept', and 'cookielifetime'.
|
||||
* Added -keyword, -tags, -title to :delbmarks.
|
||||
* Added "passwords" and "venkman" dialogs to :dialog.
|
||||
* Added :extupdate command.
|
||||
* Replaced 'focuscontent' with 'strictfocus'.
|
||||
* Added :if/:elseif/:else/:endif conditionals.
|
||||
* Added 'passkeys' option.
|
||||
* Changed 'urlseparator' default value to '|'.
|
||||
* Added 'wildanchor' option.
|
||||
* Added -javascript option to :abbrev and :map.
|
||||
* Added several new options to :map.
|
||||
* Added -agent flag to :style.
|
||||
* Added :write !cmd and :write >>file.
|
||||
* Added :yank command.
|
||||
* Removed the :source line at the end of files generated by
|
||||
:mkpentadactylrc.
|
||||
* gf now toggles between source and content view.
|
||||
The | key binding has been removed.
|
||||
* :extadd now supports remote URLs as well as local files on
|
||||
Firefox 4.
|
||||
* :open now only opens files beginning with /, ./, ../, or ~/
|
||||
* 'complete' now defaults to "slf" but file completion only
|
||||
triggers when the URL begins as above.
|
||||
* Page zoom information is now shown in the status bar, and
|
||||
change in zoom status no longer appears in :messages.
|
||||
* Added ZO, ZI, ZM, and ZR as aliases for zO, zI, zM, and zR.
|
||||
|
||||
Reference in New Issue
Block a user