Skip to content

Commit fecffaf

Browse files
committed
Fix for WINDOW and WDWTITLE
Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
1 parent b304d5b commit fecffaf

File tree

3 files changed

+71
-7
lines changed

3 files changed

+71
-7
lines changed

src/dspf.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class DisplayFile {
273273
switch (value[i]) {
274274
case `+`:
275275
case `-`:
276-
if (!inString) {
276+
if (!inString && value[i+1] !== newLineMark) {
277277
innerValue += value[i];
278278
}
279279
break;
@@ -377,15 +377,41 @@ class RecordInfo {
377377
this.isWindow = true;
378378
let points = keyword.value.split(' ');
379379

380+
381+
if (points.length >= 3 && points[0].toUpperCase() === `*DFT`) {
382+
// WINDOW (*DFT Y X)
383+
this.windowSize = {
384+
y: 2,
385+
x: 2,
386+
width: Number(points[2]),
387+
height: Number(points[1])
388+
};
389+
} else {
390+
if (points.length === 1) {
391+
// WINDOW (REF)
392+
this.windowReference = points[0];
393+
394+
} else if (points.length >= 4) {
395+
// WINDOW (*DFT SY SX Y X)
396+
this.windowSize = {
397+
y: Number(points[0]) || 2,
398+
x: Number(points[1]) || 2,
399+
width: Number(points[3]),
400+
height: Number(points[2])
401+
};
402+
}
403+
}
404+
405+
switch (points[0]) {
406+
case `*DFT`:
407+
break;
408+
409+
}
410+
380411
switch (points.length) {
381412
case 4:
382413
//WINDOW (STARTY STARTX SIZEY SIZEX)
383-
this.windowSize = {
384-
y: Number(points[0]) || 2,
385-
x: Number(points[1]) || 2,
386-
width: Number(points[3]),
387-
height: Number(points[2])
388-
};
414+
389415
break;
390416
case 1:
391417
//WINDOW (REF)

test/file/issue1149.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
exports.lines = [
2+
` A R HELP`,
3+
` A*%%TS SD 20080304 144943 PGML REL-V5R4M0 5722-WDS`,
4+
` A KEEP`,
5+
` A OVERLAY`,
6+
` A WINDOW(10 2 10 70 *NORSTCSR)`,
7+
` A WDWBORDER((*DSPATR RI) (*CHAR ':.::-`,
8+
` A ::.:'))`,
9+
` A WDWTITLE((*TEXT 'Print accounts by -`,
10+
` A store number for status type - Help-`,
11+
` A ') (*COLOR WHT))`,
12+
` A 1 26'Print accounts - Help'`,
13+
` A COLOR(WHT)`,
14+
` A 3 3'This report print all accounts of -`,
15+
` A selected status for a store or all'`,
16+
` A 4 2'stores. An account will print for-`,
17+
` A a store only if that store has'`,
18+
` A 5 2'taken a check from that account. -`,
19+
` A You can only select one status type'`,
20+
` A 6 2'for each report request.'`,
21+
` A 9 2'Press Enter to return'`,
22+
]

test/tests.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const assert = require("assert");
22
const { DisplayFile } = require("../src/dspf");
3+
34
const depts = require("./file/depts");
45
const replloadfm = require("./file/replloadfm");
6+
const issue1149 = require(`./file/issue1149`);
57

68
exports.simple = () => {
79
const file = new DisplayFile();
@@ -135,4 +137,18 @@ exports.window = () => {
135137
assert.deepStrictEqual(confirmWindowFormat.windowSize, {
136138
height: 6, width: 54, x: 6, y: 6
137139
});
140+
}
141+
142+
exports.issue1149 = () => {
143+
const file = new DisplayFile();
144+
file.parse(issue1149.lines);
145+
146+
const windowFormat = file.formats[1];
147+
assert.strictEqual(windowFormat.name, `HELP`);
148+
assert.deepStrictEqual(windowFormat.windowSize, {
149+
height: 10, width: 70, x: 2, y: 10
150+
});
151+
152+
const windowTitle = windowFormat.keywords.find(keyword => keyword.name === `WDWTITLE`);
153+
assert.strictEqual(windowTitle.value, `*TEXT 'Print accounts by store number for status type - Help' *COLOR WHT`);
138154
}

0 commit comments

Comments
 (0)