mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Remove even more useless code
This commit is contained in:
-382
@@ -4164,388 +4164,6 @@
|
||||
this.maxRange();
|
||||
};
|
||||
|
||||
Terminal.prototype.keyPrefix = function(ev, key) {
|
||||
if (key === 'k' || key === '&') {
|
||||
this.destroy();
|
||||
} else if (key === 'p' || key === ']') {
|
||||
this.emit('request paste');
|
||||
} else if (key === 'c') {
|
||||
this.emit('request create');
|
||||
} else if (key >= '0' && key <= '9') {
|
||||
key = +key - 1;
|
||||
if (!~key) key = 9;
|
||||
this.emit('request term', key);
|
||||
} else if (key === 'n') {
|
||||
this.emit('request term next');
|
||||
} else if (key === 'P') {
|
||||
this.emit('request term previous');
|
||||
} else if (key === ':') {
|
||||
this.emit('request command mode');
|
||||
}
|
||||
};
|
||||
|
||||
Terminal.prototype.keySelect = function(ev, key) {
|
||||
this.showCursor();
|
||||
|
||||
if (key === '\x04') { // ctrl-d
|
||||
var y = this.ydisp + this.y;
|
||||
if (this.ydisp === this.ybase) {
|
||||
// Mimic vim behavior
|
||||
this.y = Math.min(this.y + (this.rows - 1) / 2 | 0, this.rows - 1);
|
||||
this.refresh(0, this.rows - 1);
|
||||
} else {
|
||||
this.scrollDisp((this.rows - 1) / 2 | 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === '\x15') { // ctrl-u
|
||||
var y = this.ydisp + this.y;
|
||||
if (this.ydisp === 0) {
|
||||
// Mimic vim behavior
|
||||
this.y = Math.max(this.y - (this.rows - 1) / 2 | 0, 0);
|
||||
this.refresh(0, this.rows - 1);
|
||||
} else {
|
||||
this.scrollDisp(-(this.rows - 1) / 2 | 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === '\x06') { // ctrl-f
|
||||
var y = this.ydisp + this.y;
|
||||
this.scrollDisp(this.rows - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === '\x02') { // ctrl-b
|
||||
var y = this.ydisp + this.y;
|
||||
this.scrollDisp(-(this.rows - 1));
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'k' || key === '\x1b[A') {
|
||||
var y = this.ydisp + this.y;
|
||||
this.y--;
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
this.scrollDisp(-1);
|
||||
}
|
||||
this.refresh(this.y, this.y + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'j' || key === '\x1b[B') {
|
||||
var y = this.ydisp + this.y;
|
||||
this.y++;
|
||||
if (this.y >= this.rows) {
|
||||
this.y = this.rows - 1;
|
||||
this.scrollDisp(1);
|
||||
}
|
||||
this.refresh(this.y - 1, this.y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'h' || key === '\x1b[D') {
|
||||
var x = this.x;
|
||||
this.x--;
|
||||
if (this.x < 0) {
|
||||
this.x = 0;
|
||||
}
|
||||
this.refresh(this.y, this.y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'l' || key === '\x1b[C') {
|
||||
var x = this.x;
|
||||
this.x++;
|
||||
if (this.x >= this.cols) {
|
||||
this.x = this.cols - 1;
|
||||
}
|
||||
this.refresh(this.y, this.y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'w' || key === 'W') {
|
||||
var ox = this.x;
|
||||
var oy = this.y;
|
||||
var oyd = this.ydisp;
|
||||
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
var yb = this.ydisp;
|
||||
var saw_space = false;
|
||||
|
||||
for (;;) {
|
||||
var line = this.lines[yb + y];
|
||||
while (x < this.cols) {
|
||||
if (line[x][1] <= ' ') {
|
||||
saw_space = true;
|
||||
} else if (saw_space) {
|
||||
break;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
if (x >= this.cols) x = this.cols - 1;
|
||||
if (x === this.cols - 1 && line[x][1] <= ' ') {
|
||||
x = 0;
|
||||
if (++y >= this.rows) {
|
||||
y--;
|
||||
if (++yb > this.ybase) {
|
||||
yb = this.ybase;
|
||||
x = this.x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
this.x = x, this.y = y;
|
||||
this.scrollDisp(-this.ydisp + yb);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'b' || key === 'B') {
|
||||
var ox = this.x;
|
||||
var oy = this.y;
|
||||
var oyd = this.ydisp;
|
||||
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
var yb = this.ydisp;
|
||||
|
||||
for (;;) {
|
||||
var line = this.lines[yb + y];
|
||||
var saw_space = x > 0 && line[x][1] > ' ' && line[x - 1][1] > ' ';
|
||||
while (x >= 0) {
|
||||
if (line[x][1] <= ' ') {
|
||||
if (saw_space && (x + 1 < this.cols && line[x + 1][1] > ' ')) {
|
||||
x++;
|
||||
break;
|
||||
} else {
|
||||
saw_space = true;
|
||||
}
|
||||
}
|
||||
x--;
|
||||
}
|
||||
if (x < 0) x = 0;
|
||||
if (x === 0 && (line[x][1] <= ' ' || !saw_space)) {
|
||||
x = this.cols - 1;
|
||||
if (--y < 0) {
|
||||
y++;
|
||||
if (--yb < 0) {
|
||||
yb++;
|
||||
x = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
this.x = x, this.y = y;
|
||||
this.scrollDisp(-this.ydisp + yb);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'e' || key === 'E') {
|
||||
var x = this.x + 1;
|
||||
var y = this.y;
|
||||
var yb = this.ydisp;
|
||||
if (x >= this.cols) x--;
|
||||
|
||||
for (;;) {
|
||||
var line = this.lines[yb + y];
|
||||
while (x < this.cols) {
|
||||
if (line[x][1] <= ' ') {
|
||||
x++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (x < this.cols) {
|
||||
if (line[x][1] <= ' ') {
|
||||
if (x - 1 >= 0 && line[x - 1][1] > ' ') {
|
||||
x--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
x++;
|
||||
}
|
||||
if (x >= this.cols) x = this.cols - 1;
|
||||
if (x === this.cols - 1 && line[x][1] <= ' ') {
|
||||
x = 0;
|
||||
if (++y >= this.rows) {
|
||||
y--;
|
||||
if (++yb > this.ybase) {
|
||||
yb = this.ybase;
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
this.x = x, this.y = y;
|
||||
this.scrollDisp(-this.ydisp + yb);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === '^' || key === '0') {
|
||||
var ox = this.x;
|
||||
|
||||
if (key === '0') {
|
||||
this.x = 0;
|
||||
} else if (key === '^') {
|
||||
var line = this.lines[this.ydisp + this.y];
|
||||
var x = 0;
|
||||
while (x < this.cols) {
|
||||
if (line[x][1] > ' ') {
|
||||
break;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
if (x >= this.cols) x = this.cols - 1;
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
this.refresh(this.y, this.y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === '$') {
|
||||
var ox = this.x;
|
||||
var line = this.lines[this.ydisp + this.y];
|
||||
var x = this.cols - 1;
|
||||
while (x >= 0) {
|
||||
x--;
|
||||
}
|
||||
if (x < 0) x = 0;
|
||||
this.x = x;
|
||||
this.refresh(this.y, this.y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'g' || key === 'G') {
|
||||
var ox = this.x;
|
||||
var oy = this.y;
|
||||
var oyd = this.ydisp;
|
||||
if (key === 'g') {
|
||||
this.x = 0, this.y = 0;
|
||||
this.scrollDisp(-this.ydisp);
|
||||
} else if (key === 'G') {
|
||||
this.x = 0, this.y = this.rows - 1;
|
||||
this.scrollDisp(this.ybase);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'H' || key === 'M' || key === 'L') {
|
||||
var ox = this.x;
|
||||
var oy = this.y;
|
||||
if (key === 'H') {
|
||||
this.x = 0, this.y = 0;
|
||||
} else if (key === 'M') {
|
||||
this.x = 0, this.y = this.rows / 2 | 0;
|
||||
} else if (key === 'L') {
|
||||
this.x = 0, this.y = this.rows - 1;
|
||||
}
|
||||
this.refresh(oy, oy);
|
||||
this.refresh(this.y, this.y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === '{' || key === '}') {
|
||||
var ox = this.x;
|
||||
var oy = this.y;
|
||||
var oyd = this.ydisp;
|
||||
|
||||
var line;
|
||||
var saw_full = false;
|
||||
var found = false;
|
||||
var first_is_space = -1;
|
||||
var y = this.y + (key === '{' ? -1 : 1);
|
||||
var yb = this.ydisp;
|
||||
var i;
|
||||
|
||||
if (key === '{') {
|
||||
if (y < 0) {
|
||||
y++;
|
||||
if (yb > 0) yb--;
|
||||
}
|
||||
} else if (key === '}') {
|
||||
if (y >= this.rows) {
|
||||
y--;
|
||||
if (yb < this.ybase) yb++;
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
line = this.lines[yb + y];
|
||||
|
||||
for (i = 0; i < this.cols; i++) {
|
||||
if (line[i][1] > ' ') {
|
||||
if (first_is_space === -1) {
|
||||
first_is_space = 0;
|
||||
}
|
||||
saw_full = true;
|
||||
break;
|
||||
} else if (i === this.cols - 1) {
|
||||
if (first_is_space === -1) {
|
||||
first_is_space = 1;
|
||||
} else if (first_is_space === 0) {
|
||||
found = true;
|
||||
} else if (first_is_space === 1) {
|
||||
if (saw_full) found = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) break;
|
||||
|
||||
if (key === '{') {
|
||||
y--;
|
||||
if (y < 0) {
|
||||
y++;
|
||||
if (yb > 0) yb--;
|
||||
else break;
|
||||
}
|
||||
} else if (key === '}') {
|
||||
y++;
|
||||
if (y >= this.rows) {
|
||||
y--;
|
||||
if (yb < this.ybase) yb++;
|
||||
else break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
if (key === '{') {
|
||||
y = 0;
|
||||
yb = 0;
|
||||
} else if (key === '}') {
|
||||
y = this.rows - 1;
|
||||
yb = this.ybase;
|
||||
}
|
||||
}
|
||||
|
||||
this.x = 0, this.y = y;
|
||||
this.scrollDisp(-this.ydisp + yb);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Character Sets
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user