comparison src/org/tn5250j/framework/tn5250/WTDSFParser.java @ 112:77ac18bc1b2f

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