Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xterm test cases #161

Merged
merged 12 commits into from
Jul 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{
"name": "xterm",
"version": "0.33.0",
"ignore": ["demo", "test", ".gitignore"],
"ignore": [
"demo",
"test",
".gitignore"
],
"main": "src/xterm.js",
"repository": "https://github.com/sourcelair/xterm.js",
"license": "MIT",
"devDependencies": {
"chai": "3.5.0",
"docdash": "0.4.0",
"express": "4.13.4",
"express-ws": "2.0.0-rc.1",
"pty.js": "0.3.0",
"mocha": "2.5.3",
"chai": "3.5.0",
"glob": "^7.0.5",
"jsdoc": "3.4.0",
"docdash": "0.4.0"
"mocha": "2.5.3",
"pty.js": "0.3.0",
"sleep": "^3.0.1"
},
"scripts": {
"start": "node demo/app",
Expand Down
71 changes: 49 additions & 22 deletions src/xterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
this.applicationCursor = false;
this.originMode = false;
this.insertMode = false;
this.wraparoundMode = false;
this.wraparoundMode = true; // defaults: xterm - true, vt100 - false
this.normal = null;

// charset
Expand Down Expand Up @@ -1467,7 +1467,7 @@
* @public
*/
Terminal.prototype.write = function(data) {
var l = data.length, i = 0, j, cs, ch, code, low, ch_width;
var l = data.length, i = 0, j, cs, ch, code, low, ch_width, row;

this.refreshStart = this.y;
this.refreshEnd = this.y;
Expand Down Expand Up @@ -1569,20 +1569,22 @@
ch = this.charset[ch];
}

row = this.y + this.ybase;

// insert combining char in last cell
// FIXME: needs handling after cursor jumps
if (!ch_width && this.x) {

// dont overflow left
if (this.lines[this.y + this.ybase][this.x-1]) {
if (!this.lines[this.y + this.ybase][this.x-1][2]) {
if (this.lines[row][this.x-1]) {
if (!this.lines[row][this.x-1][2]) {

// found empty cell after fullwidth, need to go 2 cells back
if (this.lines[this.y + this.ybase][this.x-2])
this.lines[this.y + this.ybase][this.x-2][1] += ch;
if (this.lines[row][this.x-2])
this.lines[row][this.x-2][1] += ch;

} else {
this.lines[this.y + this.ybase][this.x-1][1] += ch;
this.lines[row][this.x-1][1] += ch;
}
this.updateRange(this.y);
}
Expand All @@ -1592,21 +1594,46 @@
// goto next line if ch would overflow
// TODO: needs a global min terminal width of 2
if (this.x+ch_width-1 >= this.cols) {
this.x = 0;
this.y++;
if (this.y > this.scrollBottom) {
this.y--;
this.scroll();
// autowrap - DECAWM
if (this.wraparoundMode) {
this.x = 0;
this.y++;
if (this.y > this.scrollBottom) {
this.y--;
this.scroll();
}
} else {
this.x = this.cols-1;
if(ch_width===2) // FIXME: check for xterm behavior
continue;
}
}
row = this.y + this.ybase;

// insert mode: move characters to right
if (this.insertMode) {
// do this twice for a fullwidth char
for (var moves=0; moves<ch_width; ++moves) {
// remove last cell, if it's width is 0
// we have to adjust the second last cell as well
var removed = this.lines[this.y + this.ybase].pop();
if (removed[2]===0
&& this.lines[row][this.cols-2]
&& this.lines[row][this.cols-2][2]===2)
this.lines[row][this.cols-2] = [this.curAttr, ' ', 1];

// insert empty cell at cursor
this.lines[row].splice(this.x, 0, [this.curAttr, ' ', 1]);
}
}

this.lines[this.y + this.ybase][this.x] = [this.curAttr, ch, ch_width];
this.lines[row][this.x] = [this.curAttr, ch, ch_width];
this.x++;
this.updateRange(this.y);

// fullwidth char - set next cell width to zero and advance cursor
if (ch_width==2) {
this.lines[this.y + this.ybase][this.x] = [this.curAttr, '', 0];
if (ch_width===2) {
this.lines[row][this.x] = [this.curAttr, '', 0];
this.x++;
}
}
Expand Down Expand Up @@ -3469,7 +3496,7 @@

row = this.y + this.ybase;
j = this.x;
ch = [this.eraseAttr(), ' ']; // xterm
ch = [this.eraseAttr(), ' ', 1]; // xterm

while (param-- && j < this.cols) {
this.lines[row].splice(j++, 0, ch);
Expand Down Expand Up @@ -3566,7 +3593,7 @@
if (param < 1) param = 1;

row = this.y + this.ybase;
ch = [this.eraseAttr(), ' ']; // xterm
ch = [this.eraseAttr(), ' ', 1]; // xterm

while (param--) {
this.lines[row].splice(this.x, 1);
Expand All @@ -3584,7 +3611,7 @@

row = this.y + this.ybase;
j = this.x;
ch = [this.eraseAttr(), ' ']; // xterm
ch = [this.eraseAttr(), ' ', 1]; // xterm

while (param-- && j < this.cols) {
this.lines[row][j++] = ch;
Expand Down Expand Up @@ -4198,7 +4225,7 @@
Terminal.prototype.repeatPrecedingCharacter = function(params) {
var param = params[0] || 1
, line = this.lines[this.ybase + this.y]
, ch = line[this.x - 1] || [this.defAttr, ' '];
, ch = line[this.x - 1] || [this.defAttr, ' ', 1];

while (param--) line[this.x++] = ch;
};
Expand Down Expand Up @@ -4460,7 +4487,7 @@
, i
, ch;

ch = [this.eraseAttr(), ' ']; // xterm?
ch = [this.eraseAttr(), ' ', 1]; // xterm?

for (; t < b + 1; t++) {
line = this.lines[this.ybase + t];
Expand All @@ -4481,7 +4508,7 @@
Terminal.prototype.insertColumns = function() {
var param = params[0]
, l = this.ybase + this.rows
, ch = [this.eraseAttr(), ' '] // xterm?
, ch = [this.eraseAttr(), ' ', 1] // xterm?
, i;

while (param--) {
Expand All @@ -4501,7 +4528,7 @@
Terminal.prototype.deleteColumns = function() {
var param = params[0]
, l = this.ybase + this.rows
, ch = [this.eraseAttr(), ' '] // xterm?
, ch = [this.eraseAttr(), ' ', 1] // xterm?
, i;

while (param--) {
Expand Down
21 changes: 21 additions & 0 deletions test/escape_sequence_files/NOTES
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
All tests are made for 80x25 terminal. Make sure to run tests with 80x25.

Create .text files from xterm (expected output)
- open xterm
- resize xterm to 80x25
- run `python run_tests.py`
- copy & paste whole window output into editor
- add 26th empty line (due to line handling in toString) - not a bug, a feature ;)
- advance to next test with ^D


Known problems
##############


t0031-HBP:
- no documentation at all about CSIj found - skipping

t0050-ICH:
- bug in xterm? (cant ICH last real char, always sticks to last col)
- text used from https://github.com/MarkLodato/vt100-parser/blob/master/test/t0050-ICH.text
6 changes: 6 additions & 0 deletions test/escape_sequence_files/t0001-all_printable.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~
25 changes: 25 additions & 0 deletions test/escape_sequence_files/t0001-all_printable.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~



















95 changes: 95 additions & 0 deletions test/escape_sequence_files/t0002-history.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

!
"
#
$
%
&
'
(
)
*
+
,
-
.
/
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~
25 changes: 25 additions & 0 deletions test/escape_sequence_files/t0002-history.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~

1 change: 1 addition & 0 deletions test/escape_sequence_files/t0002j-simple_string.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abcdefghijklmnopqrstuvwxyz0123456789
25 changes: 25 additions & 0 deletions test/escape_sequence_files/t0002j-simple_string.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
abcdefghijklmnopqrstuvwxyz0123456789
























Loading