summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpsvenk <45520974+psvenk@users.noreply.github.com>2020-05-15 20:21:26 -0400
committerJack Rosenthal <jack@rosenth.al>2020-05-22 13:18:46 -0600
commitdbf02d0b77636eedfe83ff5d9f70920616e8e017 (patch)
tree5bf79dc11bc0363b3a5f948e2cbe48c4b07c7d6a
parent1712b0a97b8c3019284060026d8f3fd6cba8bdf2 (diff)
downloadpentadactyl-dbf02d0b77636eedfe83ff5d9f70920616e8e017.tar.gz
Make option defregister for yank and put on X11
The variable editor.defaultRegister has been made into an option 'defregister'. If '+' appears before '*' in it, the "global" clipboard is used instead of the "selection" clipboard on X11 systems for put operations (p, P, gP). Yank operations yank to all clipboards in 'defregister'.
-rw-r--r--common/content/dactyl.js13
-rw-r--r--common/content/editor.js11
-rw-r--r--common/locale/en-US/browsing.xml2
-rw-r--r--common/locale/en-US/options.xml31
4 files changed, 49 insertions, 8 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index 28d57b36..36a26783 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -333,8 +333,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* apps like Thunderbird which do not provide it.
*
* @param {string} which Which clipboard to write to. Either
- * "global" or "selection". If not provided, both clipboards are
- * updated.
+ * "global" or "selection". If not provided, the selection is used
+ * unless '+' appears before '*' in the option 'defregister' or
+ * the OS does not have a selection clipboard.
* @optional
* @returns {string}
*/
@@ -345,8 +346,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let transferable = services.Transferable();
transferable.addDataFlavor("text/unicode");
- let source = clipboard[which == "global" || !clipboard.supportsSelectionClipboard() ?
- "kGlobalClipboard" : "kSelectionClipboard"];
+ let source = clipboard[
+ which == "global"
+ || !clipboard.supportsSelectionClipboard()
+ || (!which && options.get("defregister").value.match(/^[^\*]*\+/)) ?
+ "kGlobalClipboard" : "kSelectionClipboard"
+ ];
clipboard.getData(transferable, source);
let str = {}, len = {};
diff --git a/common/content/editor.js b/common/content/editor.js
index b346a5d9..9c779c0a 100644
--- a/common/content/editor.js
+++ b/common/content/editor.js
@@ -56,8 +56,6 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
}, this);
},
- defaultRegister: "*+",
-
selectionRegisters: {
"*": "selection",
"+": "global"
@@ -72,7 +70,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
*/
getRegister: function getRegister(name) {
if (name == null)
- name = editor.currentRegister || editor.defaultRegister;
+ name = editor.currentRegister || options.get("defregister").value;
name = String(name)[0];
if (name == '"')
@@ -106,7 +104,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
*/
setRegister: function setRegister(name, value, verbose) {
if (name == null)
- name = editor.currentRegister || editor.defaultRegister;
+ name = editor.currentRegister || options.get("defregister").value;
if (isinstance(value, [Ci.nsIDOMRange, Ci.nsIDOMNode, Ci.nsISelection]))
value = DOM.stringify(value);
@@ -1438,6 +1436,11 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
context.keys = { text: identity, description: identity };
}
});
+
+ options.add(["defregister", "dr"],
+ "The list of registers to use, in order of preference, for yank and put operations",
+ // Make sure to update the docs when you change this.
+ "string", "*+");
},
sanitizer: function initSanitizer() {
sanitizer.addItem("registers", {
diff --git a/common/locale/en-US/browsing.xml b/common/locale/en-US/browsing.xml
index d526ba80..5f6380cd 100644
--- a/common/locale/en-US/browsing.xml
+++ b/common/locale/en-US/browsing.xml
@@ -170,6 +170,8 @@
contents, or, on X11 systems, the currently selected
text. All white space is stripped from the selection and
it is opened in the same manner as <ex>:open</ex>.
+ The clipboard used on X11 systems is controlled by
+ <o>defregister</o>.
</p>
</description>
</item>
diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml
index 19533bfa..ef2bca58 100644
--- a/common/locale/en-US/options.xml
+++ b/common/locale/en-US/options.xml
@@ -573,6 +573,37 @@
</item>
<item>
+ <tags>'dr' 'defregister'</tags>
+ <spec>'defregister' 'dr'</spec>
+ <type>string</type>
+ <default>*+</default>
+ <description>
+ <p>
+ The list of registers (clipboards) to use, in order of
+ preference, for yank (<k>y</k>) and put
+ (<k>p</k>, <k>P</k>, and <k>gP</k>) operations on X11 systems.
+ Yank operations yank to all registers in this list and
+ put operations read from <str>*</str> or <str>+</str>,
+ whichever comes first in this list.
+
+ The value is a string consisting of any of the following
+ characters:
+
+ <dl>
+ <dt>*</dt> <dd>Tied to the PRIMARY selection value.</dd>
+ <dt>+</dt> <dd>Tied to the primary global clipboard.</dd>
+ <dt>_</dt> <dd>The null register. Never has any value.</dd>
+ <dt>"</dt> <dd>Equivalent to 0.</dd>
+ <dt>0-9</dt> <dd>
+ These act as a kill ring. Setting any one of them pushes
+ the values of higher numbered registers up one slot.
+ </dd>
+ </dl>
+ </p>
+ </description>
+</item>
+
+<item>
<tags>'dls' 'dlsort' 'downloadsort'</tags>
<spec>'downloadsort' 'dlsort' 'dls'</spec>
<strut/>