2016-10-10 02:26:47 -08:00
|
|
|
// Clear selection range of current selected term view
|
2016-08-17 17:45:18 -08:00
|
|
|
// Fix event when terminal text is selected and keyboard action is invoked
|
|
|
|
|
exports.clear = function (terminal) {
|
|
|
|
|
terminal.document_.getSelection().removeAllRanges();
|
|
|
|
|
};
|
|
|
|
|
|
2016-08-18 19:09:40 -08:00
|
|
|
// Use selection extend upon dblclick
|
|
|
|
|
exports.extend = function (terminal) {
|
2016-09-21 06:27:11 -08:00
|
|
|
const sel = terminal.document_.getSelection();
|
2016-08-21 01:44:17 -08:00
|
|
|
|
|
|
|
|
// Test if focusNode exist and nodeName is #text
|
|
|
|
|
if (sel.focusNode && sel.focusNode.nodeName === '#text') {
|
|
|
|
|
terminal.screen_.expandSelection(sel);
|
2016-11-09 17:03:08 -09:00
|
|
|
if (terminal.copyOnSelect) {
|
|
|
|
|
terminal.copyStringToClipboard();
|
|
|
|
|
}
|
2016-08-21 01:44:17 -08:00
|
|
|
}
|
2016-08-17 17:45:18 -08:00
|
|
|
};
|
2016-08-18 19:09:40 -08:00
|
|
|
|
|
|
|
|
// Fix a bug in ScrollPort selectAll behavior
|
|
|
|
|
// Select all rows in the viewport
|
|
|
|
|
exports.all = function (terminal) {
|
2016-09-21 06:27:11 -08:00
|
|
|
const scrollPort = terminal.scrollPort_;
|
|
|
|
|
let firstRow;
|
|
|
|
|
let lastRow;
|
2016-08-18 19:09:40 -08:00
|
|
|
|
2016-09-21 06:27:11 -08:00
|
|
|
if (scrollPort.topFold_.nextSibling.rowIndex === 0) {
|
|
|
|
|
firstRow = scrollPort.topFold_.nextSibling;
|
|
|
|
|
} else {
|
2016-08-18 19:09:40 -08:00
|
|
|
while (scrollPort.topFold_.previousSibling) {
|
|
|
|
|
scrollPort.rowNodes_.removeChild(scrollPort.topFold_.previousSibling);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
firstRow = scrollPort.fetchRowNode_(0);
|
|
|
|
|
scrollPort.rowNodes_.insertBefore(firstRow, scrollPort.topFold_);
|
|
|
|
|
scrollPort.syncRowNodesDimensions_();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-21 06:27:11 -08:00
|
|
|
const lastRowIndex = scrollPort.rowProvider_.getRowCount() - 1;
|
2016-08-18 19:09:40 -08:00
|
|
|
|
2016-09-21 06:27:11 -08:00
|
|
|
if (scrollPort.bottomFold_.previousSibling.rowIndex === lastRowIndex) {
|
|
|
|
|
lastRow = scrollPort.bottomFold_.previousSibling.rowIndex;
|
|
|
|
|
} else {
|
2016-08-18 19:09:40 -08:00
|
|
|
while (scrollPort.bottomFold_.nextSibling) {
|
|
|
|
|
scrollPort.rowNodes_.removeChild(scrollPort.bottomFold_.nextSibling);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastRow = scrollPort.fetchRowNode_(lastRowIndex);
|
|
|
|
|
scrollPort.rowNodes_.appendChild(lastRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scrollPort.selection.sync();
|
|
|
|
|
};
|