vim style selection+yanking. add props to constructor.
This commit is contained in:
+23
-7
@@ -207,6 +207,16 @@ function Terminal(options) {
|
|||||||
this.wraparoundMode = false;
|
this.wraparoundMode = false;
|
||||||
this.normal = null;
|
this.normal = null;
|
||||||
|
|
||||||
|
// select modes
|
||||||
|
this.prefixMode = false;
|
||||||
|
this.selectMode = false;
|
||||||
|
this.visualMode = false;
|
||||||
|
this.searchMode = false;
|
||||||
|
this.searchDown;
|
||||||
|
this.entry = '';
|
||||||
|
this.entryPrefix = '';
|
||||||
|
this._real;
|
||||||
|
|
||||||
// charset
|
// charset
|
||||||
this.charset = null;
|
this.charset = null;
|
||||||
this.gcharset = null;
|
this.gcharset = null;
|
||||||
@@ -2357,7 +2367,8 @@ Terminal.prototype.writeln = function(data) {
|
|||||||
// Key Resources:
|
// Key Resources:
|
||||||
// https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
|
// https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
|
||||||
Terminal.prototype.keyDown = function(ev) {
|
Terminal.prototype.keyDown = function(ev) {
|
||||||
var key;
|
var self = this
|
||||||
|
, key;
|
||||||
|
|
||||||
switch (ev.keyCode) {
|
switch (ev.keyCode) {
|
||||||
// backspace
|
// backspace
|
||||||
@@ -2537,7 +2548,11 @@ Terminal.prototype.keyDown = function(ev) {
|
|||||||
}
|
}
|
||||||
// Ctrl-C
|
// Ctrl-C
|
||||||
if ((this.prefixMode || this.selectMode) && ev.keyCode === 67) {
|
if ((this.prefixMode || this.selectMode) && ev.keyCode === 67) {
|
||||||
if (this.visualMode) this.leaveVisual();
|
if (this.visualMode) {
|
||||||
|
setTimeout(function() {
|
||||||
|
self.leaveVisual();
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
key = String.fromCharCode(ev.keyCode - 64);
|
key = String.fromCharCode(ev.keyCode - 64);
|
||||||
@@ -4787,14 +4802,14 @@ Terminal.prototype.selectText = function(x1, x2, y1, y2) {
|
|||||||
|
|
||||||
for (y = y1; y <= y2; y++) {
|
for (y = y1; y <= y2; y++) {
|
||||||
x = 0;
|
x = 0;
|
||||||
xl = this.cols;
|
xl = this.cols - 1;
|
||||||
if (y === y1) {
|
if (y === y1) {
|
||||||
x = x1;
|
x = x1;
|
||||||
}
|
}
|
||||||
if (y === y2) {
|
if (y === y2) {
|
||||||
xl = x2;
|
xl = x2;
|
||||||
}
|
}
|
||||||
for (; x < xl; x++) {
|
for (; x <= xl; x++) {
|
||||||
//this.lines[y][x].old = this.lines[y][x][0];
|
//this.lines[y][x].old = this.lines[y][x][0];
|
||||||
//this.lines[y][x][0] &= ~0x1ff;
|
//this.lines[y][x][0] &= ~0x1ff;
|
||||||
//this.lines[y][x][0] |= (0x1ff << 9) | 4;
|
//this.lines[y][x][0] |= (0x1ff << 9) | 4;
|
||||||
@@ -4846,14 +4861,14 @@ Terminal.prototype.grabText = function(x1, x2, y1, y2) {
|
|||||||
|
|
||||||
for (y = y1; y <= y2; y++) {
|
for (y = y1; y <= y2; y++) {
|
||||||
x = 0;
|
x = 0;
|
||||||
xl = this.cols;
|
xl = this.cols - 1;
|
||||||
if (y === y1) {
|
if (y === y1) {
|
||||||
x = x1;
|
x = x1;
|
||||||
}
|
}
|
||||||
if (y === y2) {
|
if (y === y2) {
|
||||||
xl = x2;
|
xl = x2;
|
||||||
}
|
}
|
||||||
for (; x < xl; x++) {
|
for (; x <= xl; x++) {
|
||||||
ch = this.lines[y][x][1];
|
ch = this.lines[y][x][1];
|
||||||
if (ch === ' ') {
|
if (ch === ' ') {
|
||||||
buf += ch;
|
buf += ch;
|
||||||
@@ -4872,7 +4887,7 @@ Terminal.prototype.grabText = function(x1, x2, y1, y2) {
|
|||||||
|
|
||||||
// If we're not at the end of the
|
// If we're not at the end of the
|
||||||
// line, don't add a newline.
|
// line, don't add a newline.
|
||||||
for (x = x2 + 1, y = y2; x < this.cols; x++) {
|
for (x = x2, y = y2; x < this.cols; x++) {
|
||||||
if (this.lines[y][x][1] !== ' ') {
|
if (this.lines[y][x][1] !== ' ') {
|
||||||
out = out.slice(0, -1);
|
out = out.slice(0, -1);
|
||||||
break;
|
break;
|
||||||
@@ -5218,6 +5233,7 @@ Terminal.prototype.keySelect = function(ev, key) {
|
|||||||
var x = this.cols - 1;
|
var x = this.cols - 1;
|
||||||
while (x >= 0) {
|
while (x >= 0) {
|
||||||
if (line[x][1] > ' ') {
|
if (line[x][1] > ' ') {
|
||||||
|
if (this.visualMode && x < this.cols - 1) x++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x--;
|
x--;
|
||||||
|
|||||||
Reference in New Issue
Block a user