Skip to content

Commit

Permalink
Merge pull request #2355 from jerch/fix_2354
Browse files Browse the repository at this point in the history
DECSTBM issues
  • Loading branch information
Tyriar committed Aug 7, 2019
2 parents 61e5829 + 4200e83 commit 58e1b0d
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 49 deletions.
2 changes: 1 addition & 1 deletion fixtures/escape_sequence_files/t0070-DECSTBM_LF.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ r
s
t
uvwxyz


The end.
44 changes: 22 additions & 22 deletions fixtures/escape_sequence_files/t0070-DECSTBM_LF.text
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
1
2
6
7
8
9 ABC
6
7
8
9 ABC
DEF
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
yz qrstu vwx
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
yz vwx
The end.

2 changes: 1 addition & 1 deletion fixtures/escape_sequence_files/t0071-DECSTBM_IND.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1D2D3D4D5D6D7D8D9ABCDEFaDbDcDdDeDfDgDhDiDjDkDlDmDnDoDpDqDrDsDtDuvwxyz


The end.
4 changes: 2 additions & 2 deletions fixtures/escape_sequence_files/t0071-DECSTBM_IND.text
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
2
6
7
8
Expand All @@ -21,5 +20,6 @@ DEF
o
p
q
The end. rstu vwx
yz rstu vwx
The end.

11 changes: 5 additions & 6 deletions fixtures/escape_sequence_files/t0076-DECSTBM_IL_DL.text
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
6 C
8 ^^^^
9 vvvv DL on line 11, expected: ACD_
10 A
Expand All @@ -13,14 +12,14 @@
19 vvvv IL on line 21, expected: A_
20 A


22 ^^^^
24 A
25 B
27 vvvv DL on line 28, expected: B_

23 vvvv IL on line 24, expected: _A
25 B
26 ^^^^
28 A

29 B
30 ^^^^
31
32
32
24 changes: 24 additions & 0 deletions fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x12
25 changes: 25 additions & 0 deletions fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
a
b
c
d
e
f
g
h
i
2
k
l
m
n
o
p
q
r
1
t
u
v
w
x

24 changes: 24 additions & 0 deletions fixtures/escape_sequence_files/t0079-DECSTBM_VPR.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x1
25 changes: 25 additions & 0 deletions fixtures/escape_sequence_files/t0079-DECSTBM_VPR.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
1
40 changes: 30 additions & 10 deletions src/InputHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,13 @@ export class InputHandler extends Disposable implements IInputHandler {
if (wraparoundMode) {
buffer.x = 0;
buffer.y++;
if (buffer.y > buffer.scrollBottom) {
if (buffer.y === buffer.scrollBottom + 1) {
buffer.y--;
this._terminal.scroll(true);
} else {
if (buffer.y >= this._bufferService.rows) {
buffer.y = this._bufferService.rows - 1;
}
// The line already exists (eg. the initial viewport), mark it as a
// wrapped line
buffer.lines.get(buffer.y).isWrapped = true;
Expand Down Expand Up @@ -508,9 +511,11 @@ export class InputHandler extends Disposable implements IInputHandler {
buffer.x = 0;
}
buffer.y++;
if (buffer.y > buffer.scrollBottom) {
if (buffer.y === buffer.scrollBottom + 1) {
buffer.y--;
this._terminal.scroll();
} else if (buffer.y >= this._bufferService.rows) {
buffer.y = this._bufferService.rows - 1;
}
// If the end of the line is hit, prevent this action from wrapping around to the next line.
if (buffer.x >= this._bufferService.cols) {
Expand Down Expand Up @@ -611,15 +616,27 @@ export class InputHandler extends Disposable implements IInputHandler {
* Cursor Up Ps Times (default = 1) (CUU).
*/
public cursorUp(params: IParams): void {
this._moveCursor(0, -(params.params[0] || 1));
// stop at scrollTop
const diffToTop = this._bufferService.buffer.y - this._bufferService.buffer.scrollTop;
if (diffToTop >= 0) {
this._moveCursor(0, -Math.min(diffToTop, params.params[0] || 1));
} else {
this._moveCursor(0, -(params.params[0] || 1));
}
}

/**
* CSI Ps B
* Cursor Down Ps Times (default = 1) (CUD).
*/
public cursorDown(params: IParams): void {
this._moveCursor(0, params.params[0] || 1);
// stop at scrollBottom
const diffToBottom = this._bufferService.buffer.scrollBottom - this._bufferService.buffer.y;
if (diffToBottom >= 0) {
this._moveCursor(0, Math.min(diffToBottom, params.params[0] || 1));
} else {
this._moveCursor(0, params.params[0] || 1);
}
}

/**
Expand All @@ -644,7 +661,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* Other than cursorDown (CUD) also set the cursor to first column.
*/
public cursorNextLine(params: IParams): void {
this._moveCursor(0, params.params[0] || 1);
this.cursorDown(params);
this._bufferService.buffer.x = 0;
}

Expand All @@ -654,7 +671,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* Other than cursorUp (CUU) also set the cursor to first column.
*/
public cursorPrecedingLine(params: IParams): void {
this._moveCursor(0, -(params.params[0] || 1));
this.cursorUp(params);
this._bufferService.buffer.x = 0;
}

Expand Down Expand Up @@ -996,7 +1013,7 @@ export class InputHandler extends Disposable implements IInputHandler {

while (param--) {
buffer.lines.splice(buffer.ybase + buffer.scrollTop, 1);
buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA));
buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));
}
this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);
}
Expand All @@ -1013,7 +1030,7 @@ export class InputHandler extends Disposable implements IInputHandler {

while (param--) {
buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1);
buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA));
buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));
}
this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);
}
Expand Down Expand Up @@ -2043,10 +2060,13 @@ export class InputHandler extends Disposable implements IInputHandler {
*/
public index(): void {
this._restrictCursor();
const buffer = this._bufferService.buffer;
this._bufferService.buffer.y++;
if (this._bufferService.buffer.y > this._bufferService.buffer.scrollBottom) {
this._bufferService.buffer.y--;
if (buffer.y === buffer.scrollBottom + 1) {
buffer.y--;
this._terminal.scroll();
} else if (buffer.y >= this._bufferService.rows) {
buffer.y = this._bufferService.rows - 1;
}
this._restrictCursor();
}
Expand Down
8 changes: 1 addition & 7 deletions src/Terminal2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ const ROWS = 25;

const TESTFILES = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..')});
const SKIP_FILES = [
't0070-DECSTBM_LF.in', // lineFeed not working correctly
't0071-DECSTBM_IND.in',
't0072-DECSTBM_NEL.in',
't0075-DECSTBM_CUU_CUD.in',
't0076-DECSTBM_IL_DL.in', // not working due to lineFeed
't0077-DECSTBM_quirks.in',
't0084-CBT.in',
't0101-NLM.in',
't0103-reverse_wrap.in',
Expand All @@ -42,7 +36,7 @@ const FILES = TESTFILES.filter(value => SKIP_FILES.indexOf(value.split('/').slic


describe('Escape Sequence Files', function(): void {
this.timeout(20000);
this.timeout(1000);

let ptyTerm: any;
let slaveEnd: any;
Expand Down

0 comments on commit 58e1b0d

Please sign in to comment.