UNPKG

2.14 kBJavaScriptView Raw
1'use strict';
2
3module.exports = function (Terminal) {
4 Terminal.prototype.eraseRight = function(x, y) {
5 var line = this.lines[this.ybase + y],
6 ch = [this.curAttr, ' ']; // xterm
7
8 for (; x < this.cols; x++) {
9 line[x] = ch;
10 }
11
12 this.updateRange(y);
13 };
14
15 Terminal.prototype.eraseLeft = function(x, y) {
16 var line = this.lines[this.ybase + y],
17 ch = [this.curAttr, ' ']; // xterm
18
19 x++;
20 while (x--) line[x] = ch;
21
22 this.updateRange(y);
23 };
24
25 Terminal.prototype.eraseLine = function(y) {
26 this.eraseRight(0, y);
27 };
28
29 // CSI Ps J Erase in Display (ED).
30 // Ps = 0 -> Erase Below (default).
31 // Ps = 1 -> Erase Above.
32 // Ps = 2 -> Erase All.
33 // Ps = 3 -> Erase Saved Lines (xterm).
34 // CSI ? Ps J
35 // Erase in Display (DECSED).
36 // Ps = 0 -> Selective Erase Below (default).
37 // Ps = 1 -> Selective Erase Above.
38 // Ps = 2 -> Selective Erase All.
39 Terminal.prototype.eraseInDisplay = function(params) {
40 var j;
41 switch (params[0]) {
42 case 0:
43 this.eraseRight(this.x, this.y);
44 j = this.y + 1;
45 for (; j < this.rows; j++) {
46 this.eraseLine(j);
47 }
48 break;
49 case 1:
50 this.eraseLeft(this.x, this.y);
51 j = this.y;
52 while (j--) {
53 this.eraseLine(j);
54 }
55 break;
56 case 2:
57 j = this.rows;
58 while (j--) this.eraseLine(j);
59 break;
60 case 3:
61 ; // no saved lines
62 break;
63 }
64 };
65
66 // CSI Ps K Erase in Line (EL).
67 // Ps = 0 -> Erase to Right (default).
68 // Ps = 1 -> Erase to Left.
69 // Ps = 2 -> Erase All.
70 // CSI ? Ps K
71 // Erase in Line (DECSEL).
72 // Ps = 0 -> Selective Erase to Right (default).
73 // Ps = 1 -> Selective Erase to Left.
74 // Ps = 2 -> Selective Erase All.
75 Terminal.prototype.eraseInLine = function(params) {
76 switch (params[0]) {
77 case 0:
78 this.eraseRight(this.x, this.y);
79 break;
80 case 1:
81 this.eraseLeft(this.x, this.y);
82 break;
83 case 2:
84 this.eraseLine(this.y);
85 break;
86 }
87 };
88};