Commit 15278b3f authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

Merge branch 'prakhar/purr-data-copy_cons' into emscripten

parents ea898cd9 988a9db1
Pipeline #3681 canceled with stage
......@@ -323,6 +323,14 @@ li .hr{
overflow: auto;
}
*[unselectable="on"] {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Bootstrap */
.container-fluid{
background-color: transparent;
......
......@@ -109,8 +109,10 @@
</label>
</div>
</div>
<i class='fa fa-trash ml-3 text-primary' style='cursor:pointer' id='clear' data-toggle="tooltip" title="Clear Console"></i>
<div>
<i class="fa fa-clone text-primary" id="cons_copy" unselectable="on" style="cursor: pointer;" data-toggle="tooltip" title="Copy Console"></i>
<i class='fa fa-trash ml-3 text-primary' style='cursor:pointer' id='clear' data-toggle="tooltip" title="Clear Console"></i>
</div>
</div>
<div class="collapse show" id="console_bottom">
......
......@@ -52,6 +52,38 @@ function load_menu_actions(){
}
});
minit("cons_copy", {
onclick: function() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
if (text.length === 0) {
var container_id = "p1", range;
// This should work across browsers
if (window.document.selection) {
range = window.document.body.createTextRange();
range.moveToElementText(window.document.getElementById(container_id));
range.select();
} else if (window.getSelection) {
range = window.document.createRange();
range.selectNode(window.document.getElementById(container_id));
// we need to empty the current selection to avoid a strange
// error when trying to select all right after Pd starts:
// "The given range and the current selection belong to two
// different document fragments."
// (I guess nw.js somehow starts up with the selection being
// somewhere outside the window...)
window.getSelection().empty();
window.getSelection().addRange(range);
}
}
window.document.execCommand("copy");
}
});
minit("edit-find", {
onclick: function() {
var find_bar = window.document.getElementById("console_find"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment