3
|
1 /**
|
|
2 * Title: tn5250J
|
|
3 * Copyright: Copyright (c) 2001
|
|
4 * Company:
|
|
5 * @author Kenneth J. Pouncey
|
|
6 * @version 0.5
|
|
7 *
|
|
8 * Description:
|
|
9 *
|
|
10 * This program is free software; you can redistribute it and/or modify
|
|
11 * it under the terms of the GNU General Public License as published by
|
|
12 * the Free Software Foundation; either version 2, or (at your option)
|
|
13 * any later version.
|
|
14 *
|
|
15 * This program is distributed in the hope that it will be useful,
|
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 * GNU General Public License for more details.
|
|
19 *
|
|
20 * You should have received a copy of the GNU General Public License
|
|
21 * along with this software; see the file COPYING. If not, write to
|
|
22 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
23 * Boston, MA 02111-1307 USA
|
|
24 *
|
|
25 */
|
|
26 package org.tn5250j.framework.tn5250;
|
|
27
|
|
28 import static org.tn5250j.TN5250jConstants.BOTTOM;
|
|
29 import static org.tn5250j.TN5250jConstants.GUI_LEFT;
|
|
30 import static org.tn5250j.TN5250jConstants.GUI_RIGHT;
|
|
31 import static org.tn5250j.TN5250jConstants.LOWER_LEFT;
|
|
32 import static org.tn5250j.TN5250jConstants.LOWER_RIGHT;
|
|
33 import static org.tn5250j.TN5250jConstants.NO_GUI;
|
|
34 import static org.tn5250j.TN5250jConstants.NR_REQUEST_ERROR;
|
|
35 import static org.tn5250j.TN5250jConstants.UPPER;
|
|
36 import static org.tn5250j.TN5250jConstants.UPPER_LEFT;
|
|
37 import static org.tn5250j.TN5250jConstants.UPPER_RIGHT;
|
|
38
|
|
39 import java.util.ArrayList;
|
|
40 import java.util.List;
|
|
41
|
|
42 import org.tn5250j.encoding.ICodePage;
|
|
43 import org.tn5250j.tools.logging.TN5250jLogFactory;
|
|
44 import org.tn5250j.tools.logging.TN5250jLogger;
|
|
45
|
|
46 /**
|
|
47 *
|
|
48 * Write To Display Structured Field:
|
|
49 *
|
|
50 * This module will parse the structured field information for enhanced
|
|
51 * emulation mode.
|
|
52 *
|
|
53 */
|
|
54 public class WTDSFParser {
|
|
55
|
|
56 private Screen5250 screen52;
|
|
57 private tnvt vt;
|
|
58 private ICodePage codePage;
|
|
59 int pos;
|
|
60 byte[] segment;
|
|
61 int length;
|
|
62 boolean error;
|
|
63 boolean guiStructsExist;
|
|
64
|
|
65 private TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass());
|
|
66
|
|
67 private final List<Window> guiStructs = new ArrayList<Window>(3);
|
|
68 private final List<ChoiceField> choices = new ArrayList<ChoiceField>(3);
|
|
69
|
|
70
|
|
71 WTDSFParser (tnvt vt) {
|
|
72
|
|
73 this.vt = vt;
|
|
74 screen52 = vt.screen52;
|
|
75 codePage = vt.codePage;
|
|
76
|
|
77 }
|
|
78
|
|
79 protected class ChoiceField {
|
|
80
|
|
81 int x;
|
|
82 int y;
|
|
83 int row;
|
|
84 int col;
|
|
85 int width;
|
|
86 int height;
|
|
87 char mnemonic;
|
|
88 int fieldId;
|
|
89 int selectIndex;
|
|
90
|
|
91 ChoiceField(int row, int col, int fldRow, int fldCol) {
|
|
92 x = row;
|
|
93 y = col;
|
|
94 row = fldRow;
|
|
95 col = fldCol;
|
|
96 }
|
|
97 }
|
|
98
|
|
99 protected class Window {
|
|
100
|
|
101 byte[] window;
|
|
102 int pos;
|
|
103
|
|
104 Window(byte[] seg, int pos) {
|
|
105
|
|
106 //log.info("window created at " + pos);
|
|
107 window = seg;
|
|
108 this.pos = pos;
|
|
109 guiStructsExist = true;
|
|
110 }
|
|
111
|
|
112 }
|
|
113
|
|
114 protected void addChoiceField(int row,int col,int fldRow, int fldCol, String text) {
|
|
115
|
|
116 ChoiceField cf = new ChoiceField(row,col, fldRow, fldCol);
|
|
117 cf.fieldId = screen52.getScreenFields().getCurrentField().getFieldId();
|
|
118 choices.add(cf);
|
|
119
|
|
120 }
|
|
121
|
|
122 protected boolean isGuisExists () {
|
|
123
|
|
124 return guiStructsExist;
|
|
125
|
|
126 }
|
|
127
|
|
128 protected byte[] getSegmentAtPos(int pos) {
|
|
129 int len = guiStructs.size();
|
|
130 for (int x = 0; x < len; x++) {
|
|
131 Window w = guiStructs.get(x);
|
|
132 if (w.pos == pos)
|
|
133 return w.window;
|
|
134 }
|
|
135
|
|
136 return null;
|
|
137
|
|
138 }
|
|
139
|
|
140 protected void clearGuiStructs() {
|
|
141
|
|
142 guiStructs.clear();
|
|
143 }
|
|
144
|
|
145 protected boolean parseWriteToDisplayStructuredField(byte[] seg) {
|
|
146
|
|
147 // bk = vt.bk;
|
|
148
|
|
149 error = false;
|
|
150 boolean done = false;
|
|
151 boolean windowDefined = false;
|
|
152 // int nextone;
|
|
153 pos = 0;
|
|
154 segment = seg;
|
|
155
|
|
156 // try {
|
|
157 length = (( segment[pos++] & 0xff )<< 8 | (segment[pos++] & 0xff));
|
|
158
|
|
159 while (!done) {
|
|
160 int s = segment[pos++] & 0xff;
|
|
161 switch (s) {
|
|
162
|
|
163 case 0xD9: // Class Type 0xD9 - Create Window
|
|
164
|
|
165 switch (segment[pos++]) {
|
|
166 case 0x50: // Define Selection Field
|
|
167
|
|
168 defineSelectionField(length);
|
|
169 done = true;
|
|
170 break;
|
|
171 case 0x51: // Create Window
|
|
172
|
|
173 guiStructs.add(new Window(segment, screen52.getLastPos()));
|
|
174
|
|
175 boolean cr = false;
|
|
176 int rows = 0;
|
|
177 int cols = 0;
|
|
178 // pull down not supported yet
|
|
179 if ((segment[pos++] & 0x80) == 0x80)
|
|
180 cr = true; // restrict cursor
|
|
181 pos++; // get reserved field pos 6
|
|
182 pos++; // get reserved field pos 7
|
|
183 rows = segment[pos++]; // get window depth rows pos 8
|
|
184 cols = segment[pos++]; // get window width cols pos 9
|
|
185 length -= 9;
|
|
186 if (length == 0) {
|
|
187 done = true;
|
|
188 // System.out.println("Create Window");
|
|
189 // System.out.println(" restrict cursor " + cr);
|
|
190 // System.out.println(" Depth = " + rows + " Width = " + cols);
|
|
191 // screen52.createWindow(rows,cols,1,true,32,58,
|
|
192 createWindow(rows,cols,1,true,32,58,
|
|
193 '.',
|
|
194 '.',
|
|
195 '.',
|
|
196 ':',
|
|
197 ':',
|
|
198 ':',
|
|
199 '.',
|
|
200 ':');
|
|
201 windowDefined = true;
|
|
202 break;
|
|
203 }
|
|
204
|
|
205 // pos 10 is Minor Structure
|
|
206 int ml = 0;
|
|
207 int type = 0;
|
|
208 int lastPos = screen52.getLastPos();
|
|
209 // if (cr)
|
|
210 // screen52.setPendingInsert(true,
|
|
211 // screen52.getCurrentRow(),
|
|
212 // screen52.getCurrentCol());
|
|
213 int mAttr = 0;
|
|
214 int cAttr = 0;
|
|
215
|
|
216 while (length > 0) {
|
|
217
|
|
218 // get minor length
|
|
219 ml = ( segment[pos++] & 0xff );
|
|
220 length -= ml;
|
|
221
|
|
222 // only normal windows are supported at this time
|
|
223 type = segment[pos++];
|
|
224
|
|
225 switch (type) {
|
|
226
|
|
227 case 0x01 : // Border presentation
|
|
228 boolean gui = false;
|
|
229 if ((segment[pos++] & 0x80) == 0x80)
|
|
230 gui = true;
|
|
231 mAttr = segment[pos++];
|
|
232 cAttr = segment[pos++];
|
|
233
|
|
234 char ul = '.';
|
|
235 char upper = '.';
|
|
236 char ur = '.';
|
|
237 char left = ':';
|
|
238 char right = ':';
|
|
239 char ll = ':';
|
|
240 char bottom = '.';
|
|
241 char lr = ':';
|
|
242
|
|
243 // if minor length is greater than 5 then
|
|
244 // the border characters are specified
|
|
245 if (ml > 5) {
|
|
246 ul = codePage.ebcdic2uni(segment[pos++]);
|
|
247 // ul = getASCIIChar(segment[pos++]);
|
|
248 if (ul == 0)
|
|
249 ul = '.';
|
|
250
|
|
251 upper = codePage.ebcdic2uni(segment[pos++]);
|
|
252 // upper = getASCIIChar(segment[pos++]);
|
|
253 if (upper == 0)
|
|
254 upper = '.';
|
|
255
|
|
256 ur = codePage.ebcdic2uni(segment[pos++]);
|
|
257 // ur = getASCIIChar(segment[pos++]);
|
|
258 if (ur == 0)
|
|
259 ur = '.';
|
|
260
|
|
261 left = codePage.ebcdic2uni(segment[pos++]);
|
|
262 // left = getASCIIChar(segment[pos++]);
|
|
263 if (left == 0)
|
|
264 left = ':';
|
|
265
|
|
266 right = codePage.ebcdic2uni(segment[pos++]);
|
|
267 // right = getASCIIChar(segment[pos++]);
|
|
268 if (right == 0)
|
|
269 right = ':';
|
|
270
|
|
271 ll = codePage.ebcdic2uni(segment[pos++]);
|
|
272 // ll = getASCIIChar(segment[pos++]);
|
|
273 if (ll == 0)
|
|
274 ll = ':';
|
|
275
|
|
276 bottom = codePage.ebcdic2uni(segment[pos++]);
|
|
277 // bottom = getASCIIChar(segment[pos++]);
|
|
278 if (bottom == 0)
|
|
279 bottom = '.';
|
|
280
|
|
281 lr = codePage.ebcdic2uni(segment[pos++]);
|
|
282 // lr = getASCIIChar(segment[pos++]);
|
|
283 if (lr == 0)
|
|
284 lr = ':';
|
|
285 }
|
|
286
|
|
287 // System.out.println("Create Window");
|
|
288 // System.out.println(" restrict cursor " + cr);
|
|
289 // System.out.println(" Depth = " + rows + " Width = " + cols);
|
|
290 // System.out.println(" type = " + type + " gui = " + gui);
|
|
291 // System.out.println(" mono attr = " + mAttr + " color attr = " + cAttr);
|
|
292 // System.out.println(" ul = " + ul + " upper = " + upper +
|
|
293 // " ur = " + ur +
|
|
294 // " left = " + left +
|
|
295 // " right = " + right +
|
|
296 // " ll = " + ll +
|
|
297 // " bottom = " + bottom +
|
|
298 // " lr = " + lr
|
|
299 // );
|
|
300 // screen52.createWindow(rows,cols,type,gui,mAttr,cAttr,
|
|
301 createWindow(rows,cols,type,gui,mAttr,cAttr,
|
|
302 ul,
|
|
303 upper,
|
|
304 ur,
|
|
305 left,
|
|
306 right,
|
|
307 ll,
|
|
308 bottom,
|
|
309 lr);
|
|
310 windowDefined = true;
|
|
311 break;
|
|
312 //
|
|
313 // The following shows the input for window with a title
|
|
314 //
|
|
315 // +0000 019A12A0 00000400 00020411 00200107 .?.?..?...?..?.
|
|
316 // +0010 00000018 00000011 06131500 37D95180 ........?.?..R??
|
|
317 // +0020 00000A24 0D018023 23404040 40404040 ..??..???
|
|
318 // +0030 40211000 000000D7 C2C1D9C4 C5D4D67A \uFFFD.....PBARDEMO:
|
|
319 // +0040 40D79996 879985A2 A2408281 99408485 Progress bar de
|
|
320 // +0050 94961108 1520D5A4 94828599 40968640 mo.???Number of
|
|
321 // +0060 8595A399 8985A24B 4B4B4B4B 4B7A2011 entries......:?.
|
|
322 // +0070 082E2040 404040F5 F0F06BF0 F0F02011 ?.? 500,000?.
|
|
323 // +0080 091520C3 A4999985 95A34085 95A399A8 \uFFFD??Current entry
|
|
324 // +0090 4095A494 8285994B 4B4B7A20 11092E20 number...:?.\uFFFD.?
|
|
325 // +00A0 40404040 4040F56B F0F0F020 110A1520 5,000?.???
|
|
326 // +00B0 D9859481 89958995 87408595 A3998985 Remaining entrie
|
|
327 // +00C0 A24B4B4B 4B4B4B7A 20110A2E 20404040 s......:?.?.?
|
|
328 // +00D0 40F4F9F5 6BF0F0F0 20110C15 20E2A381 495,000?..??Sta
|
|
329 // +00E0 99A340A3 8994854B 4B4B4B4B 4B4B4B4B rt time.........
|
|
330 // +00F0 4B4B4B4B 7A20110C 2F2040F7 7AF5F37A ....:?...? 7:53:
|
|
331
|
|
332 case 0x10 : // Window title/footer
|
|
333 if (!windowDefined) {
|
|
334 // screen52.createWindow(rows,cols,1,true,32,58,
|
|
335 guiStructs.add(new Window(segment, screen52.getLastPos()));
|
|
336 createWindow(rows,cols,1,true,32,58,
|
|
337 '.',
|
|
338 '.',
|
|
339 '.',
|
|
340 ':',
|
|
341 ':',
|
|
342 ':',
|
|
343 '.',
|
|
344 ':');
|
|
345 windowDefined = true;
|
|
346 }
|
|
347
|
|
348 byte orientation = segment[pos++];
|
|
349 mAttr = segment[pos++];
|
|
350 cAttr = segment[pos++];
|
|
351
|
|
352 //reserved
|
|
353 pos++;
|
|
354 ml -= 6;
|
|
355
|
|
356 StringBuffer hfBuffer = new StringBuffer(ml);
|
|
357 while (ml-- > 0) {
|
|
358 //LDC - 13/02/2003 - Convert it to unicode
|
|
359 hfBuffer.append(codePage.ebcdic2uni(segment[pos++]));
|
|
360 // hfBuffer.append(getASCIIChar(segment[pos++]));
|
|
361
|
|
362 }
|
|
363
|
|
364 log.debug(
|
|
365 " orientation " + Integer.toBinaryString(orientation) +
|
|
366 " mAttr " + mAttr +
|
|
367 " cAttr " + cAttr +
|
|
368 " Header/Footer " + hfBuffer);
|
|
369 screen52.writeWindowTitle(lastPos,
|
|
370 rows,
|
|
371 cols,
|
|
372 orientation,
|
|
373 mAttr,
|
|
374 cAttr,
|
|
375 hfBuffer);
|
|
376 break;
|
|
377 default:
|
|
378 log.warn("Invalid Window minor structure");
|
|
379 length = 0;
|
|
380 done = true;
|
|
381 }
|
|
382
|
|
383 }
|
|
384
|
|
385 done = true;
|
|
386
|
|
387 break;
|
|
388
|
|
389 case 0x53: // Scroll Bar
|
|
390 int sblen = 15;
|
|
391 byte sbflag = segment[pos++]; // flag position 5
|
|
392
|
|
393 pos++; // reserved position 6
|
|
394
|
|
395 // position 7,8
|
|
396 int totalRowScrollable = (( segment[pos++] & 0xff )<< 8
|
|
397 | (segment[pos++] & 0xff));
|
|
398
|
|
399 // position 9,10
|
|
400 int totalColScrollable = (( segment[pos++] & 0xff )<< 8
|
|
401 | (segment[pos++] & 0xff));
|
|
402
|
|
403 // position 11,12
|
|
404 int sliderRowPos = (( segment[pos++] & 0xff )<< 8
|
|
405 | (segment[pos++] & 0xff));
|
|
406
|
|
407 // position 13,14
|
|
408 int sliderColPos = (( segment[pos++] & 0xff )<< 8
|
|
409 | (segment[pos++] & 0xff));
|
|
410
|
|
411 // position 15
|
|
412 int sliderRC = segment[pos++];
|
|
413
|
|
414 screen52.createScrollBar(sbflag,totalRowScrollable,
|
|
415 totalColScrollable,
|
|
416 sliderRowPos,
|
|
417 sliderColPos,
|
|
418 sliderRC);
|
|
419 length -= 15;
|
|
420
|
|
421 done = true;
|
|
422
|
|
423 break;
|
|
424
|
|
425 case 0x5B: // Remove GUI ScrollBar field
|
|
426
|
|
427 pos++; // reserved must be set to off pos 5
|
|
428 pos++; // reserved must be set to zero pos 6
|
|
429
|
|
430 done = true;
|
|
431 break;
|
|
432
|
|
433 case 0x5F: // Remove All GUI Constructs
|
|
434 log.info("remove all gui contructs");
|
|
435 clearGuiStructs();
|
|
436 guiStructsExist = false;
|
|
437 int len = 4;
|
|
438 int d = 0;
|
|
439 length -= s;
|
|
440 while (--len > 0)
|
|
441 d = segment[pos++];
|
|
442 // if (length > 0) {
|
|
443 // len = (segment[pos++] & 0xff )<< 8;
|
|
444 //
|
|
445 // while (--len > 0)
|
|
446 // d = segment[pos++];
|
|
447 // }
|
|
448
|
|
449 screen52.clearGuiStuff();
|
|
450 // per 14.6.13.4 documentation we should clear the
|
|
451 // format table after this command
|
|
452 screen52.clearTable();
|
|
453 done = true;
|
|
454 break;
|
|
455 case 0x59: // remove gui window
|
|
456 log.info(" remove window at " + screen52.getCurrentPos());
|
|
457 done = true;
|
|
458 break;
|
|
459
|
|
460 case 0x60: // Erase/Draw Grid Lines - not supported
|
|
461 // do not know what they are
|
|
462 // as of 03/11/2002 we should not be getting
|
|
463 // this anymore but I will leave it here
|
|
464 // just in case.
|
|
465 // System.out.println("erase/draw grid lines " + length);
|
|
466 len = 6;
|
|
467 d = 0;
|
|
468 length -= 9;
|
|
469 while (--len > 0)
|
|
470 d = segment[pos++];
|
|
471 if (length > 0) {
|
|
472 len = (segment[pos++] & 0xff )<< 8;
|
|
473
|
|
474 while (--len > 0) {
|
|
475 d = segment[pos++];
|
|
476 }
|
|
477 }
|
|
478 done = true;
|
|
479 break;
|
|
480 default:
|
|
481 vt.sendNegResponse(NR_REQUEST_ERROR,0x03,0x01,0x01,"invalid wtd structured field sub command "
|
|
482 + ( pos - 1));
|
|
483 // + bk.getByteOffset(-1));
|
|
484 error = true;
|
|
485 break;
|
|
486 }
|
|
487 break;
|
|
488
|
|
489 default:
|
|
490 vt.sendNegResponse(NR_REQUEST_ERROR,0x03,0x01,0x01,
|
|
491 "invalid wtd structured field command "
|
|
492 + (pos - 1));
|
|
493 // + bk.getByteOffset(-1));
|
|
494 error = true;
|
|
495 break;
|
|
496 }
|
|
497
|
|
498 if (error)
|
|
499 done = true;
|
|
500
|
|
501 }
|
|
502 // }
|
|
503 // catch (Exception e) {};
|
|
504
|
|
505 return error;
|
|
506
|
|
507 }
|
|
508
|
|
509 /**
|
|
510 * Creates a window on the screen
|
|
511 *
|
|
512 * @param depth
|
|
513 * @param width
|
|
514 * @param type
|
|
515 * @param gui
|
|
516 * @param monoAttr
|
|
517 * @param colorAttr
|
|
518 * @param ul
|
|
519 * @param upper
|
|
520 * @param ur
|
|
521 * @param left
|
|
522 * @param right
|
|
523 * @param ll
|
|
524 * @param bottom
|
|
525 * @param lr
|
|
526 */
|
|
527 protected void createWindow(int depth, int width, int type, boolean gui,
|
|
528 int monoAttr, int colorAttr, int ul, int upper, int ur, int left,
|
|
529 int right, int ll, int bottom, int lr) {
|
|
530
|
|
531 int lastPos = screen52.getLastPos();
|
|
532 int numCols = screen52.getColumns();
|
|
533
|
|
534 int c = screen52.getCol(lastPos);
|
|
535 int w = 0;
|
|
536 width++;
|
|
537
|
|
538 w = width;
|
|
539 char initChar = Screen5250.initChar;
|
|
540 int initAttr = Screen5250.initAttr;
|
|
541
|
|
542 // set leading attribute byte
|
|
543 screen52.setScreenCharAndAttr(initChar, initAttr, true);
|
|
544
|
|
545 // set upper left
|
|
546 if (gui) {
|
|
547 screen52.setScreenCharAndAttr((char) ul, colorAttr, UPPER_LEFT, false);
|
|
548 }
|
|
549 else {
|
|
550 screen52.setScreenCharAndAttr((char) ul, colorAttr, false);
|
|
551 }
|
|
552
|
|
553 // draw top row
|
|
554 while (w-- >= 0) {
|
|
555 if (gui) {
|
|
556 screen52.setScreenCharAndAttr((char) upper, colorAttr, UPPER,false);
|
|
557 }
|
|
558 else {
|
|
559 screen52.setScreenCharAndAttr((char) upper, colorAttr, false);
|
|
560 }
|
|
561 }
|
|
562
|
|
563 // set upper right
|
|
564 if (gui) {
|
|
565 screen52.setScreenCharAndAttr((char) ur, colorAttr, UPPER_RIGHT, false);
|
|
566 }
|
|
567 else {
|
|
568 screen52.setScreenCharAndAttr((char) ur, colorAttr, false);
|
|
569
|
|
570 }
|
|
571
|
|
572 // set ending attribute byte
|
|
573 screen52.setScreenCharAndAttr(initChar, initAttr, true);
|
|
574
|
|
575 lastPos = ((screen52.getRow(lastPos) + 1) * numCols) + c;
|
|
576 screen52.goto_XY(lastPos);
|
|
577
|
|
578 // now handle body of window
|
|
579 while (depth-- > 0) {
|
|
580
|
|
581 // set leading attribute byte
|
|
582 screen52.setScreenCharAndAttr(initChar, initAttr, true);
|
|
583 // set left
|
|
584 if (gui) {
|
|
585 screen52.setScreenCharAndAttr((char) left, colorAttr, GUI_LEFT, false);
|
|
586 }
|
|
587 else {
|
|
588 screen52.setScreenCharAndAttr((char) left, colorAttr, false);
|
|
589
|
|
590 }
|
|
591
|
|
592 w = width - 2;
|
|
593 screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, true);
|
|
594 // fill it in
|
|
595 while (w-- >= 0) {
|
|
596 // if (!planes.isUseGui(screen52.getLastPos()))
|
|
597 screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, false);
|
|
598 }
|
|
599 screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, true);
|
|
600
|
|
601 // set right
|
|
602 if (gui) {
|
|
603 screen52.setScreenCharAndAttr((char) right, colorAttr, GUI_RIGHT, false);
|
|
604
|
|
605 }
|
|
606 else {
|
|
607 screen52.setScreenCharAndAttr((char) right, colorAttr, false);
|
|
608
|
|
609 }
|
|
610
|
|
611 screen52.setScreenCharAndAttr(initChar, initAttr, true);
|
|
612
|
|
613 lastPos = ((screen52.getRow(lastPos) + 1) * numCols) + c;
|
|
614 screen52.goto_XY(lastPos);
|
|
615 }
|
|
616
|
|
617 // set leading attribute byte
|
|
618 screen52.setScreenCharAndAttr(initChar, initAttr, true);
|
|
619 if (gui) {
|
|
620 screen52.setScreenCharAndAttr((char) ll, colorAttr, LOWER_LEFT, false);
|
|
621
|
|
622 }
|
|
623 else {
|
|
624 screen52.setScreenCharAndAttr((char) ll, colorAttr, false);
|
|
625
|
|
626 }
|
|
627 w = width;
|
|
628
|
|
629 // draw bottom row
|
|
630 while (w-- >= 0) {
|
|
631 if (gui) {
|
|
632 screen52.setScreenCharAndAttr((char) bottom, colorAttr, BOTTOM, false);
|
|
633 }
|
|
634 else {
|
|
635 screen52.setScreenCharAndAttr((char) bottom, colorAttr, false);
|
|
636
|
|
637 }
|
|
638 }
|
|
639
|
|
640 // set lower right
|
|
641 if (gui) {
|
|
642 screen52.setScreenCharAndAttr((char) lr, colorAttr, LOWER_RIGHT, false);
|
|
643 }
|
|
644 else {
|
|
645 screen52.setScreenCharAndAttr((char) lr, colorAttr, false);
|
|
646 }
|
|
647
|
|
648 // set ending attribute byte
|
|
649 screen52.setScreenCharAndAttr(initChar, initAttr, true);
|
|
650
|
|
651 }
|
|
652
|
|
653 /* *** NEVER USED LOCALLY ************************************************** */
|
|
654 // private void clearWindowBody(ScreenPlanes planes, int startPos, int depth, int width) {
|
|
655 //
|
|
656 // int lastPos = startPos;
|
|
657 // char initChar = Screen5250.initChar;
|
|
658 // int initAttr = Screen5250.initAttr;
|
|
659 //
|
|
660 // // now handle body of window
|
|
661 // while (depth-- > 0) {
|
|
662 //
|
|
663 // // set leading attribute byte
|
|
664 //// planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
665 //// setDirty(lastPos);
|
|
666 //// advancePos();
|
|
667 ////
|
|
668 //// // set left
|
|
669 //// planes.setScreenCharAndAttr(lastPos, (char) left, colorAttr, false);
|
|
670 ////
|
|
671 //// if (gui) {
|
|
672 //// planes.setUseGUI(lastPos,GUI_LEFT);
|
|
673 //// }
|
|
674 //// setDirty(lastPos);
|
|
675 //// advancePos();
|
|
676 //
|
|
677 // int w = width;
|
|
678 // // fill it in
|
|
679 // while (w-- >= 0) {
|
|
680 //// screen[lastPos].setCharAndAttr(initChar, initAttr, true);
|
|
681 // planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
682 //// screen[lastPos].setUseGUI(NO_GUI);
|
|
683 // planes.setUseGUI(lastPos,NO_GUI);
|
|
684 //// setDirty(lastPos);
|
|
685 // lastPos++;
|
|
686 // advancePos();
|
|
687 // }
|
|
688 //
|
|
689 //// // set right
|
|
690 //// // screen[lastPos].setCharAndAttr((char) right, colorAttr, false);
|
|
691 //// planes.setScreenCharAndAttr(lastPos,(char) right, colorAttr, false);
|
|
692 //// if (gui) {
|
|
693 //// // screen[lastPos].setUseGUI(RIGHT);
|
|
694 //// planes.setUseGUI(lastPos,GUI_RIGHT);
|
|
695 //// }
|
|
696 ////
|
|
697 //// setDirty(lastPos);
|
|
698 //// advancePos();
|
|
699 ////
|
|
700 //// // set ending attribute byte
|
|
701 //// // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
|
|
702 //// planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
703 //// setDirty(lastPos);
|
|
704 //
|
|
705 // lastPos = startPos;
|
|
706 // }
|
|
707 //
|
|
708 // }
|
|
709
|
|
710 /* *** NEVER USED LOCALLY ************************************************** */
|
|
711 // private void setDirty(int pos) {
|
|
712 //
|
|
713 // screen52.setDirty(pos);
|
|
714 //
|
|
715 // }
|
|
716
|
|
717 /* *** NEVER USED LOCALLY ************************************************** */
|
|
718 // private void advancePos() {
|
|
719 //
|
|
720 // screen52.advancePos();
|
|
721 // }
|
|
722
|
|
723 private void defineSelectionField(int majLen) {
|
|
724
|
|
725 // 0030: 20 00 2C 3E 00 00 00 69 12 A0 00 00 04 00 00 03 .,>...i........
|
|
726 // 0040: 04 40 04 11 00 28 01 07 00 00 00 19 00 00 04 11 .@...(..........
|
|
727 // 0050: 14 19 15 00 48 D9 50 00 60 00 11 01 84 84 00 00 ....H.P.`.......
|
|
728 // 0060: 05 03 01 01 00 00 00 13 01 E0 00 21 00 21 00 3B ...........!.!.;
|
|
729 // 0070: 22 20 20 20 20 3A 24 20 20 3A 0B 10 08 00 E0 00 " :$ :......
|
|
730 // 0080: D6 95 85 40 40 0B 10 08 00 E0 00 E3 A6 96 40 40 ...@@.........@@
|
|
731 // 0090: 0B 10 08 00 E0 00 E3 88 99 85 85 04 52 00 00 FF ............R...
|
|
732 // 00A0: EF .
|
|
733 try {
|
|
734 int flag1 = segment[pos++]; // Flag byte 1 - byte 5
|
|
735 int flag2 = segment[pos++]; // Flag byte 2 - byte 6
|
|
736 int flag3 = segment[pos++]; // Flag byte 3 - byte 7
|
|
737 int typeSelection = segment[pos++]; // Type of selection Field - byte 8
|
|
738
|
|
739 // GUI Device Characteristics:
|
|
740 // This byte is used if the target device is a GUI PWS or a GUI-like
|
|
741 // NWS. If neigher of these WS are the targets, this byte is ignored
|
|
742 int guiDevice = segment[pos++]; // byte 9
|
|
743 int withMnemonic = segment[pos++]; // byte 10
|
|
744 int noMnemonic = segment[pos++]; // byte 11
|
|
745
|
|
746 pos++; // Reserved - byte 12
|
|
747 pos++; // Reserved - byte 13
|
|
748
|
|
749 int cols = segment[pos++]; // Text Size - byte 14
|
|
750 int rows = segment[pos++]; // Rows - byte 15
|
|
751
|
|
752 int maxColChoice = segment[pos++]; // byte 16 num of column choices
|
|
753 int padding = segment[pos++]; // byte 17
|
|
754 int numSepChar = segment[pos++]; // byte 18
|
|
755 int ctySepChar = segment[pos++]; // byte 19
|
|
756 int cancelAID = segment[pos++]; // byte 20
|
|
757
|
|
758 int cnt = 0;
|
|
759 int minLen = 0;
|
|
760 majLen -= 21;
|
|
761 log.debug(" row: " + screen52.getCurrentRow()
|
|
762 + " col: " + screen52.getCurrentCol()
|
|
763 + " type " + typeSelection
|
|
764 + " gui " + guiDevice
|
|
765 + " withMnemonic " + Integer.toHexString(withMnemonic & 0xf0)
|
|
766 + " noMnemonic " + Integer.toHexString(noMnemonic & 0xf0)
|
|
767 + " noMnemonic " + Integer.toBinaryString(noMnemonic)
|
|
768 + " noMnemonicType " + Integer.toBinaryString((noMnemonic & 0xf0))
|
|
769 + " noMnemonicSel " + Integer.toBinaryString((noMnemonic & 0x0f))
|
|
770 + " maxcols " + maxColChoice
|
|
771 + " cols " + cols
|
|
772 + " rows " + rows);
|
|
773 int rowCtr = 0;
|
|
774 int colCtr = 0;
|
|
775 int chcRowStart = screen52.getCurrentRow();
|
|
776 int chcColStart = screen52.getCurrentCol();
|
|
777 int chcRow = chcRowStart;
|
|
778 int chcCol = chcColStart;
|
|
779 int chcPos = screen52.getPos(chcRow-1,chcCol);
|
|
780
|
|
781 // client access
|
|
782 //0000 00 04 ac 9e b9 35 00 01 02 32 bb 4e 08 00 45 00 .....5...2.N..E.
|
|
783 //0010 00 3c 4f 8e 40 00 80 06 00 00 c1 a8 33 58 c1 a8 .<O.@.......3X..
|
|
784 //0020 33 01 09 e4 00 17 5b bf b7 a4 c3 41 43 d1 50 18 3.....[....AC.P.
|
|
785 //0030 fc de e9 d8 00 00 00 12 12 a0 00 00 04 00 80 03 ................
|
|
786 //0040 16 18 f1 11 14 1a 00 22 ff ef ......."..
|
|
787
|
|
788 int colAvail = 0x20;
|
|
789 int colSelAvail = 0x20;
|
|
790 int fld = 0;
|
|
791
|
|
792 do {
|
|
793 minLen = segment[pos++]; // Minor Length byte 21
|
|
794
|
|
795 int minType = segment[pos++]; // Minor Type
|
|
796
|
|
797 switch (minType) {
|
|
798
|
|
799 case 0x01: // Choice Presentation Display
|
|
800
|
|
801 // flag
|
|
802 int flagCP1 = segment[pos++];
|
|
803
|
|
804 pos++; // mon select cursor avail emphasis - byte4
|
|
805 colSelAvail = segment[pos++]; // -byte 5
|
|
806
|
|
807 pos++; // mon select cursor - byte 6
|
|
808 int colSelCur = segment[pos++]; // -byte 7
|
|
809
|
|
810 pos++; // mon select cursor not avail emphasis - byte 8
|
|
811 int colSelNotAvail = segment[pos++]; // -byte 9
|
|
812
|
|
813 pos++; // mon avail emphasis - byte 10
|
|
814 colAvail = segment[pos++]; // -byte 11
|
|
815
|
|
816 pos++; // mon select emphasis - byte 12
|
|
817 int colSel = segment[pos++]; // -byte 13
|
|
818
|
|
819 pos++; // mon not avail emphasis - byte 14
|
|
820 int colNotAvail = segment[pos++]; // -byte 15
|
|
821
|
|
822 pos++; // mon indicator emphasis - byte 16
|
|
823 int colInd = segment[pos++]; // -byte 17
|
|
824
|
|
825 pos++; // mon indicator not avail emphasis - byte 18
|
|
826 int colNotAvailInd = segment[pos++]; // -byte 19
|
|
827
|
|
828 break;
|
|
829
|
|
830 case 0x10: // Choice Text minor structure
|
|
831
|
|
832 cnt = 5;
|
|
833 int flagCT1 = segment[pos++];
|
|
834 int flagCT2 = segment[pos++];
|
|
835 int flagCT3 = segment[pos++];
|
|
836 int mnemOffset = 0;
|
|
837 boolean aid = false;
|
|
838 boolean selected = false;
|
|
839
|
|
840 // is in selected state
|
|
841 if ((flagCT1 & 0x40) == 0x40) {
|
|
842 log.debug(" selected ");
|
|
843 selected = true;
|
|
844 }
|
|
845
|
|
846 //System.out.println(Integer.toBinaryString((flagCT1 & 0xf0)));
|
|
847 // is mnemonic offset specified
|
|
848 if ((flagCT1 & 0x08) == 8) {
|
|
849 log.debug(" mnemOffset " + mnemOffset);
|
|
850 mnemOffset = segment[pos++];
|
|
851 cnt++;
|
|
852 }
|
|
853
|
|
854 // is aid key specified
|
|
855 if ((flagCT1 & 0x04) == 4) {
|
|
856
|
|
857 aid = true;
|
|
858 log.debug(" aidKey " + aid);
|
|
859 // cnt++;
|
|
860 }
|
|
861
|
|
862 // is single digit number specified
|
|
863 if ((flagCT1 & 0x01) == 0x01) {
|
|
864 log.debug(" single digit " );
|
|
865 pos++;
|
|
866 cnt++;
|
|
867 }
|
|
868
|
|
869 // is double digint number specified
|
|
870 if ((flagCT1 & 0x02) == 0x02) {
|
|
871 log.debug(" double digit " );
|
|
872
|
|
873 pos++;
|
|
874 cnt++;
|
|
875 }
|
|
876
|
|
877 String s = "";
|
|
878 byte byte0 = 0;
|
|
879 fld++;
|
|
880
|
|
881 screen52.setCursor(chcRowStart,chcColStart);
|
|
882
|
|
883 // we do not add a selection if it is marked as unavailable
|
|
884 if ((flagCT1 & 0x80) != 0x80) {
|
|
885 screen52.addField(0x26,1,0,0,0,0);
|
|
886 screen52.getScreenFields().getCurrentField().setFieldChar('.');
|
|
887 screen52.getScreenFields().getCurrentField().setSelectionFieldInfo(17,
|
|
888 fld,
|
|
889 chcPos);
|
|
890 screen52.setCursor(chcRowStart,chcColStart + 3);
|
|
891
|
|
892 for (;cnt < minLen; cnt++) {
|
|
893
|
|
894 byte0 = segment[pos++];
|
|
895 s += vt.codePage.ebcdic2uni(byte0);
|
|
896 screen52.setChar(vt.codePage.ebcdic2uni(byte0));
|
|
897
|
|
898 }
|
|
899
|
|
900 addChoiceField(chcRowStart,chcColStart,chcRow,chcCol,s);
|
|
901 }
|
|
902
|
|
903 // screen52.getScreenFields().getCurrentField().setMDT();
|
|
904
|
|
905 log.debug(s + " selected " + selected);
|
|
906 // chcRowStart;
|
|
907 //maxColChoice
|
|
908 colCtr++;
|
|
909 // rowCtr++;
|
|
910 if (colCtr >= maxColChoice) {
|
|
911
|
|
912 rowCtr++;
|
|
913 colCtr=0;
|
|
914 chcColStart = chcCol;
|
|
915 chcRowStart = chcRow + rowCtr;
|
|
916 if (rowCtr > rows) {
|
|
917 chcRowStart = chcRow;
|
|
918 rowCtr = 0;
|
|
919 chcColStart = chcColStart + 3 + cols + padding;
|
|
920 }
|
|
921 }
|
|
922 else {
|
|
923 chcColStart = chcColStart + padding + cols + 3;
|
|
924 //
|
|
925 }
|
|
926
|
|
927 break;
|
|
928 default:
|
|
929 for (cnt = 2;cnt < minLen; cnt++) {
|
|
930
|
|
931 pos++;
|
|
932 }
|
|
933
|
|
934 }
|
|
935
|
|
936 majLen -= minLen;
|
|
937
|
|
938 } while (majLen > 0);
|
|
939 }
|
|
940 catch (Exception exc) {
|
|
941 log.warn(" defineSelectionField :", exc);
|
|
942 exc.printStackTrace();
|
|
943 }
|
|
944 }
|
|
945
|
|
946 // negotiating commands
|
|
947 // private static final byte IAC = (byte)-1; // 255 FF
|
|
948 // private static final byte DONT = (byte)-2; //254 FE
|
|
949 // private static final byte DO = (byte)-3; //253 FD
|
|
950 // private static final byte WONT = (byte)-4; //252 FC
|
|
951 // private static final byte WILL = (byte)-5; //251 FB
|
|
952 // private static final byte SB = (byte)-6; //250 Sub Begin FA
|
|
953 // private static final byte SE = (byte)-16; //240 Sub End F0
|
|
954 // private static final byte EOR = (byte)-17; //239 End of Record EF
|
|
955 // private static final byte TERMINAL_TYPE = (byte)24; // 18
|
|
956 // private static final byte OPT_END_OF_RECORD = (byte)25; // 19
|
|
957 // private static final byte TRANSMIT_BINARY = (byte)0; // 0
|
|
958 // private static final byte QUAL_IS = (byte)0; // 0
|
|
959 // private static final byte TIMING_MARK = (byte)6; // 6
|
|
960 // private static final byte NEW_ENVIRONMENT = (byte)39; // 27
|
|
961 // private static final byte IS = (byte)0; // 0
|
|
962 // private static final byte SEND = (byte)1; // 1
|
|
963 // private static final byte INFO = (byte)2; // 2
|
|
964 // private static final byte VAR = (byte)0; // 0
|
|
965 // private static final byte VALUE = (byte)1; // 1
|
|
966 // private static final byte NEGOTIATE_ESC = (byte)2; // 2
|
|
967 // private static final byte USERVAR = (byte)3; // 3
|
|
968
|
|
969 // miscellaneous
|
|
970 // private static final byte ESC = 0x04; // 04
|
|
971 // private static final char char0 = 0;
|
|
972
|
|
973 // private static final byte CMD_READ_IMMEDIATE_ALT = (byte)0x83; // 131
|
|
974
|
|
975
|
|
976 } |