mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 11:18:00 +01:00
Add :yank command.
This commit is contained in:
@@ -538,7 +538,7 @@ const CommandLine = Module("commandline", {
|
|||||||
* @param {boolean} forceSingle If provided, don't let over-long
|
* @param {boolean} forceSingle If provided, don't let over-long
|
||||||
* messages move to the MOW.
|
* messages move to the MOW.
|
||||||
*/
|
*/
|
||||||
_echoLine: function echoLine(str, highlightGroup, forceSingle) {
|
_echoLine: function echoLine(str, highlightGroup, forceSingle, silent) {
|
||||||
this.widgets.message = str ? [highlightGroup, str] : null;
|
this.widgets.message = str ? [highlightGroup, str] : null;
|
||||||
|
|
||||||
dactyl.triggerObserver("echoLine", str, highlightGroup, forceSingle);
|
dactyl.triggerObserver("echoLine", str, highlightGroup, forceSingle);
|
||||||
@@ -549,7 +549,7 @@ const CommandLine = Module("commandline", {
|
|||||||
let field = this.widgets.active.message.inputField;
|
let field = this.widgets.active.message.inputField;
|
||||||
if (field.value && !forceSingle && field.editor.rootElement.scrollWidth > field.scrollWidth) {
|
if (field.value && !forceSingle && field.editor.rootElement.scrollWidth > field.scrollWidth) {
|
||||||
this.widgets.message = null;
|
this.widgets.message = null;
|
||||||
this._echoMultiline(<span highlight="Message">{str}</span>, highlightGroup);
|
this._echoMultiline(<span highlight="Message">{str}</span>, highlightGroup, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -559,7 +559,7 @@ const CommandLine = Module("commandline", {
|
|||||||
* @param {string} str
|
* @param {string} str
|
||||||
* @param {string} highlightGroup
|
* @param {string} highlightGroup
|
||||||
*/
|
*/
|
||||||
_echoMultiline: function echoMultiline(str, highlightGroup) {
|
_echoMultiline: function echoMultiline(str, highlightGroup, silent) {
|
||||||
let doc = this.widgets.multilineOutput.contentDocument;
|
let doc = this.widgets.multilineOutput.contentDocument;
|
||||||
let win = this.widgets.multilineOutput.contentWindow;
|
let win = this.widgets.multilineOutput.contentWindow;
|
||||||
|
|
||||||
@@ -567,8 +567,6 @@ const CommandLine = Module("commandline", {
|
|||||||
if (!this.commandVisible)
|
if (!this.commandVisible)
|
||||||
this.hide();
|
this.hide();
|
||||||
|
|
||||||
dactyl.triggerObserver("echoMultiline", str, highlightGroup);
|
|
||||||
|
|
||||||
this._startHints = false;
|
this._startHints = false;
|
||||||
if (!(modes.extended & modes.OUTPUT_MULTILINE))
|
if (!(modes.extended & modes.OUTPUT_MULTILINE))
|
||||||
modes.push(modes.COMMAND_LINE, modes.OUTPUT_MULTILINE, {
|
modes.push(modes.COMMAND_LINE, modes.OUTPUT_MULTILINE, {
|
||||||
@@ -585,6 +583,9 @@ const CommandLine = Module("commandline", {
|
|||||||
this._lastMowOutput = <div class="ex-command-output" style={"white-space: " + style} highlight={highlightGroup}>{str}</div>;
|
this._lastMowOutput = <div class="ex-command-output" style={"white-space: " + style} highlight={highlightGroup}>{str}</div>;
|
||||||
let output = util.xmlToDom(this._lastMowOutput, doc);
|
let output = util.xmlToDom(this._lastMowOutput, doc);
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
dactyl.triggerObserver("echoMultiline", str, highlightGroup, output);
|
||||||
|
|
||||||
// FIXME: need to make sure an open MOW is closed when commands
|
// FIXME: need to make sure an open MOW is closed when commands
|
||||||
// that don't generate output are executed
|
// that don't generate output are executed
|
||||||
if (this.widgets.mowContainer.collapsed)
|
if (this.widgets.mowContainer.collapsed)
|
||||||
@@ -660,7 +661,7 @@ const CommandLine = Module("commandline", {
|
|||||||
else {
|
else {
|
||||||
if (this.widgets.message && this.widgets.message[1] == this._lastEcho)
|
if (this.widgets.message && this.widgets.message[1] == this._lastEcho)
|
||||||
this._echoMultiline(<span highlight="Message">{this._lastEcho}</span>,
|
this._echoMultiline(<span highlight="Message">{this._lastEcho}</span>,
|
||||||
this.widgets.message[0]);
|
this.widgets.message[0], true);
|
||||||
|
|
||||||
if (action === this._echoLine && !(flags & this.FORCE_MULTILINE) && !this.widgets.mowContainer.collapsed) {
|
if (action === this._echoLine && !(flags & this.FORCE_MULTILINE) && !this.widgets.mowContainer.collapsed) {
|
||||||
highlightGroup += " Message";
|
highlightGroup += " Message";
|
||||||
@@ -1153,6 +1154,17 @@ const CommandLine = Module("commandline", {
|
|||||||
}
|
}
|
||||||
if (this._history)
|
if (this._history)
|
||||||
this._history.reset();
|
this._history.reset();
|
||||||
|
},
|
||||||
|
|
||||||
|
withOutputToString: function (fn, self) {
|
||||||
|
let buffer = [];
|
||||||
|
dactyl.registerObserver("echoLine", observe, true);
|
||||||
|
dactyl.registerObserver("echoMultiline", observe, true);
|
||||||
|
function observe(str, highlight, dom) {
|
||||||
|
buffer.push(dom ? dom.textContent : str)
|
||||||
|
}
|
||||||
|
dactyl.trapErrors.apply(dactyl, [fn, self].concat(Array.slice(arguments, 2)));
|
||||||
|
return buffer.join("\n");
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1241,6 +1241,17 @@ const Commands = Module("commands", {
|
|||||||
argCount: "1",
|
argCount: "1",
|
||||||
completer: function (context) completion.userCommand(context)
|
completer: function (context) completion.userCommand(context)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
commands.add(["y[ank]"],
|
||||||
|
"Yanks the output of the given command to the clipboard",
|
||||||
|
function (args) {
|
||||||
|
dactyl.clipboardWrite(
|
||||||
|
commandline.withOutputToString(commands.execute, commands, args[0]));
|
||||||
|
},
|
||||||
|
{
|
||||||
|
completer: function (context) completion.ex(context),
|
||||||
|
literal: 0
|
||||||
|
});
|
||||||
},
|
},
|
||||||
javascript: function () {
|
javascript: function () {
|
||||||
JavaScript.setCompleter([this.get, this.removeUserCommand],
|
JavaScript.setCompleter([this.get, this.removeUserCommand],
|
||||||
|
|||||||
@@ -621,7 +621,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
let br = <>
|
let br = <>
|
||||||
</>;
|
</>;
|
||||||
|
|
||||||
dactyl.clipboardWrite(<>
|
return <>
|
||||||
<item>
|
<item>
|
||||||
<tags>{template.map(obj.names, tag, " ")}</tags>
|
<tags>{template.map(obj.names, tag, " ")}</tags>
|
||||||
<spec>{spec((obj.specs || obj.names)[0])}</spec>{
|
<spec>{spec((obj.specs || obj.names)[0])}</spec>{
|
||||||
@@ -633,7 +633,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
extraHelp ? br+extraHelp : "" }{
|
extraHelp ? br+extraHelp : "" }{
|
||||||
!(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" }
|
!(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" }
|
||||||
</description>
|
</description>
|
||||||
</item></>.toXMLString().replace(/^ {12}/gm, ""), true);
|
</item></>.toXMLString().replace(/^ {12}/gm, "");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -210,6 +210,7 @@
|
|||||||
<li><ex>:vmap</ex></li>
|
<li><ex>:vmap</ex></li>
|
||||||
<li><ex>:vnoremap</ex></li>
|
<li><ex>:vnoremap</ex></li>
|
||||||
<li><ex>:winopen</ex></li>
|
<li><ex>:winopen</ex></li>
|
||||||
|
<li><ex>:yank</ex></li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
</description>
|
</description>
|
||||||
|
|||||||
@@ -351,6 +351,7 @@ This file contains a list of all available commands, mappings and options.
|
|||||||
<dt><ex>:winonly</ex></dt> <dd>Close all other windows</dd>
|
<dt><ex>:winonly</ex></dt> <dd>Close all other windows</dd>
|
||||||
<dt><ex>:winopen</ex></dt> <dd>Open one or more URLs in a new window</dd>
|
<dt><ex>:winopen</ex></dt> <dd>Open one or more URLs in a new window</dd>
|
||||||
<dt><ex>:wqall</ex></dt> <dd>Save the session and quit</dd>
|
<dt><ex>:wqall</ex></dt> <dd>Save the session and quit</dd>
|
||||||
|
<dt><ex>:yank</ex></dt> <dd>Yanks the output of the given command to the clipboard.</dd>
|
||||||
<dt><ex>:zoom</ex></dt> <dd>Set zoom value of current web page</dd>
|
<dt><ex>:zoom</ex></dt> <dd>Set zoom value of current web page</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,14 @@
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags>:yank :y</tags>
|
||||||
|
<spec>:y[ank] <a>cmd</a></spec>
|
||||||
|
<description>
|
||||||
|
<p>Yanks the output of the given command to the clipboard.</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<h2 tag="privacy">Privacy and sensitive information</h2>
|
<h2 tag="privacy">Privacy and sensitive information</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
* Added several new options to :map.
|
* Added several new options to :map.
|
||||||
* Added -agent flag to :style.
|
* Added -agent flag to :style.
|
||||||
* Added :write !cmd and :write >>file.
|
* Added :write !cmd and :write >>file.
|
||||||
|
* Added :yank command.
|
||||||
* Removed the :source line at the end of files generated by
|
* Removed the :source line at the end of files generated by
|
||||||
:mkpentadactylrc.
|
:mkpentadactylrc.
|
||||||
* gf now toggles between source and content view.
|
* gf now toggles between source and content view.
|
||||||
|
|||||||
Reference in New Issue
Block a user