mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-28 19:32:28 +01:00
Add third argument to dactyl.clipboardWrite.
This commit is contained in:
@@ -349,9 +349,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
*/
|
||||
clipboardRead: function clipboardRead(getClipboard) {
|
||||
try {
|
||||
const clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
|
||||
const transferable = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
|
||||
const { clipboard } = services;
|
||||
|
||||
let transferable = services.Transferable();
|
||||
transferable.addDataFlavor("text/unicode");
|
||||
|
||||
let source = clipboard[getClipboard || !clipboard.supportsSelectionClipboard() ?
|
||||
@@ -373,12 +373,21 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
* Copies a string to the system clipboard. If *verbose* is specified the
|
||||
* copied string is also echoed to the command line.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {boolean} verbose
|
||||
* @param {string} str The string to write.
|
||||
* @param {boolean} verbose If true, the user is notified of the copied data.
|
||||
* @param {string} which Which clipboard to write to. Either
|
||||
* "global" or "selection". If not provided, both clipboards are
|
||||
* updated.
|
||||
* @optional
|
||||
*/
|
||||
clipboardWrite: function clipboardWrite(str, verbose) {
|
||||
const clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
|
||||
clipboardHelper.copyString(str);
|
||||
clipboardWrite: function clipboardWrite(str, verbose, which) {
|
||||
if (!which)
|
||||
services.clipboardHelper.copyString(str);
|
||||
else if (which == "selection" && !services.clipboard.supportsSelectionClipboard())
|
||||
return;
|
||||
else
|
||||
services.clipboardHelper.copyStringToClipboard(str,
|
||||
services.clipboard["k" + util.capitalize(which) + "Clipboard"]);
|
||||
|
||||
if (verbose) {
|
||||
let message = { message: _("dactyl.yank", str) };
|
||||
@@ -416,8 +425,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
echoerr: function echoerr(str, flags) {
|
||||
flags |= commandline.APPEND_TO_MESSAGES;
|
||||
|
||||
if (isinstance(str, ["DOMException", "Error", "Exception"]) || isinstance(str, ["XPCWrappedNative_NoHelper"]) && /^\[Exception/.test(str))
|
||||
if (isinstance(str, ["DOMException", "Error", "Exception"])
|
||||
|| isinstance(str, ["XPCWrappedNative_NoHelper"]) && /^\[Exception/.test(str))
|
||||
dactyl.reportError(str);
|
||||
|
||||
if (isObject(str) && "echoerr" in str)
|
||||
str = str.echoerr;
|
||||
else if (isinstance(str, ["Error", FailedAssertion]) && str.fileName)
|
||||
@@ -1207,7 +1218,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
if (error instanceof FailedAssertion && error.noTrace || error.message === "Interrupted") {
|
||||
let context = contexts.context;
|
||||
let prefix = context ? context.file + ":" + context.line + ": " : "";
|
||||
if (error.message && error.message.indexOf(prefix) !== 0)
|
||||
if (error.message && error.message.indexOf(prefix) !== 0 &&
|
||||
prefix != "[Command Line]:1: ")
|
||||
error.message = prefix + error.message;
|
||||
|
||||
if (error.message)
|
||||
|
||||
@@ -1182,7 +1182,7 @@ var Commands = Module("commands", {
|
||||
(?P<prespace> [:\s]*)
|
||||
(?P<count> (?:\d+ | %)? )
|
||||
(?P<fullCmd>
|
||||
(?: (?P<group> <name>) : )?
|
||||
(?: (?P<group> <name>) : )?
|
||||
(?P<cmd> (?:-? [()] | <name> | !)? ))
|
||||
(?P<bang> !?)
|
||||
(?P<space> \s*)
|
||||
|
||||
@@ -29,6 +29,8 @@ var Services = Module("Services", {
|
||||
this.add("cache", "@mozilla.org/network/cache-service;1", "nsICacheService");
|
||||
this.add("charset", "@mozilla.org/charset-converter-manager;1", "nsICharsetConverterManager");
|
||||
this.add("chromeRegistry", "@mozilla.org/chrome/chrome-registry;1", "nsIXULChromeRegistry");
|
||||
this.add("clipboard", "@mozilla.org/widget/clipboard;1", "nsIClipboard");
|
||||
this.add("clipboardHelper", "@mozilla.org/widget/clipboardhelper;1", "nsIClipboardHelper");
|
||||
this.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=dactyl");
|
||||
this.add("console", "@mozilla.org/consoleservice;1", "nsIConsoleService");
|
||||
this.add("dactyl:", "@mozilla.org/network/protocol;1?name=dactyl");
|
||||
@@ -93,6 +95,7 @@ var Services = Module("Services", {
|
||||
this.addClass("String", "@mozilla.org/supports-string;1", "nsISupportsString", "data");
|
||||
this.addClass("StringStream", "@mozilla.org/io/string-input-stream;1", "nsIStringInputStream", "data");
|
||||
this.addClass("Transfer", "@mozilla.org/transfer;1", "nsITransfer", "init");
|
||||
this.addClass("Transferable", "@mozilla.org/widget/transferable;1", "nsITransferable");
|
||||
this.addClass("Timer", "@mozilla.org/timer;1", "nsITimer", "initWithCallback");
|
||||
this.addClass("URL", "@mozilla.org/network/standard-url;1", ["nsIStandardURL", "nsIURL"], "init");
|
||||
this.addClass("Xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", "nsIXMLHttpRequest", "open");
|
||||
|
||||
Reference in New Issue
Block a user