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

cleanup java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 18 Jun 2014 13:03:01 -0700
parents 6a0ad4d384ea
children cb3b9b660b3d
comparison
equal deleted inserted replaced
111:6a0ad4d384ea 112:77ac18bc1b2f
99 private StringBuffer keybuf; 99 private StringBuffer keybuf;
100 100
101 101
102 102
103 public Screen5250() { 103 public Screen5250() {
104
105 //Added by Barry 104 //Added by Barry
106 this.keybuf = new StringBuffer(); 105 this.keybuf = new StringBuffer();
107 106
108 try { 107 try {
109 jbInit(); 108 jbInit();
110 } catch (Exception ex) { 109 }
111 Log.w(TAG,"In constructor: ", ex); 110 catch (Exception ex) {
111 Log.w(TAG, "In constructor: ", ex);
112 } 112 }
113 } 113 }
114 114
115 void jbInit() throws Exception { 115 void jbInit() throws Exception {
116
117 lastAttr = 32; 116 lastAttr = 32;
118
119 // default number of rows and columns 117 // default number of rows and columns
120 numRows = 24; 118 numRows = 24;
121 numCols = 80; 119 numCols = 80;
122
123 setCursor(1, 1); // set initial cursor position 120 setCursor(1, 1); // set initial cursor position
124
125 oia = new ScreenOIA(this); 121 oia = new ScreenOIA(this);
126 oia.setKeyBoardLocked(true); 122 oia.setKeyBoardLocked(true);
127
128 lenScreen = numRows * numCols; 123 lenScreen = numRows * numCols;
129 124 planes = new ScreenPlanes(this, numRows);
130 planes = new ScreenPlanes(this,numRows);
131
132 screenFields = new ScreenFields(this); 125 screenFields = new ScreenFields(this);
133 strokenizer = new KeyStrokenizer(); 126 strokenizer = new KeyStrokenizer();
134 } 127 }
135 128
136 protected ScreenPlanes getPlanes() { 129 protected ScreenPlanes getPlanes() {
140 public final ScreenOIA getOIA() { 133 public final ScreenOIA getOIA() {
141 return oia; 134 return oia;
142 } 135 }
143 136
144 protected final void setRowsCols(int rows, int cols) { 137 protected final void setRowsCols(int rows, int cols) {
145
146 int oldRows = numRows; 138 int oldRows = numRows;
147 int oldCols = numCols; 139 int oldCols = numCols;
148
149 // default number of rows and columns 140 // default number of rows and columns
150 numRows = rows; 141 numRows = rows;
151 numCols = cols; 142 numCols = cols;
152
153 lenScreen = numRows * numCols; 143 lenScreen = numRows * numCols;
154
155 planes.setSize(rows); 144 planes.setSize(rows);
156 145
157 // If they are not the same then we need to inform the listeners that 146 // If they are not the same then we need to inform the listeners that
158 // the size changed. 147 // the size changed.
159 if (oldRows != numRows || oldCols != numCols) 148 if (oldRows != numRows || oldCols != numCols)
160 fireScreenSizeChanged(); 149 fireScreenSizeChanged();
161
162 } 150 }
163 151
164 152
165 public boolean isCursorActive() { 153 public boolean isCursorActive() {
166 return cursorActive; 154 return cursorActive;
167
168 } 155 }
169 156
170 public boolean isCursorShown() { 157 public boolean isCursorShown() {
171 return cursorShown; 158 return cursorShown;
172 } 159 }
195 */ 182 */
196 public final String copyText(Rect area) { 183 public final String copyText(Rect area) {
197 StringBuilder sb = new StringBuilder(); 184 StringBuilder sb = new StringBuilder();
198 Rect workR = new Rect(); 185 Rect workR = new Rect();
199 workR.setBounds(area); 186 workR.setBounds(area);
200 Log.d(TAG,"Copying " + workR); 187 Log.d(TAG, "Copying " + workR);
201
202 // loop through all the screen characters to send them to the clip board 188 // loop through all the screen characters to send them to the clip board
203 int m = workR.x; 189 int m = workR.x;
204 int i = 0; 190 int i = 0;
205 int t = 0; 191 int t = 0;
206 192
207 while (workR.height-- > 0) { 193 while (workR.height-- > 0) {
208 t = workR.width; 194 t = workR.width;
209 i = workR.y; 195 i = workR.y;
196
210 while (t-- > 0) { 197 while (t-- > 0) {
211 // only copy printable characters (in this case >= ' ') 198 // only copy printable characters (in this case >= ' ')
212 char c = planes.getChar(getPos(m - 1, i - 1)); 199 char c = planes.getChar(getPos(m - 1, i - 1));
200
213 if (c >= ' ' && (planes.screenExtended[getPos(m - 1, i - 1)] & EXTENDED_5250_NON_DSP) 201 if (c >= ' ' && (planes.screenExtended[getPos(m - 1, i - 1)] & EXTENDED_5250_NON_DSP)
214 == 0) 202 == 0)
215 sb.append(c); 203 sb.append(c);
216 else 204 else
217 sb.append(' '); 205 sb.append(' ');
218 206
219 i++; 207 i++;
220 } 208 }
209
221 sb.append('\n'); 210 sb.append('\n');
222 m++; 211 m++;
223 } 212 }
213
224 return sb.toString(); 214 return sb.toString();
225 } 215 }
226 216
227 /** 217 /**
228 * Copy & Paste support 218 * Copy & Paste support
229 * 219 *
230 * @param content 220 * @param content
231 * @see {@link #copyText(Rectangle)} 221 * @see {@link #copyText(Rectangle)}
232 */ 222 */
233 public final void pasteText(String content, boolean special) { 223 public final void pasteText(String content, boolean special) {
234 Log.d(TAG,"Pasting, special:"+special); 224 Log.d(TAG, "Pasting, special:" + special);
235 setCursorActive(false); 225 setCursorActive(false);
236
237 StringBuilder sb = new StringBuilder(content); 226 StringBuilder sb = new StringBuilder(content);
238 StringBuilder pd = new StringBuilder(); 227 StringBuilder pd = new StringBuilder();
239
240 // character counters within the string to be pasted. 228 // character counters within the string to be pasted.
241 int nextChar = 0; 229 int nextChar = 0;
242 int nChars = sb.length(); 230 int nChars = sb.length();
243
244 int lr = getRow(lastPos); 231 int lr = getRow(lastPos);
245 int lc = getCol(lastPos); 232 int lc = getCol(lastPos);
246 resetDirty(lastPos); 233 resetDirty(lastPos);
247
248 int cpos = lastPos; 234 int cpos = lastPos;
249 int length = getScreenLength(); 235 int length = getScreenLength();
250
251 char c = 0; 236 char c = 0;
252 boolean setIt; 237 boolean setIt;
253
254 // save our current place within the FFT. 238 // save our current place within the FFT.
255 screenFields.saveCurrentField(); 239 screenFields.saveCurrentField();
256 240
257 for (int x = nextChar; x < nChars; x++) { 241 for (int x = nextChar; x < nChars; x++) {
258
259 c = sb.charAt(x); 242 c = sb.charAt(x);
260 243
261 if ((c == '\n') || (c == '\r')) { 244 if ((c == '\n') || (c == '\r')) {
262 245 Log.i(TAG, "pasted cr-lf>" + pd + "<");
263 Log.i(TAG,"pasted cr-lf>" + pd + "<");
264 pd.setLength(0); 246 pd.setLength(0);
265 // if we read in a cr lf in the data stream we need to go 247 // if we read in a cr lf in the data stream we need to go
266 // to the starting column of the next row and start from there 248 // to the starting column of the next row and start from there
267 cpos = getPos(getRow(cpos)+1,lc); 249 cpos = getPos(getRow(cpos) + 1, lc);
268 250
269 // If we go paste the end of the screen then let's start over from 251 // If we go paste the end of the screen then let's start over from
270 // the beginning of the screen space. 252 // the beginning of the screen space.
271 if (cpos > length) 253 if (cpos > length)
272 cpos = 0; 254 cpos = 0;
273 } 255 }
274 else { 256 else {
275
276 // we will default to set the character always. 257 // we will default to set the character always.
277 setIt = true; 258 setIt = true;
278 259
279 // If we are in a special paste scenario then we check for valid 260 // If we are in a special paste scenario then we check for valid
280 // characters to paste. 261 // characters to paste.
286 if (isInField(cpos) && setIt) { 267 if (isInField(cpos) && setIt) {
287 planes.setChar(cpos, c); 268 planes.setChar(cpos, c);
288 setDirty(cpos); 269 setDirty(cpos);
289 screenFields.setCurrentFieldMDT(); 270 screenFields.setCurrentFieldMDT();
290 } 271 }
272
291 // If we placed a character then we go to the next position. 273 // If we placed a character then we go to the next position.
292 if (setIt) 274 if (setIt)
293 cpos++; 275 cpos++;
276
294 // we will append the information to our debug buffer. 277 // we will append the information to our debug buffer.
295 pd.append(c); 278 pd.append(c);
296 } 279 }
297 } 280 }
298 281
299 // if we have anything else not logged then log it out. 282 // if we have anything else not logged then log it out.
300 if (pd.length() > 0) 283 if (pd.length() > 0)
301 Log.i(TAG,"pasted >" + pd + "<"); 284 Log.i(TAG, "pasted >" + pd + "<");
302 285
303 // restore out position within the FFT. 286 // restore out position within the FFT.
304 screenFields.restoreCurrentField(); 287 screenFields.restoreCurrentField();
305 updateDirty(); 288 updateDirty();
306
307 // restore our cursor position. 289 // restore our cursor position.
308 setCursor(lr + 1, lc + 1); 290 setCursor(lr + 1, lc + 1);
309
310 setCursorActive(true); 291 setCursorActive(true);
311
312 } 292 }
313 293
314 /** 294 /**
315 * Copy & Paste support 295 * Copy & Paste support
316 * 296 *
338 * @param which 318 * @param which
339 * formatting option to use 319 * formatting option to use
340 * @return vector string of numberic values 320 * @return vector string of numberic values
341 */ 321 */
342 public final Vector<Double> sumThem(boolean which, Rect area) { 322 public final Vector<Double> sumThem(boolean which, Rect area) {
343
344 StringBuilder sb = new StringBuilder(); 323 StringBuilder sb = new StringBuilder();
345 Rect workR = new Rect(); 324 Rect workR = new Rect();
346 workR.setBounds(area); 325 workR.setBounds(area);
347
348 // gui.rubberband.reset(); 326 // gui.rubberband.reset();
349 // gui.repaint(); 327 // gui.repaint();
350 328 Log.d(TAG, "Summing");
351 Log.d(TAG,"Summing");
352
353 // obtain the decimal format for parsing 329 // obtain the decimal format for parsing
354 DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(); 330 DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
355
356 DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); 331 DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
357 332
358 if (which) { 333 if (which) {
359 dfs.setDecimalSeparator('.'); 334 dfs.setDecimalSeparator('.');
360 dfs.setGroupingSeparator(','); 335 dfs.setGroupingSeparator(',');
361 } else { 336 }
337 else {
362 dfs.setDecimalSeparator(','); 338 dfs.setDecimalSeparator(',');
363 dfs.setGroupingSeparator('.'); 339 dfs.setGroupingSeparator('.');
364 } 340 }
365 341
366 df.setDecimalFormatSymbols(dfs); 342 df.setDecimalFormatSymbols(dfs);
367
368 Vector<Double> sumVector = new Vector<Double>(); 343 Vector<Double> sumVector = new Vector<Double>();
369
370 // loop through all the screen characters to send them to the clip board 344 // loop through all the screen characters to send them to the clip board
371 int m = workR.x; 345 int m = workR.x;
372 int i = 0; 346 int i = 0;
373 int t = 0; 347 int t = 0;
374
375 double sum = 0.0; 348 double sum = 0.0;
376 349
377 while (workR.height-- > 0) { 350 while (workR.height-- > 0) {
378 t = workR.width; 351 t = workR.width;
379 i = workR.y; 352 i = workR.y;
353
380 while (t-- > 0) { 354 while (t-- > 0) {
381
382 // only copy printable numeric characters (in this case >= ' ') 355 // only copy printable numeric characters (in this case >= ' ')
383 // char c = screen[getPos(m - 1, i - 1)].getChar(); 356 // char c = screen[getPos(m - 1, i - 1)].getChar();
384 char c = planes.getChar(getPos(m - 1, i - 1)); 357 char c = planes.getChar(getPos(m - 1, i - 1));
385 // if (((c >= '0' && c <= '9') || c == '.' || c == ',' || c == '-') 358 // if (((c >= '0' && c <= '9') || c == '.' || c == ',' || c == '-')
386 // && !screen[getPos(m - 1, i - 1)].nonDisplay) { 359 // && !screen[getPos(m - 1, i - 1)].nonDisplay) {
387 360
388 // TODO: update me here to implement the nonDisplay check as well 361 // TODO: update me here to implement the nonDisplay check as well
389 if (((c >= '0' && c <= '9') || c == '.' || c == ',' || c == '-')) { 362 if (((c >= '0' && c <= '9') || c == '.' || c == ',' || c == '-')) {
390 sb.append(c); 363 sb.append(c);
391 } 364 }
365
392 i++; 366 i++;
393 } 367 }
394 368
395 if (sb.length() > 0) { 369 if (sb.length() > 0) {
396 if (sb.charAt(sb.length() - 1) == '-') { 370 if (sb.charAt(sb.length() - 1) == '-') {
397 sb.insert(0, '-'); 371 sb.insert(0, '-');
398 sb.deleteCharAt(sb.length() - 1); 372 sb.deleteCharAt(sb.length() - 1);
399 } 373 }
374
400 try { 375 try {
401 Number n = df.parse(sb.toString()); 376 Number n = df.parse(sb.toString());
402 // System.out.println(s + " " + n.doubleValue()); 377 // System.out.println(s + " " + n.doubleValue());
403
404 sumVector.add(new Double(n.doubleValue())); 378 sumVector.add(new Double(n.doubleValue()));
405 sum += n.doubleValue(); 379 sum += n.doubleValue();
406 } catch (ParseException pe) { 380 }
407 Log.w(TAG,pe.getMessage() + " at " 381 catch (ParseException pe) {
408 + pe.getErrorOffset()); 382 Log.w(TAG, pe.getMessage() + " at "
383 + pe.getErrorOffset());
409 } 384 }
410 } 385 }
386
411 sb.setLength(0); 387 sb.setLength(0);
412 m++; 388 m++;
413 } 389 }
414 Log.d(TAG,"" + sum); 390
391 Log.d(TAG, "" + sum);
415 return sumVector; 392 return sumVector;
416 } 393 }
417 394
418 /** 395 /**
419 * This will move the screen cursor based on the mouse event. 396 * This will move the screen cursor based on the mouse event.
423 * should be up to the gui frontend in my opinion. 400 * should be up to the gui frontend in my opinion.
424 * 401 *
425 * @param pos 402 * @param pos
426 */ 403 */
427 public boolean moveCursor(int pos) { 404 public boolean moveCursor(int pos) {
428
429 if (!oia.isKeyBoardLocked()) { 405 if (!oia.isKeyBoardLocked()) {
430
431 if (pos < 0) 406 if (pos < 0)
432 return false; 407 return false;
408
433 // because getRowColFromPoint returns offset of 1,1 we need to 409 // because getRowColFromPoint returns offset of 1,1 we need to
434 // translate to offset 0,0 410 // translate to offset 0,0
435 // pos -= (numCols + 1); 411 // pos -= (numCols + 1);
436
437 int g = planes.getWhichGUI(pos); 412 int g = planes.getWhichGUI(pos);
438 413
439 // lets check for hot spots 414 // lets check for hot spots
440 if (g >= BUTTON_LEFT && g <= BUTTON_LAST) { 415 if (g >= BUTTON_LEFT && g <= BUTTON_LAST) {
441 StringBuffer aid = new StringBuffer(); 416 StringBuffer aid = new StringBuffer();
442 boolean aidFlag = true; 417 boolean aidFlag = true;
418
443 switch (g) { 419 switch (g) {
444 case BUTTON_RIGHT: 420 case BUTTON_RIGHT:
445 case BUTTON_MIDDLE: 421 case BUTTON_MIDDLE:
446 while (planes.getWhichGUI(--pos) != BUTTON_LEFT) { 422 while (planes.getWhichGUI(--pos) != BUTTON_LEFT) {
447 } 423 }
448 case BUTTON_LEFT: 424
449 if (planes.getChar(pos) == 'F') { 425 case BUTTON_LEFT:
450 pos++; 426 if (planes.getChar(pos) == 'F') {
451 } else 427 pos++;
452 aidFlag = false; 428 }
453 429 else
454 if (planes.getChar(pos + 1) != '=' 430 aidFlag = false;
455 && planes.getChar(pos + 1) != '.' 431
456 && planes.getChar(pos + 1) != '/') { 432 if (planes.getChar(pos + 1) != '='
457 Log.d(TAG," Hotspot clicked!!! we will send characters " 433 && planes.getChar(pos + 1) != '.'
458 + planes.getChar(pos) + " " + planes.getChar(pos+1)); 434 && planes.getChar(pos + 1) != '/') {
459 aid.append(planes.getChar(pos)); 435 Log.d(TAG, " Hotspot clicked!!! we will send characters "
460 aid.append(planes.getChar(pos + 1)); 436 + planes.getChar(pos) + " " + planes.getChar(pos + 1));
461 } else { 437 aid.append(planes.getChar(pos));
462 Log.d(TAG," Hotspot clicked!!! we will send character " 438 aid.append(planes.getChar(pos + 1));
463 + planes.getChar(pos)); 439 }
464 aid.append(planes.getChar(pos)); 440 else {
465 } 441 Log.d(TAG, " Hotspot clicked!!! we will send character "
466 break; 442 + planes.getChar(pos));
467 443 aid.append(planes.getChar(pos));
468 } 444 }
445
446 break;
447 }
448
469 if (aidFlag) { 449 if (aidFlag) {
470 switch (g) { 450 switch (g) {
471 451 case BUTTON_LEFT_UP:
472 case BUTTON_LEFT_UP: 452 case BUTTON_MIDDLE_UP:
473 case BUTTON_MIDDLE_UP: 453 case BUTTON_RIGHT_UP:
474 case BUTTON_RIGHT_UP: 454 case BUTTON_ONE_UP:
475 case BUTTON_ONE_UP: 455 case BUTTON_SB_UP:
476 case BUTTON_SB_UP: 456 case BUTTON_SB_GUIDE:
477 case BUTTON_SB_GUIDE: 457 sessionVT.sendAidKey(AID_ROLL_UP);
478 sessionVT.sendAidKey(AID_ROLL_UP); 458 break;
479 break; 459
480 460 case BUTTON_LEFT_DN:
481 case BUTTON_LEFT_DN: 461 case BUTTON_MIDDLE_DN:
482 case BUTTON_MIDDLE_DN: 462 case BUTTON_RIGHT_DN:
483 case BUTTON_RIGHT_DN: 463 case BUTTON_ONE_DN:
484 case BUTTON_ONE_DN: 464 case BUTTON_SB_DN:
485 case BUTTON_SB_DN: 465 case BUTTON_SB_THUMB:
486 case BUTTON_SB_THUMB: 466 sessionVT.sendAidKey(AID_ROLL_DOWN);
487 467 break;
488 sessionVT.sendAidKey(AID_ROLL_DOWN); 468
489 break; 469 case BUTTON_LEFT_EB:
490 case BUTTON_LEFT_EB: 470 case BUTTON_MIDDLE_EB:
491 case BUTTON_MIDDLE_EB: 471 case BUTTON_RIGHT_EB:
492 case BUTTON_RIGHT_EB: 472 StringBuffer eb = new StringBuffer();
493 StringBuffer eb = new StringBuffer(); 473
494 while (planes.getWhichGUI(pos--) != BUTTON_LEFT_EB) 474 while (planes.getWhichGUI(pos--) != BUTTON_LEFT_EB)
495 ; 475 ;
496 while (planes.getWhichGUI(pos++) != BUTTON_RIGHT_EB) { 476
497 eb.append(planes.getChar(pos)); 477 while (planes.getWhichGUI(pos++) != BUTTON_RIGHT_EB) {
498 } 478 eb.append(planes.getChar(pos));
499 sessionVT.showURL(eb.toString()); 479 }
500 // take out the log statement when we are sure it is 480
501 // working 481 sessionVT.showURL(eb.toString());
502 Log.i(TAG,"Send to external Browser: " + eb.toString()); 482 // take out the log statement when we are sure it is
503 break; 483 // working
504 484 Log.i(TAG, "Send to external Browser: " + eb.toString());
505 default: 485 break;
506 int aidKey = Integer.parseInt(aid.toString()); 486
507 if (aidKey >= 1 && aidKey <= 12) 487 default:
508 sessionVT.sendAidKey(0x30 + aidKey); 488 int aidKey = Integer.parseInt(aid.toString());
509 if (aidKey >= 13 && aidKey <= 24) 489
510 sessionVT.sendAidKey(0xB0 + (aidKey - 12)); 490 if (aidKey >= 1 && aidKey <= 12)
491 sessionVT.sendAidKey(0x30 + aidKey);
492
493 if (aidKey >= 13 && aidKey <= 24)
494 sessionVT.sendAidKey(0xB0 + (aidKey - 12));
511 } 495 }
512 } else { 496 }
497 else {
513 if (screenFields.getCurrentField() != null) { 498 if (screenFields.getCurrentField() != null) {
514 int xPos = screenFields.getCurrentField().startPos(); 499 int xPos = screenFields.getCurrentField().startPos();
500
515 for (int x = 0; x < aid.length(); x++) { 501 for (int x = 0; x < aid.length(); x++) {
516 // System.out.println(sr + "," + (sc + x) + " " + 502 // System.out.println(sr + "," + (sc + x) + " " +
517 // aid.charAt(x)); 503 // aid.charAt(x));
518 planes.setChar(xPos + x , aid.charAt(x)); 504 planes.setChar(xPos + x , aid.charAt(x));
519 } 505 }
506
520 // System.out.println(aid); 507 // System.out.println(aid);
521 screenFields.setCurrentFieldMDT(); 508 screenFields.setCurrentFieldMDT();
522 sessionVT.sendAidKey(AID_ENTER); 509 sessionVT.sendAidKey(AID_ENTER);
523 } 510 }
524 511 }
525 } 512
526 // return back to the calling routine that the cursor was not moved 513 // return back to the calling routine that the cursor was not moved
527 // but something else here was done like aid keys or the such 514 // but something else here was done like aid keys or the such
528 return false; 515 return false;
529 } 516 }
517
530 // this is a note to not execute this code here when we 518 // this is a note to not execute this code here when we
531 // implement 519 // implement
532 // the remain after edit function option. 520 // the remain after edit function option.
533 // if (gui.rubberband.isAreaSelected()) { 521 // if (gui.rubberband.isAreaSelected()) {
534 // gui.rubberband.reset(); 522 // gui.rubberband.reset();
535 // gui.repaint(); 523 // gui.repaint();
536 // } else { 524 // } else {
537 goto_XY(pos); 525 goto_XY(pos);
538 isInField(lastPos); 526 isInField(lastPos);
539
540 // return back to the calling object that the cursor was indeed 527 // return back to the calling object that the cursor was indeed
541 // moved with in the screen object 528 // moved with in the screen object
542 return true; 529 return true;
543 // } 530 // }
544 } 531 }
532
545 return false; 533 return false;
546 } 534 }
547 535
548 public void setVT(tnvt v) { 536 public void setVT(tnvt v) {
549 sessionVT = v; 537 sessionVT = v;
560 * @param mnem string mnemonic value 548 * @param mnem string mnemonic value
561 * @return key value of Mnemonic 549 * @return key value of Mnemonic
562 */ 550 */
563 private int getMnemonicValue(String mnem) { 551 private int getMnemonicValue(String mnem) {
564 if (mnemonicMap.containsKey(mnem)) return mnemonicMap.get(mnem); 552 if (mnemonicMap.containsKey(mnem)) return mnemonicMap.get(mnem);
553
565 return 0; 554 return 0;
566 } 555 }
567 556
568 protected void setPrehelpState(boolean setErrorCode, boolean lockKeyboard, 557 protected void setPrehelpState(boolean setErrorCode, boolean lockKeyboard,
569 boolean unlockIfLocked) { 558 boolean unlockIfLocked) {
570 if (oia.isKeyBoardLocked() && unlockIfLocked) 559 if (oia.isKeyBoardLocked() && unlockIfLocked)
571 oia.setKeyBoardLocked(false); 560 oia.setKeyBoardLocked(false);
572 else 561 else
573 oia.setKeyBoardLocked(lockKeyboard); 562 oia.setKeyBoardLocked(lockKeyboard);
563
574 bufferedKeys = null; 564 bufferedKeys = null;
575 oia.setKeysBuffered(false); 565 oia.setKeysBuffered(false);
576
577
578 } 566 }
579 567
580 /** 568 /**
581 * Activate the cursor on screen 569 * Activate the cursor on screen
582 * 570 *
583 * @param activate 571 * @param activate
584 */ 572 */
585 public void setCursorActive(boolean activate) { 573 public void setCursorActive(boolean activate) {
586
587 // System.out.println("cursor active " + updateCursorLoc + " " + 574 // System.out.println("cursor active " + updateCursorLoc + " " +
588 // cursorActive + " " + activate); 575 // cursorActive + " " + activate);
589 if (cursorActive && !activate) { 576 if (cursorActive && !activate) {
590 setCursorOff(); 577 setCursorOff();
591 cursorActive = activate; 578 cursorActive = activate;
592 } else { 579 }
580 else {
593 if (!cursorActive && activate) { 581 if (!cursorActive && activate) {
594 cursorActive = activate; 582 cursorActive = activate;
595 setCursorOn(); 583 setCursorOn();
596 } 584 }
597 } 585 }
607 595
608 /** 596 /**
609 * Set the cursor off 597 * Set the cursor off
610 */ 598 */
611 public void setCursorOff() { 599 public void setCursorOff() {
612
613 cursorShown = false; 600 cursorShown = false;
614 updateCursorLoc(); 601 updateCursorLoc();
615 // System.out.println("cursor off " + updateCursorLoc + " " + 602 // System.out.println("cursor off " + updateCursorLoc + " " +
616 // cursorActive); 603 // cursorActive);
617
618 } 604 }
619 605
620 /** 606 /**
621 * 607 *
622 */ 608 */
933 * The string of characters to be sent 919 * The string of characters to be sent
934 * 920 *
935 * @see #sendAid 921 * @see #sendAid
936 * 922 *
937 */ 923 */
924
938 public synchronized void sendKeys(String text) { 925 public synchronized void sendKeys(String text) {
939 Log.d(TAG, "sendKeys() " + text); 926 Log.d(TAG, "sendKeys() " + text);
940 this.keybuf.append(text); 927 this.keybuf.append(text);
941 928
942 if (isStatusErrorCode() && !resetRequired) { 929 if (isStatusErrorCode() && !resetRequired) {
949 if (text.equals("[reset]") || text.equals("[sysreq]") 936 if (text.equals("[reset]") || text.equals("[sysreq]")
950 || text.equals("[attn]")) { 937 || text.equals("[attn]")) {
951 setCursorActive(false); 938 setCursorActive(false);
952 simulateMnemonic(getMnemonicValue(text)); 939 simulateMnemonic(getMnemonicValue(text));
953 setCursorActive(true); 940 setCursorActive(true);
954 941 }
955 } else { 942 else {
956 if (isStatusErrorCode()) { 943 if (isStatusErrorCode()) {
957 sessionVT.signalBell(); 944 sessionVT.signalBell();
958 return; 945 return;
959 } 946 }
960 947
961 oia.setKeysBuffered(true); 948 oia.setKeysBuffered(true);
962 949
963 if (bufferedKeys == null) bufferedKeys = text; 950 if (bufferedKeys == null) bufferedKeys = text;
964 else bufferedKeys += text; 951 else bufferedKeys += text;
952
965 return; 953 return;
966 } 954 }
967 955 }
968 } else { 956 else {
969
970 if (oia.isKeysBuffered()) { 957 if (oia.isKeysBuffered()) {
971 if (bufferedKeys != null) { 958 if (bufferedKeys != null) {
972 text = bufferedKeys + text; 959 text = bufferedKeys + text;
973 } 960 }
961
974 // if (text.length() == 0) { 962 // if (text.length() == 0) {
975 oia.setKeysBuffered(false); 963 oia.setKeysBuffered(false);
976 // } 964 // }
977 bufferedKeys = null; 965 bufferedKeys = null;
978
979 } 966 }
967
980 // check to see if position is in a field and if it is then change 968 // check to see if position is in a field and if it is then change
981 // current field to that field 969 // current field to that field
982 isInField(lastPos, true); 970 isInField(lastPos, true);
971
983 if (text.length() == 1 && !text.equals("[") && !text.equals("]")) { 972 if (text.length() == 1 && !text.equals("[") && !text.equals("]")) {
984 // setCursorOff2(); 973 // setCursorOff2();
985 setCursorActive(false); 974 setCursorActive(false);
986 simulateKeyStroke(text.charAt(0)); 975 simulateKeyStroke(text.charAt(0));
987 setCursorActive(true); 976 setCursorActive(true);
988 // setCursorOn2(); 977 // setCursorOn2();
989 // System.out.println(" text one"); 978 // System.out.println(" text one");
990 979 }
991 } else { 980 else {
992
993 strokenizer.setKeyStrokes(text); 981 strokenizer.setKeyStrokes(text);
994 String s; 982 String s;
995 boolean done = false; 983 boolean done = false;
996
997 // setCursorOff2(); 984 // setCursorOff2();
998 setCursorActive(false); 985 setCursorActive(false);
986
999 while (!done) { 987 while (!done) {
1000 // while (strokenizer.hasMoreKeyStrokes() && !keyboardLocked 988 // while (strokenizer.hasMoreKeyStrokes() && !keyboardLocked
1001 // && 989 // &&
1002 // !isStatusErrorCode() && !done) { 990 // !isStatusErrorCode() && !done) {
1003 if (strokenizer.hasMoreKeyStrokes()) { 991 if (strokenizer.hasMoreKeyStrokes()) {
1004
1005 // check to see if position is in a field and if it is 992 // check to see if position is in a field and if it is
1006 // then change 993 // then change
1007 // current field to that field 994 // current field to that field
1008 isInField(lastPos, true); 995 isInField(lastPos, true);
1009 s = strokenizer.nextKeyStroke(); 996 s = strokenizer.nextKeyStroke();
997
1010 if (s.length() == 1) { 998 if (s.length() == 1) {
1011 // setCursorOn(); 999 // setCursorOn();
1012 // if (!keysBuffered) { 1000 // if (!keysBuffered) {
1013 // System.out.println(" s two" + s); 1001 // System.out.println(" s two" + s);
1014 // setCursorOn(); 1002 // setCursorOn();
1015 // } 1003 // }
1016
1017 // try { new Thread().sleep(400);} catch 1004 // try { new Thread().sleep(400);} catch
1018 // (InterruptedException ie) {} 1005 // (InterruptedException ie) {}
1019 simulateKeyStroke(s.charAt(0)); 1006 simulateKeyStroke(s.charAt(0));
1020 // System.out.println(" s two " + s + " " + 1007 // System.out.println(" s two " + s + " " +
1021 // cursorActive); 1008 // cursorActive);
1022 // if (cursorActive && !keysBuffered) { 1009 // if (cursorActive && !keysBuffered) {
1023 // System.out.println(" s two" + s); 1010 // System.out.println(" s two" + s);
1024 // setCursorOn(); 1011 // setCursorOn();
1025 // } 1012 // }
1026 } else { 1013 }
1014 else {
1027 simulateMnemonic(getMnemonicValue(s)); 1015 simulateMnemonic(getMnemonicValue(s));
1028 // if (!cursorActive && !keysBuffered) { 1016 // if (!cursorActive && !keysBuffered) {
1029 // System.out.println(" m one"); 1017 // System.out.println(" m one");
1030 // setCursorOn(); 1018 // setCursorOn();
1031 // } 1019 // }
1032 } 1020 }
1033 1021
1034 if (oia.isKeyBoardLocked()) { 1022 if (oia.isKeyBoardLocked()) {
1035
1036 bufferedKeys = strokenizer 1023 bufferedKeys = strokenizer
1037 .getUnprocessedKeyStroked(); 1024 .getUnprocessedKeyStroked();
1025
1038 if (bufferedKeys != null) { 1026 if (bufferedKeys != null) {
1039 oia.setKeysBuffered(true); 1027 oia.setKeysBuffered(true);
1040
1041 } 1028 }
1029
1042 done = true; 1030 done = true;
1043 } 1031 }
1044
1045 } 1032 }
1046
1047 else { 1033 else {
1048 // setCursorActive(true); 1034 // setCursorActive(true);
1049 // setCursorOn(); 1035 // setCursorOn();
1050 done = true; 1036 done = true;
1051 } 1037 }
1052 } 1038 }
1039
1053 setCursorActive(true); 1040 setCursorActive(true);
1054 } 1041 }
1055 } 1042 }
1056 } 1043 }
1057 1044
1097 * @see #AID_PF22 1084 * @see #AID_PF22
1098 * @see #AID_PF23 1085 * @see #AID_PF23
1099 * @see #AID_PF24 1086 * @see #AID_PF24
1100 */ 1087 */
1101 public void sendAid(int aidKey) { 1088 public void sendAid(int aidKey) {
1102
1103 sessionVT.sendAidKey(aidKey); 1089 sessionVT.sendAidKey(aidKey);
1104 } 1090 }
1105 1091
1106 /** 1092 /**
1107 * Restores the error line and sets the error mode off. 1093 * Restores the error line and sets the error mode off.
1108 * 1094 *
1109 */ 1095 */
1110 protected void resetError() { 1096 protected void resetError() {
1111
1112 restoreErrorLine(); 1097 restoreErrorLine();
1113 setStatus(STATUS_ERROR_CODE, STATUS_VALUE_OFF, ""); 1098 setStatus(STATUS_ERROR_CODE, STATUS_VALUE_OFF, "");
1114
1115 } 1099 }
1116 1100
1117 protected boolean simulateMnemonic(int mnem) { 1101 protected boolean simulateMnemonic(int mnem) {
1118
1119 boolean simulated = false; 1102 boolean simulated = false;
1120 1103
1121 switch (mnem) { 1104 switch (mnem) {
1122 1105 case AID_CLEAR:
1123 case AID_CLEAR: 1106 case AID_ENTER:
1124 case AID_ENTER: 1107 case AID_PF1:
1125 case AID_PF1: 1108 case AID_PF2:
1126 case AID_PF2: 1109 case AID_PF3:
1127 case AID_PF3: 1110 case AID_PF4:
1128 case AID_PF4: 1111 case AID_PF5:
1129 case AID_PF5: 1112 case AID_PF6:
1130 case AID_PF6: 1113 case AID_PF7:
1131 case AID_PF7: 1114 case AID_PF8:
1132 case AID_PF8: 1115 case AID_PF9:
1133 case AID_PF9: 1116 case AID_PF10:
1134 case AID_PF10: 1117 case AID_PF11:
1135 case AID_PF11: 1118 case AID_PF12:
1136 case AID_PF12: 1119 case AID_PF13:
1137 case AID_PF13: 1120 case AID_PF14:
1138 case AID_PF14: 1121 case AID_PF15:
1139 case AID_PF15: 1122 case AID_PF16:
1140 case AID_PF16: 1123 case AID_PF17:
1141 case AID_PF17: 1124 case AID_PF18:
1142 case AID_PF18: 1125 case AID_PF19:
1143 case AID_PF19: 1126 case AID_PF20:
1144 case AID_PF20: 1127 case AID_PF21:
1145 case AID_PF21: 1128 case AID_PF22:
1146 case AID_PF22: 1129 case AID_PF23:
1147 case AID_PF23: 1130 case AID_PF24:
1148 case AID_PF24: 1131 case AID_ROLL_DOWN:
1149 case AID_ROLL_DOWN: 1132 case AID_ROLL_UP:
1150 case AID_ROLL_UP: 1133 case AID_ROLL_LEFT:
1151 case AID_ROLL_LEFT: 1134 case AID_ROLL_RIGHT:
1152 case AID_ROLL_RIGHT: 1135 if (!screenFields.isCanSendAid()) {
1153 1136 displayError(ERR_ENTER_NO_ALLOWED);
1154 if (!screenFields.isCanSendAid()) { 1137 }
1155 displayError(ERR_ENTER_NO_ALLOWED); 1138 else
1156 } else 1139 sendAid(mnem);
1157 sendAid(mnem); 1140
1158 simulated = true; 1141 simulated = true;
1159 1142 break;
1160 break; 1143
1161 case AID_HELP: 1144 case AID_HELP:
1162 sessionVT.sendHelpRequest(); 1145 sessionVT.sendHelpRequest();
1163 simulated = true; 1146 simulated = true;
1164 break; 1147 break;
1165 1148
1166 case AID_PRINT: 1149 case AID_PRINT:
1167 sessionVT.hostPrint(1); 1150 sessionVT.hostPrint(1);
1168 simulated = true; 1151 simulated = true;
1169 break; 1152 break;
1170 1153
1171 case BACK_SPACE: 1154 case BACK_SPACE:
1172 if (screenFields.getCurrentField() != null 1155 if (screenFields.getCurrentField() != null
1173 && screenFields.withinCurrentField(lastPos) 1156 && screenFields.withinCurrentField(lastPos)
1174 && !screenFields.isCurrentFieldBypassField()) { 1157 && !screenFields.isCurrentFieldBypassField()) {
1175 1158 if (screenFields.getCurrentField().startPos() == lastPos) {
1176 if (screenFields.getCurrentField().startPos() == lastPos) { 1159 if (backspaceError)
1177 if (backspaceError) 1160 displayError(ERR_CURSOR_PROTECTED);
1178 displayError(ERR_CURSOR_PROTECTED); 1161 else {
1162 gotoFieldPrev();
1163 goto_XY(screenFields.getCurrentField().endPos());
1164 updateDirty();
1165 }
1166 }
1179 else { 1167 else {
1168 screenFields.getCurrentField().getKeyPos(lastPos);
1169 screenFields.getCurrentField().changePos(-1);
1170 resetDirty(screenFields.getCurrentField().getCurrentPos());
1171 shiftLeft(screenFields.getCurrentField().getCurrentPos());
1172 updateDirty();
1173 screenFields.setCurrentFieldMDT();
1174 simulated = true;
1175 }
1176 }
1177 else {
1178 displayError(ERR_CURSOR_PROTECTED);
1179 }
1180
1181 break;
1182
1183 case BACK_TAB:
1184 if (screenFields.getCurrentField() != null
1185 && screenFields.isCurrentFieldHighlightedEntry()) {
1186 resetDirty(screenFields.getCurrentField().startPos);
1187 gotoFieldPrev();
1188 updateDirty();
1189 }
1190 else
1191 gotoFieldPrev();
1192
1193 if (screenFields.isCurrentFieldContinued()) {
1194 do {
1180 gotoFieldPrev(); 1195 gotoFieldPrev();
1181 goto_XY(screenFields.getCurrentField().endPos()); 1196 }
1197 while (screenFields.isCurrentFieldContinuedMiddle()
1198 || screenFields.isCurrentFieldContinuedLast());
1199 }
1200
1201 isInField(lastPos);
1202 simulated = true;
1203 break;
1204
1205 case UP:
1206 case MARK_UP:
1207 process_XY(lastPos - numCols);
1208 simulated = true;
1209 break;
1210
1211 case DOWN:
1212 case MARK_DOWN:
1213 process_XY(lastPos + numCols);
1214 simulated = true;
1215 break;
1216
1217 case LEFT:
1218 case MARK_LEFT:
1219 process_XY(lastPos - 1);
1220 simulated = true;
1221 break;
1222
1223 case RIGHT:
1224 case MARK_RIGHT:
1225 process_XY(lastPos + 1);
1226 simulated = true;
1227 break;
1228
1229 case NEXTWORD:
1230 gotoNextWord();
1231 simulated = true;
1232 break;
1233
1234 case PREVWORD:
1235 gotoPrevWord();
1236 simulated = true;
1237 break;
1238
1239 case DELETE:
1240 if (screenFields.getCurrentField() != null
1241 && screenFields.withinCurrentField(lastPos)
1242 && !screenFields.isCurrentFieldBypassField()) {
1243 resetDirty(lastPos);
1244 screenFields.getCurrentField().getKeyPos(lastPos);
1245 shiftLeft(screenFields.getCurrentFieldPos());
1246 screenFields.setCurrentFieldMDT();
1247 updateDirty();
1248 simulated = true;
1249 }
1250 else {
1251 displayError(ERR_CURSOR_PROTECTED);
1252 }
1253
1254 break;
1255
1256 case TAB:
1257 if (screenFields.getCurrentField() != null
1258 && !screenFields.isCurrentFieldContinued()) {
1259 if (screenFields.isCurrentFieldHighlightedEntry()) {
1260 resetDirty(screenFields.getCurrentField().startPos);
1261 gotoFieldNext();
1182 updateDirty(); 1262 updateDirty();
1183 } 1263 }
1264 else
1265 gotoFieldNext();
1184 } 1266 }
1185 else { 1267 else {
1186 screenFields.getCurrentField().getKeyPos(lastPos); 1268 do {
1187 screenFields.getCurrentField().changePos(-1); 1269 gotoFieldNext();
1188 resetDirty(screenFields.getCurrentField().getCurrentPos()); 1270 }
1189 shiftLeft(screenFields.getCurrentField().getCurrentPos()); 1271 while (screenFields.getCurrentField() != null
1190 updateDirty(); 1272 && (screenFields.isCurrentFieldContinuedMiddle() || screenFields
1191 screenFields.setCurrentFieldMDT(); 1273 .isCurrentFieldContinuedLast()));
1274 }
1275
1276 isInField(lastPos);
1277 simulated = true;
1278 break;
1279
1280 case EOF:
1281 if (screenFields.getCurrentField() != null
1282 && screenFields.withinCurrentField(lastPos)
1283 && !screenFields.isCurrentFieldBypassField()) {
1284 int where = endOfField(screenFields.getCurrentField()
1285 .startPos(), true);
1286
1287 if (where > 0) {
1288 setCursor((where / numCols) + 1, (where % numCols) + 1);
1289 }
1192 1290
1193 simulated = true; 1291 simulated = true;
1194 } 1292 }
1195 } else { 1293 else {
1196 displayError(ERR_CURSOR_PROTECTED); 1294 displayError(ERR_CURSOR_PROTECTED);
1197 1295 }
1198 }
1199 break;
1200 case BACK_TAB:
1201
1202 if (screenFields.getCurrentField() != null
1203 && screenFields.isCurrentFieldHighlightedEntry()) {
1204 resetDirty(screenFields.getCurrentField().startPos);
1205 gotoFieldPrev();
1206 updateDirty();
1207 } else
1208 gotoFieldPrev();
1209
1210 if (screenFields.isCurrentFieldContinued()) {
1211 do {
1212 gotoFieldPrev();
1213 } while (screenFields.isCurrentFieldContinuedMiddle()
1214 || screenFields.isCurrentFieldContinuedLast());
1215 }
1216 isInField(lastPos);
1217 simulated = true;
1218 break;
1219 case UP:
1220 case MARK_UP:
1221 process_XY(lastPos - numCols);
1222 simulated = true;
1223 break;
1224 case DOWN:
1225 case MARK_DOWN:
1226 process_XY(lastPos + numCols);
1227 simulated = true;
1228 break;
1229 case LEFT:
1230 case MARK_LEFT:
1231 process_XY(lastPos - 1);
1232 simulated = true;
1233 break;
1234 case RIGHT:
1235 case MARK_RIGHT:
1236 process_XY(lastPos + 1);
1237 simulated = true;
1238 break;
1239 case NEXTWORD:
1240 gotoNextWord();
1241 simulated = true;
1242 break;
1243 case PREVWORD:
1244 gotoPrevWord();
1245 simulated = true;
1246 break;
1247 case DELETE:
1248 if (screenFields.getCurrentField() != null
1249 && screenFields.withinCurrentField(lastPos)
1250 && !screenFields.isCurrentFieldBypassField()) {
1251 1296
1252 resetDirty(lastPos); 1297 resetDirty(lastPos);
1253 screenFields.getCurrentField().getKeyPos(lastPos); 1298 break;
1254 shiftLeft(screenFields.getCurrentFieldPos()); 1299
1255 screenFields.setCurrentFieldMDT(); 1300 case ERASE_EOF:
1256 updateDirty(); 1301 if (screenFields.getCurrentField() != null
1257 simulated = true; 1302 && screenFields.withinCurrentField(lastPos)
1258 } else { 1303 && !screenFields.isCurrentFieldBypassField()) {
1259 displayError(ERR_CURSOR_PROTECTED); 1304 int where = lastPos;
1260 }
1261
1262 break;
1263 case TAB:
1264
1265 if (screenFields.getCurrentField() != null
1266 && !screenFields.isCurrentFieldContinued()) {
1267 if (screenFields.isCurrentFieldHighlightedEntry()) {
1268 resetDirty(screenFields.getCurrentField().startPos);
1269 gotoFieldNext();
1270 updateDirty();
1271 } else
1272 gotoFieldNext();
1273 } else {
1274 do {
1275 gotoFieldNext();
1276 } while (screenFields.getCurrentField() != null
1277 && (screenFields.isCurrentFieldContinuedMiddle() || screenFields
1278 .isCurrentFieldContinuedLast()));
1279 }
1280
1281 isInField(lastPos);
1282 simulated = true;
1283
1284 break;
1285 case EOF:
1286 if (screenFields.getCurrentField() != null
1287 && screenFields.withinCurrentField(lastPos)
1288 && !screenFields.isCurrentFieldBypassField()) {
1289 int where = endOfField(screenFields.getCurrentField()
1290 .startPos(), true);
1291 if (where > 0) {
1292 setCursor((where / numCols) + 1, (where % numCols) + 1);
1293 }
1294 simulated = true;
1295 } else {
1296 displayError(ERR_CURSOR_PROTECTED);
1297 }
1298 resetDirty(lastPos);
1299
1300 break;
1301 case ERASE_EOF:
1302 if (screenFields.getCurrentField() != null
1303 && screenFields.withinCurrentField(lastPos)
1304 && !screenFields.isCurrentFieldBypassField()) {
1305
1306 int where = lastPos;
1307 resetDirty(lastPos);
1308 if (fieldExit()) {
1309 screenFields.setCurrentFieldMDT();
1310 if (!screenFields.isCurrentFieldContinued()) {
1311 gotoFieldNext();
1312 } else {
1313 do {
1314 gotoFieldNext();
1315 if (screenFields.isCurrentFieldContinued())
1316 fieldExit();
1317 } while (screenFields.isCurrentFieldContinuedMiddle()
1318 || screenFields.isCurrentFieldContinuedLast());
1319 }
1320 }
1321 updateDirty();
1322 goto_XY(where);
1323 simulated = true;
1324
1325 } else {
1326 displayError(ERR_CURSOR_PROTECTED);
1327 }
1328
1329 break;
1330 case ERASE_FIELD:
1331 if (screenFields.getCurrentField() != null
1332 && screenFields.withinCurrentField(lastPos)
1333 && !screenFields.isCurrentFieldBypassField()) {
1334
1335 int where = lastPos;
1336 lastPos = screenFields.getCurrentField().startPos();
1337 resetDirty(lastPos);
1338 if (fieldExit()) {
1339 screenFields.setCurrentFieldMDT();
1340 if (!screenFields.isCurrentFieldContinued()) {
1341 gotoFieldNext();
1342 } else {
1343 do {
1344 gotoFieldNext();
1345 if (screenFields.isCurrentFieldContinued())
1346 fieldExit();
1347 } while (screenFields.isCurrentFieldContinuedMiddle()
1348 || screenFields.isCurrentFieldContinuedLast());
1349 }
1350 }
1351 updateDirty();
1352 goto_XY(where);
1353 simulated = true;
1354
1355 } else {
1356 displayError(ERR_CURSOR_PROTECTED);
1357 }
1358
1359 break;
1360 case INSERT:
1361 // we toggle it
1362 oia.setInsertMode(oia.isInsertMode() ? false : true);
1363 break;
1364 case HOME:
1365 // position to the home position set
1366 if (lastPos + numCols + 1 != homePos) {
1367 goto_XY(homePos - numCols - 1);
1368 // now check if we are in a field
1369 isInField(lastPos);
1370 } else
1371 gotoField(1);
1372 break;
1373 case KEYPAD_0:
1374 simulated = simulateKeyStroke('0');
1375 break;
1376 case KEYPAD_1:
1377 simulated = simulateKeyStroke('1');
1378 break;
1379 case KEYPAD_2:
1380 simulated = simulateKeyStroke('2');
1381 break;
1382 case KEYPAD_3:
1383 simulated = simulateKeyStroke('3');
1384 break;
1385 case KEYPAD_4:
1386 simulated = simulateKeyStroke('4');
1387 break;
1388 case KEYPAD_5:
1389 simulated = simulateKeyStroke('5');
1390 break;
1391 case KEYPAD_6:
1392 simulated = simulateKeyStroke('6');
1393 break;
1394 case KEYPAD_7:
1395 simulated = simulateKeyStroke('7');
1396 break;
1397 case KEYPAD_8:
1398 simulated = simulateKeyStroke('8');
1399 break;
1400 case KEYPAD_9:
1401 simulated = simulateKeyStroke('9');
1402 break;
1403 case KEYPAD_PERIOD:
1404 simulated = simulateKeyStroke('.');
1405 break;
1406 case KEYPAD_COMMA:
1407 simulated = simulateKeyStroke(',');
1408 break;
1409 case KEYPAD_MINUS:
1410 if (screenFields.getCurrentField() != null
1411 && screenFields.withinCurrentField(lastPos)
1412 && !screenFields.isCurrentFieldBypassField()) {
1413
1414 int s = screenFields.getCurrentField().getFieldShift();
1415 if (s == 3 || s == 5 || s == 7) {
1416 planes.setChar(lastPos,'-');
1417
1418 resetDirty(lastPos); 1305 resetDirty(lastPos);
1419 advancePos(); 1306
1420 if (fieldExit()) { 1307 if (fieldExit()) {
1421 screenFields.setCurrentFieldMDT(); 1308 screenFields.setCurrentFieldMDT();
1309
1422 if (!screenFields.isCurrentFieldContinued()) { 1310 if (!screenFields.isCurrentFieldContinued()) {
1423 gotoFieldNext(); 1311 gotoFieldNext();
1424 } else { 1312 }
1313 else {
1425 do { 1314 do {
1426 gotoFieldNext(); 1315 gotoFieldNext();
1427 } while (screenFields 1316
1428 .isCurrentFieldContinuedMiddle() 1317 if (screenFields.isCurrentFieldContinued())
1429 || screenFields 1318 fieldExit();
1430 .isCurrentFieldContinuedLast()); 1319 }
1320 while (screenFields.isCurrentFieldContinuedMiddle()
1321 || screenFields.isCurrentFieldContinuedLast());
1431 } 1322 }
1432 simulated = true;
1433 updateDirty();
1434 if (screenFields.isCurrentFieldAutoEnter())
1435 sendAid(AID_ENTER);
1436
1437 } 1323 }
1438 } else { 1324
1439 displayError(ERR_FIELD_MINUS); 1325 updateDirty();
1440 1326 goto_XY(where);
1441 } 1327 simulated = true;
1442 } else { 1328 }
1443 displayError(ERR_CURSOR_PROTECTED); 1329 else {
1444 } 1330 displayError(ERR_CURSOR_PROTECTED);
1445 1331 }
1446 break; 1332
1447 case FIELD_EXIT: 1333 break;
1448 if (screenFields.getCurrentField() != null 1334
1449 && screenFields.withinCurrentField(lastPos) 1335 case ERASE_FIELD:
1450 && !screenFields.isCurrentFieldBypassField()) { 1336 if (screenFields.getCurrentField() != null
1451 1337 && screenFields.withinCurrentField(lastPos)
1452 resetDirty(lastPos); 1338 && !screenFields.isCurrentFieldBypassField()) {
1453 1339 int where = lastPos;
1454 boolean autoFE = screenFields.isCurrentFieldAutoEnter(); 1340 lastPos = screenFields.getCurrentField().startPos();
1455
1456 if (fieldExit()) {
1457 screenFields.setCurrentFieldMDT();
1458 if (!screenFields.isCurrentFieldContinued() &&
1459 !screenFields.isCurrentFieldAutoEnter()) {
1460 gotoFieldNext();
1461 } else {
1462 do {
1463 gotoFieldNext();
1464 if (screenFields.isCurrentFieldContinued())
1465 fieldExit();
1466 } while (screenFields.isCurrentFieldContinuedMiddle()
1467 || screenFields.isCurrentFieldContinuedLast());
1468 }
1469 }
1470
1471 updateDirty();
1472 simulated = true;
1473 if (autoFE)
1474 sendAid(AID_ENTER);
1475
1476 } else {
1477 displayError(ERR_CURSOR_PROTECTED);
1478 }
1479
1480 break;
1481 case FIELD_PLUS:
1482 if (screenFields.getCurrentField() != null
1483 && screenFields.withinCurrentField(lastPos)
1484 && !screenFields.isCurrentFieldBypassField()) {
1485
1486 resetDirty(lastPos);
1487
1488 boolean autoFE = screenFields.isCurrentFieldAutoEnter();
1489 if (fieldExit()) {
1490 screenFields.setCurrentFieldMDT();
1491 if (!screenFields.isCurrentFieldContinued() &&
1492 !screenFields.isCurrentFieldAutoEnter()) {
1493 gotoFieldNext();
1494 } else {
1495 do {
1496 gotoFieldNext();
1497 } while (screenFields.isCurrentFieldContinuedMiddle()
1498 || screenFields.isCurrentFieldContinuedLast());
1499 }
1500 }
1501 updateDirty();
1502 simulated = true;
1503
1504 if (autoFE)
1505 sendAid(AID_ENTER);
1506
1507 } else {
1508 displayError(ERR_CURSOR_PROTECTED);
1509 }
1510
1511 break;
1512 case FIELD_MINUS:
1513 if (screenFields.getCurrentField() != null
1514 && screenFields.withinCurrentField(lastPos)
1515 && !screenFields.isCurrentFieldBypassField()) {
1516
1517 int s = screenFields.getCurrentField().getFieldShift();
1518 if (s == 3 || s == 5 || s == 7) {
1519 planes.setChar(lastPos, '-');
1520
1521 resetDirty(lastPos); 1341 resetDirty(lastPos);
1522 advancePos();
1523
1524 boolean autoFE = screenFields.isCurrentFieldAutoEnter();
1525 1342
1526 if (fieldExit()) { 1343 if (fieldExit()) {
1527 screenFields.setCurrentFieldMDT(); 1344 screenFields.setCurrentFieldMDT();
1528 if (!screenFields.isCurrentFieldContinued() 1345
1529 && !screenFields.isCurrentFieldAutoEnter()) { 1346 if (!screenFields.isCurrentFieldContinued()) {
1347 gotoFieldNext();
1348 }
1349 else {
1350 do {
1351 gotoFieldNext();
1352
1353 if (screenFields.isCurrentFieldContinued())
1354 fieldExit();
1355 }
1356 while (screenFields.isCurrentFieldContinuedMiddle()
1357 || screenFields.isCurrentFieldContinuedLast());
1358 }
1359 }
1360
1361 updateDirty();
1362 goto_XY(where);
1363 simulated = true;
1364 }
1365 else {
1366 displayError(ERR_CURSOR_PROTECTED);
1367 }
1368
1369 break;
1370
1371 case INSERT:
1372 // we toggle it
1373 oia.setInsertMode(oia.isInsertMode() ? false : true);
1374 break;
1375
1376 case HOME:
1377
1378 // position to the home position set
1379 if (lastPos + numCols + 1 != homePos) {
1380 goto_XY(homePos - numCols - 1);
1381 // now check if we are in a field
1382 isInField(lastPos);
1383 }
1384 else
1385 gotoField(1);
1386
1387 break;
1388
1389 case KEYPAD_0:
1390 simulated = simulateKeyStroke('0');
1391 break;
1392
1393 case KEYPAD_1:
1394 simulated = simulateKeyStroke('1');
1395 break;
1396
1397 case KEYPAD_2:
1398 simulated = simulateKeyStroke('2');
1399 break;
1400
1401 case KEYPAD_3:
1402 simulated = simulateKeyStroke('3');
1403 break;
1404
1405 case KEYPAD_4:
1406 simulated = simulateKeyStroke('4');
1407 break;
1408
1409 case KEYPAD_5:
1410 simulated = simulateKeyStroke('5');
1411 break;
1412
1413 case KEYPAD_6:
1414 simulated = simulateKeyStroke('6');
1415 break;
1416
1417 case KEYPAD_7:
1418 simulated = simulateKeyStroke('7');
1419 break;
1420
1421 case KEYPAD_8:
1422 simulated = simulateKeyStroke('8');
1423 break;
1424
1425 case KEYPAD_9:
1426 simulated = simulateKeyStroke('9');
1427 break;
1428
1429 case KEYPAD_PERIOD:
1430 simulated = simulateKeyStroke('.');
1431 break;
1432
1433 case KEYPAD_COMMA:
1434 simulated = simulateKeyStroke(',');
1435 break;
1436
1437 case KEYPAD_MINUS:
1438 if (screenFields.getCurrentField() != null
1439 && screenFields.withinCurrentField(lastPos)
1440 && !screenFields.isCurrentFieldBypassField()) {
1441 int s = screenFields.getCurrentField().getFieldShift();
1442
1443 if (s == 3 || s == 5 || s == 7) {
1444 planes.setChar(lastPos, '-');
1445 resetDirty(lastPos);
1446 advancePos();
1447
1448 if (fieldExit()) {
1449 screenFields.setCurrentFieldMDT();
1450
1451 if (!screenFields.isCurrentFieldContinued()) {
1452 gotoFieldNext();
1453 }
1454 else {
1455 do {
1456 gotoFieldNext();
1457 }
1458 while (screenFields
1459 .isCurrentFieldContinuedMiddle()
1460 || screenFields
1461 .isCurrentFieldContinuedLast());
1462 }
1463
1464 simulated = true;
1465 updateDirty();
1466
1467 if (screenFields.isCurrentFieldAutoEnter())
1468 sendAid(AID_ENTER);
1469 }
1470 }
1471 else {
1472 displayError(ERR_FIELD_MINUS);
1473 }
1474 }
1475 else {
1476 displayError(ERR_CURSOR_PROTECTED);
1477 }
1478
1479 break;
1480
1481 case FIELD_EXIT:
1482 if (screenFields.getCurrentField() != null
1483 && screenFields.withinCurrentField(lastPos)
1484 && !screenFields.isCurrentFieldBypassField()) {
1485 resetDirty(lastPos);
1486 boolean autoFE = screenFields.isCurrentFieldAutoEnter();
1487
1488 if (fieldExit()) {
1489 screenFields.setCurrentFieldMDT();
1490
1491 if (!screenFields.isCurrentFieldContinued() &&
1492 !screenFields.isCurrentFieldAutoEnter()) {
1493 gotoFieldNext();
1494 }
1495 else {
1496 do {
1497 gotoFieldNext();
1498
1499 if (screenFields.isCurrentFieldContinued())
1500 fieldExit();
1501 }
1502 while (screenFields.isCurrentFieldContinuedMiddle()
1503 || screenFields.isCurrentFieldContinuedLast());
1504 }
1505 }
1506
1507 updateDirty();
1508 simulated = true;
1509
1510 if (autoFE)
1511 sendAid(AID_ENTER);
1512 }
1513 else {
1514 displayError(ERR_CURSOR_PROTECTED);
1515 }
1516
1517 break;
1518
1519 case FIELD_PLUS:
1520 if (screenFields.getCurrentField() != null
1521 && screenFields.withinCurrentField(lastPos)
1522 && !screenFields.isCurrentFieldBypassField()) {
1523 resetDirty(lastPos);
1524 boolean autoFE = screenFields.isCurrentFieldAutoEnter();
1525
1526 if (fieldExit()) {
1527 screenFields.setCurrentFieldMDT();
1528
1529 if (!screenFields.isCurrentFieldContinued() &&
1530 !screenFields.isCurrentFieldAutoEnter()) {
1530 gotoFieldNext(); 1531 gotoFieldNext();
1531 } 1532 }
1532 else { 1533 else {
1533 do { 1534 do {
1534 gotoFieldNext(); 1535 gotoFieldNext();
1535 } 1536 }
1536 while (screenFields.isCurrentFieldContinuedMiddle() 1537 while (screenFields.isCurrentFieldContinuedMiddle()
1537 || screenFields.isCurrentFieldContinuedLast()); 1538 || screenFields.isCurrentFieldContinuedLast());
1538 } 1539 }
1539 } 1540 }
1541
1540 updateDirty(); 1542 updateDirty();
1541 simulated = true; 1543 simulated = true;
1544
1542 if (autoFE) 1545 if (autoFE)
1543 sendAid(AID_ENTER); 1546 sendAid(AID_ENTER);
1544
1545 } 1547 }
1546 else { 1548 else {
1547 displayError(ERR_FIELD_MINUS); 1549 displayError(ERR_CURSOR_PROTECTED);
1548 1550 }
1549 } 1551
1550 } 1552 break;
1551 else { 1553
1552 displayError(ERR_CURSOR_PROTECTED); 1554 case FIELD_MINUS:
1553 } 1555 if (screenFields.getCurrentField() != null
1554 1556 && screenFields.withinCurrentField(lastPos)
1555 break; 1557 && !screenFields.isCurrentFieldBypassField()) {
1556 case BOF: 1558 int s = screenFields.getCurrentField().getFieldShift();
1557 if (screenFields.getCurrentField() != null 1559
1558 && screenFields.withinCurrentField(lastPos) 1560 if (s == 3 || s == 5 || s == 7) {
1559 && !screenFields.isCurrentFieldBypassField()) { 1561 planes.setChar(lastPos, '-');
1560 int where = screenFields.getCurrentField().startPos(); 1562 resetDirty(lastPos);
1561 if (where > 0) { 1563 advancePos();
1562 goto_XY(where); 1564 boolean autoFE = screenFields.isCurrentFieldAutoEnter();
1563 } 1565
1566 if (fieldExit()) {
1567 screenFields.setCurrentFieldMDT();
1568
1569 if (!screenFields.isCurrentFieldContinued()
1570 && !screenFields.isCurrentFieldAutoEnter()) {
1571 gotoFieldNext();
1572 }
1573 else {
1574 do {
1575 gotoFieldNext();
1576 }
1577 while (screenFields.isCurrentFieldContinuedMiddle()
1578 || screenFields.isCurrentFieldContinuedLast());
1579 }
1580 }
1581
1582 updateDirty();
1583 simulated = true;
1584
1585 if (autoFE)
1586 sendAid(AID_ENTER);
1587 }
1588 else {
1589 displayError(ERR_FIELD_MINUS);
1590 }
1591 }
1592 else {
1593 displayError(ERR_CURSOR_PROTECTED);
1594 }
1595
1596 break;
1597
1598 case BOF:
1599 if (screenFields.getCurrentField() != null
1600 && screenFields.withinCurrentField(lastPos)
1601 && !screenFields.isCurrentFieldBypassField()) {
1602 int where = screenFields.getCurrentField().startPos();
1603
1604 if (where > 0) {
1605 goto_XY(where);
1606 }
1607
1608 simulated = true;
1609 }
1610 else {
1611 displayError(ERR_CURSOR_PROTECTED);
1612 }
1613
1614 resetDirty(lastPos);
1615 break;
1616
1617 case SYSREQ:
1618 sessionVT.systemRequest();
1564 simulated = true; 1619 simulated = true;
1565 } else { 1620 break;
1566 displayError(ERR_CURSOR_PROTECTED); 1621
1567 } 1622 case RESET:
1568 resetDirty(lastPos); 1623 if (isStatusErrorCode()) {
1569 1624 resetError();
1570 break; 1625 isInField(lastPos);
1571 case SYSREQ:
1572 sessionVT.systemRequest();
1573 simulated = true;
1574 break;
1575 case RESET:
1576 if (isStatusErrorCode()) {
1577 resetError();
1578 isInField(lastPos);
1579 updateDirty();
1580 } else {
1581 setPrehelpState(false, oia.isKeyBoardLocked(), false);
1582 }
1583 simulated = true;
1584 break;
1585 case ATTN:
1586 sessionVT.sendAttentionKey();
1587 simulated = true;
1588 break;
1589 case DUP_FIELD:
1590 if (screenFields.getCurrentField() != null
1591 && screenFields.withinCurrentField(lastPos)
1592 && !screenFields.isCurrentFieldBypassField()) {
1593
1594 if (screenFields.isCurrentFieldDupEnabled()) {
1595 resetDirty(lastPos);
1596 screenFields.getCurrentField().setFieldChar(lastPos,
1597 (char) 0x1C);
1598 screenFields.setCurrentFieldMDT();
1599 gotoFieldNext();
1600 updateDirty(); 1626 updateDirty();
1601 simulated = true; 1627 }
1602 } else { 1628 else {
1603 displayError(ERR_DUP_KEY_NOT_ALLOWED); 1629 setPrehelpState(false, oia.isKeyBoardLocked(), false);
1604 } 1630 }
1605 } else { 1631
1606 displayError(ERR_CURSOR_PROTECTED); 1632 simulated = true;
1607 } 1633 break;
1608 1634
1609 break; 1635 case ATTN:
1610 case NEW_LINE: 1636 sessionVT.sendAttentionKey();
1611 if (screenFields.getSize() > 0) { 1637 simulated = true;
1612 int startRow = getRow(lastPos) + 1; 1638 break;
1613 int startPos = lastPos; 1639
1614 1640 case DUP_FIELD:
1615 if (startRow == getRows()) 1641 if (screenFields.getCurrentField() != null
1616 startRow = 0; 1642 && screenFields.withinCurrentField(lastPos)
1617
1618 setCursor(++startRow, 1);
1619
1620 if (!isInField() && screenFields.getCurrentField() != null
1621 && !screenFields.isCurrentFieldBypassField()) { 1643 && !screenFields.isCurrentFieldBypassField()) {
1622 while (!isInField() 1644 if (screenFields.isCurrentFieldDupEnabled()) {
1623 && screenFields.getCurrentField() != null 1645 resetDirty(lastPos);
1646 screenFields.getCurrentField().setFieldChar(lastPos,
1647 (char) 0x1C);
1648 screenFields.setCurrentFieldMDT();
1649 gotoFieldNext();
1650 updateDirty();
1651 simulated = true;
1652 }
1653 else {
1654 displayError(ERR_DUP_KEY_NOT_ALLOWED);
1655 }
1656 }
1657 else {
1658 displayError(ERR_CURSOR_PROTECTED);
1659 }
1660
1661 break;
1662
1663 case NEW_LINE:
1664 if (screenFields.getSize() > 0) {
1665 int startRow = getRow(lastPos) + 1;
1666 int startPos = lastPos;
1667
1668 if (startRow == getRows())
1669 startRow = 0;
1670
1671 setCursor(++startRow, 1);
1672
1673 if (!isInField() && screenFields.getCurrentField() != null
1624 && !screenFields.isCurrentFieldBypassField()) { 1674 && !screenFields.isCurrentFieldBypassField()) {
1625 1675 while (!isInField()
1626 // lets keep going 1676 && screenFields.getCurrentField() != null
1627 advancePos(); 1677 && !screenFields.isCurrentFieldBypassField()) {
1628 1678 // lets keep going
1629 // Have we looped the screen? 1679 advancePos();
1630 if (lastPos == startPos) { 1680
1631 // if so then go back to starting point 1681 // Have we looped the screen?
1632 goto_XY(startPos); 1682 if (lastPos == startPos) {
1633 break; 1683 // if so then go back to starting point
1684 goto_XY(startPos);
1685 break;
1686 }
1634 } 1687 }
1635 } 1688 }
1636 } 1689 }
1637 } 1690
1638 simulated = true; 1691 simulated = true;
1639 break; 1692 break;
1640 case FAST_CURSOR_DOWN: 1693
1641 int rowNow = (getCurrentRow()-1) + 3; 1694 case FAST_CURSOR_DOWN:
1642 if (rowNow > getRows()-1) 1695 int rowNow = (getCurrentRow() - 1) + 3;
1643 rowNow = rowNow - getRows(); 1696
1644 this.goto_XY(getPos(rowNow,getCurrentCol()-1)); 1697 if (rowNow > getRows() - 1)
1645 simulated = true; 1698 rowNow = rowNow - getRows();
1646 break; 1699
1647 case FAST_CURSOR_UP: 1700 this.goto_XY(getPos(rowNow, getCurrentCol() - 1));
1648 rowNow = (getCurrentRow()-1) - 3; 1701 simulated = true;
1649 if (rowNow < 0) 1702 break;
1650 rowNow = (getRows()) + rowNow; 1703
1651 this.goto_XY(getPos(rowNow,getCurrentCol()-1)); 1704 case FAST_CURSOR_UP:
1652 simulated = true; 1705 rowNow = (getCurrentRow() - 1) - 3;
1653 break; 1706
1654 case FAST_CURSOR_LEFT: 1707 if (rowNow < 0)
1655 int colNow = (getCurrentCol()-1) - 3; 1708 rowNow = (getRows()) + rowNow;
1656 rowNow = getCurrentRow()-1; 1709
1657 if (colNow <= 0) { 1710 this.goto_XY(getPos(rowNow, getCurrentCol() - 1));
1658 colNow = getColumns() + colNow; 1711 simulated = true;
1659 rowNow--; 1712 break;
1660 } 1713
1661 if (rowNow < 0) 1714 case FAST_CURSOR_LEFT:
1662 rowNow = getRows() - 1; 1715 int colNow = (getCurrentCol() - 1) - 3;
1663 1716 rowNow = getCurrentRow() - 1;
1664 process_XY(getPos(rowNow,colNow)); 1717
1665 simulated = true; 1718 if (colNow <= 0) {
1666 break; 1719 colNow = getColumns() + colNow;
1667 case FAST_CURSOR_RIGHT: 1720 rowNow--;
1668 colNow = (getCurrentCol()-1) + 3; 1721 }
1669 rowNow = getCurrentRow()-1; 1722
1670 if (colNow >= getColumns()) { 1723 if (rowNow < 0)
1671 colNow = colNow - getColumns(); 1724 rowNow = getRows() - 1;
1672 rowNow++; 1725
1673 } 1726 process_XY(getPos(rowNow, colNow));
1674 if (rowNow > getRows() - 1) 1727 simulated = true;
1675 rowNow = getRows() - rowNow; 1728 break;
1676 1729
1677 process_XY(getPos(rowNow,colNow)); 1730 case FAST_CURSOR_RIGHT:
1678 simulated = true; 1731 colNow = (getCurrentCol() - 1) + 3;
1679 break; 1732 rowNow = getCurrentRow() - 1;
1680 default: 1733
1681 Log.i(TAG," Mnemonic not supported " + mnem); 1734 if (colNow >= getColumns()) {
1682 break; 1735 colNow = colNow - getColumns();
1683 1736 rowNow++;
1737 }
1738
1739 if (rowNow > getRows() - 1)
1740 rowNow = getRows() - rowNow;
1741
1742 process_XY(getPos(rowNow, colNow));
1743 simulated = true;
1744 break;
1745
1746 default:
1747 Log.i(TAG, " Mnemonic not supported " + mnem);
1748 break;
1684 } 1749 }
1685 1750
1686 return simulated; 1751 return simulated;
1687 } 1752 }
1688 1753
1689 protected boolean simulateKeyStroke(char c) { 1754 protected boolean simulateKeyStroke(char c) {
1690
1691 if (isStatusErrorCode() && !Character.isISOControl(c) && !keyProcessed) { 1755 if (isStatusErrorCode() && !Character.isISOControl(c) && !keyProcessed) {
1692 if (resetRequired) return false; 1756 if (resetRequired) return false;
1757
1693 resetError(); 1758 resetError();
1694 } 1759 }
1695 1760
1696 boolean updateField = false; 1761 boolean updateField = false;
1697 boolean numericError = false; 1762 boolean numericError = false;
1698 boolean updatePos = false; 1763 boolean updatePos = false;
1699 boolean autoEnter = false; 1764 boolean autoEnter = false;
1700 1765
1701 if (!Character.isISOControl(c)) { 1766 if (!Character.isISOControl(c)) {
1702
1703 if (screenFields.getCurrentField() != null 1767 if (screenFields.getCurrentField() != null
1704 && screenFields.withinCurrentField(lastPos) 1768 && screenFields.withinCurrentField(lastPos)
1705 && !screenFields.isCurrentFieldBypassField()) { 1769 && !screenFields.isCurrentFieldBypassField()) {
1706
1707 if (screenFields.isCurrentFieldFER() 1770 if (screenFields.isCurrentFieldFER()
1708 && !screenFields.withinCurrentField(screenFields 1771 && !screenFields.withinCurrentField(screenFields
1709 .getCurrentFieldPos()) 1772 .getCurrentFieldPos())
1710 && lastPos == screenFields.getCurrentField().endPos() 1773 && lastPos == screenFields.getCurrentField().endPos()
1711 && screenFields.getCurrentFieldPos() > screenFields 1774 && screenFields.getCurrentFieldPos() > screenFields
1712 .getCurrentField().endPos()) { 1775 .getCurrentField().endPos()) {
1713
1714 displayError(ERR_FIELD_EXIT_INVALID); 1776 displayError(ERR_FIELD_EXIT_INVALID);
1715 feError = true; 1777 feError = true;
1716 return false; 1778 return false;
1717 } 1779 }
1718 1780
1719 switch (screenFields.getCurrentFieldShift()) { 1781 switch (screenFields.getCurrentFieldShift()) {
1720 case 0: // Alpha shift 1782 case 0: // Alpha shift
1721 case 2: // Numeric Shift 1783 case 2: // Numeric Shift
1722 case 4: // Kakana Shift 1784 case 4: // Kakana Shift
1723 updateField = true;
1724 break;
1725 case 1: // Alpha Only
1726 if (Character.isLetter(c) || c == ',' || c == '-'
1727 || c == '.' || c == ' ')
1728 updateField = true; 1785 updateField = true;
1729 break; 1786 break;
1730 case 3: // Numeric only 1787
1731 if (Character.isDigit(c) || c == '+' || c == ',' 1788 case 1: // Alpha Only
1732 || c == '-' || c == '.' || c == ' ') 1789 if (Character.isLetter(c) || c == ',' || c == '-'
1733 updateField = true; 1790 || c == '.' || c == ' ')
1734 else 1791 updateField = true;
1735 numericError = true; 1792
1736 break; 1793 break;
1737 case 5: // Digits only 1794
1738 if (Character.isDigit(c)) 1795 case 3: // Numeric only
1739 updateField = true; 1796 if (Character.isDigit(c) || c == '+' || c == ','
1740 else 1797 || c == '-' || c == '.' || c == ' ')
1741 displayError(ERR_NUMERIC_09); 1798 updateField = true;
1742 break;
1743 case 7: // Signed numeric
1744 if (Character.isDigit(c) || c == '+' || c == '-')
1745 if (lastPos == screenFields.getCurrentField().endPos()
1746 && (c != '+' && c != '-'))
1747 displayError(ERR_INVALID_SIGN);
1748 else 1799 else
1800 numericError = true;
1801
1802 break;
1803
1804 case 5: // Digits only
1805 if (Character.isDigit(c))
1749 updateField = true; 1806 updateField = true;
1750 else 1807 else
1751 displayError(ERR_NUMERIC_09); 1808 displayError(ERR_NUMERIC_09);
1752 break; 1809
1810 break;
1811
1812 case 7: // Signed numeric
1813 if (Character.isDigit(c) || c == '+' || c == '-')
1814 if (lastPos == screenFields.getCurrentField().endPos()
1815 && (c != '+' && c != '-'))
1816 displayError(ERR_INVALID_SIGN);
1817 else
1818 updateField = true;
1819 else
1820 displayError(ERR_NUMERIC_09);
1821
1822 break;
1753 } 1823 }
1754 1824
1755 if (updateField) { 1825 if (updateField) {
1756 if (screenFields.isCurrentFieldToUpper()) 1826 if (screenFields.isCurrentFieldToUpper())
1757 c = Character.toUpperCase(c); 1827 c = Character.toUpperCase(c);
1762 if (oia.isInsertMode()) { 1832 if (oia.isInsertMode()) {
1763 if (endOfField(false) != screenFields.getCurrentField() 1833 if (endOfField(false) != screenFields.getCurrentField()
1764 .endPos()) 1834 .endPos())
1765 shiftRight(lastPos); 1835 shiftRight(lastPos);
1766 else { 1836 else {
1767
1768 displayError(ERR_NO_ROOM_INSERT); 1837 displayError(ERR_NO_ROOM_INSERT);
1769 updatePos = false; 1838 updatePos = false;
1770 } 1839 }
1771
1772 } 1840 }
1773 1841
1774 if (updatePos) { 1842 if (updatePos) {
1775 screenFields.getCurrentField().getKeyPos( 1843 screenFields.getCurrentField().getKeyPos(
1776 getRow(lastPos), getCol(lastPos)); 1844 getRow(lastPos), getCol(lastPos));
1777 screenFields.getCurrentField().changePos(1); 1845 screenFields.getCurrentField().changePos(1);
1778 1846 planes.setChar(lastPos, c);
1779 planes.setChar(lastPos,c);
1780
1781 screenFields.setCurrentFieldMDT(); 1847 screenFields.setCurrentFieldMDT();
1782 1848
1783 // if we have gone passed the end of the field then goto 1849 // if we have gone passed the end of the field then goto
1784 // the next field 1850 // the next field
1785 if (!screenFields.withinCurrentField(screenFields 1851 if (!screenFields.withinCurrentField(screenFields
1786 .getCurrentFieldPos())) { 1852 .getCurrentFieldPos())) {
1787 if (screenFields.isCurrentFieldAutoEnter()) { 1853 if (screenFields.isCurrentFieldAutoEnter()) {
1788 autoEnter = true; 1854 autoEnter = true;
1789 } else if (!screenFields.isCurrentFieldFER()) 1855 }
1856 else if (!screenFields.isCurrentFieldFER())
1790 gotoFieldNext(); 1857 gotoFieldNext();
1791 else { 1858 else {
1792 // screenFields.getCurrentField().changePos(1); 1859 // screenFields.getCurrentField().changePos(1);
1793 // 1860 //
1794 // if (screenFields. 1861 // if (screenFields.
1797 // 1864 //
1798 // feError != feError; 1865 // feError != feError;
1799 // if (feError) 1866 // if (feError)
1800 // displayError(ERR_FIELD_EXIT_INVALID); 1867 // displayError(ERR_FIELD_EXIT_INVALID);
1801 } 1868 }
1802 1869 }
1803 } else 1870 else
1804 setCursor(screenFields.getCurrentField() 1871 setCursor(screenFields.getCurrentField()
1805 .getCursorRow() + 1, screenFields 1872 .getCursorRow() + 1, screenFields
1806 .getCurrentField().getCursorCol() + 1); 1873 .getCurrentField().getCursorCol() + 1);
1807
1808 } 1874 }
1809 1875
1810 fireScreenChanged(); 1876 fireScreenChanged();
1811 1877
1812 if (autoEnter) 1878 if (autoEnter)
1813 sendAid(AID_ENTER); 1879 sendAid(AID_ENTER);
1814 } else { 1880 }
1881 else {
1815 if (numericError) { 1882 if (numericError) {
1816 displayError(ERR_NUMERIC_ONLY); 1883 displayError(ERR_NUMERIC_ONLY);
1817 } 1884 }
1818 } 1885 }
1819 } else { 1886 }
1887 else {
1820 displayError(ERR_CURSOR_PROTECTED); 1888 displayError(ERR_CURSOR_PROTECTED);
1821 } 1889 }
1822 1890 }
1823 } 1891
1824 return updatePos; 1892 return updatePos;
1825 } 1893 }
1826 1894
1827 /** 1895 /**
1828 * Method: endOfField 1896 * Method: endOfField
1857 * the the last space or not 1925 * the the last space or not
1858 * @return a value of type int - the screen postion (row * columns) + col 1926 * @return a value of type int - the screen postion (row * columns) + col
1859 * 1927 *
1860 */ 1928 */
1861 private int endOfField(int pos, boolean posSpace) { 1929 private int endOfField(int pos, boolean posSpace) {
1862
1863 int endPos = screenFields.getCurrentField().endPos(); 1930 int endPos = screenFields.getCurrentField().endPos();
1864 int fePos = endPos; 1931 int fePos = endPos;
1865 // get the number of characters to the right 1932 // get the number of characters to the right
1866 int count = endPos - pos; 1933 int count = endPos - pos;
1867 1934
1868 // first lets get the real ending point without spaces and the such 1935 // first lets get the real ending point without spaces and the such
1869 while (planes.getChar(endPos) <= ' ' && count-- > 0) { 1936 while (planes.getChar(endPos) <= ' ' && count-- > 0) {
1870
1871 endPos--; 1937 endPos--;
1872 } 1938 }
1873 1939
1874 if (endPos == fePos) { 1940 if (endPos == fePos) {
1875
1876 return endPos; 1941 return endPos;
1877 1942 }
1878 } 1943
1879 screenFields.getCurrentField().getKeyPos(endPos); 1944 screenFields.getCurrentField().getKeyPos(endPos);
1945
1880 if (posSpace) screenFields.getCurrentField().changePos(+1); 1946 if (posSpace) screenFields.getCurrentField().changePos(+1);
1947
1881 return screenFields.getCurrentFieldPos(); 1948 return screenFields.getCurrentFieldPos();
1882
1883 } 1949 }
1884 1950
1885 private boolean fieldExit() { 1951 private boolean fieldExit() {
1886
1887 int pos = lastPos; 1952 int pos = lastPos;
1888 boolean mdt = false; 1953 boolean mdt = false;
1889 int end = endOfField(false); // get the ending position of the first 1954 int end = endOfField(false); // get the ending position of the first
1890 // non blank character in field 1955 // non blank character in field
1891
1892 ScreenField sf = screenFields.getCurrentField(); 1956 ScreenField sf = screenFields.getCurrentField();
1893 1957
1894 if (sf.isMandatoryEnter() && end == sf.startPos()) { 1958 if (sf.isMandatoryEnter() && end == sf.startPos()) {
1895 displayError(ERR_MANDITORY_ENTER); 1959 displayError(ERR_MANDITORY_ENTER);
1896 return false; 1960 return false;
1900 // positioning. the getKeyPos resets this information so it is useless 1964 // positioning. the getKeyPos resets this information so it is useless
1901 // for comparing if we are positioned passed the end of field. 1965 // for comparing if we are positioned passed the end of field.
1902 // Maybe this should be changed to not update the current cursor position 1966 // Maybe this should be changed to not update the current cursor position
1903 // of the field. 1967 // of the field.
1904 int currentPos = sf.getCurrentPos(); 1968 int currentPos = sf.getCurrentPos();
1905
1906 // get the number of characters to the right 1969 // get the number of characters to the right
1907 int count = (end - sf.startPos()) - sf.getKeyPos(pos); 1970 int count = (end - sf.startPos()) - sf.getKeyPos(pos);
1908 1971
1909 if (count == 0 && sf.isFER()) { 1972 if (count == 0 && sf.isFER()) {
1910 if (currentPos > sf.endPos()) { 1973 if (currentPos > sf.endPos()) {
1924 // a negative sign and then advances a position. If it is the 1987 // a negative sign and then advances a position. If it is the
1925 // end of the field where the minus is placed then this offset will 1988 // end of the field where the minus is placed then this offset will
1926 // place the count as -1. 1989 // place the count as -1.
1927 if (count == -1) { 1990 if (count == -1) {
1928 int s = sf.getFieldShift(); 1991 int s = sf.getFieldShift();
1992
1929 if (s == 3 || s == 5 || s == 7) { 1993 if (s == 3 || s == 5 || s == 7) {
1930 mdt = true; 1994 mdt = true;
1931 } 1995 }
1932 } 1996 }
1933 1997
1934 int adj = sf.getAdjustment(); 1998 int adj = sf.getAdjustment();
1935 1999
1936 if (adj != 0) { 2000 if (adj != 0) {
1937
1938 switch (adj) { 2001 switch (adj) {
1939 2002 case 5:
1940 case 5: 2003 rightAdjustField('0');
1941 rightAdjustField('0'); 2004 sf.setRightAdjusted();
1942 sf.setRightAdjusted(); 2005 break;
1943 break; 2006
1944 case 6: 2007 case 6:
1945 rightAdjustField(' '); 2008 rightAdjustField(' ');
1946 sf.setRightAdjusted(); 2009 sf.setRightAdjusted();
1947 2010 break;
1948 break; 2011
1949 case 7: 2012 case 7:
1950 sf.setManditoryEntered(); 2013 sf.setManditoryEntered();
1951 break; 2014 break;
1952
1953 } 2015 }
1954 } 2016 }
1955 else { 2017 else {
1956
1957 // we need to right adjust signed numeric fields as well. 2018 // we need to right adjust signed numeric fields as well.
1958 if (sf.isSignedNumeric()) { 2019 if (sf.isSignedNumeric()) {
1959 rightAdjustField(' '); 2020 rightAdjustField(' ');
1960 } 2021 }
1961 } 2022 }
1962 2023
1963 return mdt; 2024 return mdt;
1964 } 2025 }
1965 2026
1966 private void rightAdjustField(char fill) { 2027 private void rightAdjustField(char fill) {
1967
1968 int end = endOfField(false); // get the ending position of the first 2028 int end = endOfField(false); // get the ending position of the first
1969 // non blank character in field 2029 // non blank character in field
1970
1971 // get the number of characters to the right 2030 // get the number of characters to the right
1972 int count = screenFields.getCurrentField().endPos() - end; 2031 int count = screenFields.getCurrentField().endPos() - end;
1973 2032
1974 // subtract 1 from count for signed numeric - note for later 2033 // subtract 1 from count for signed numeric - note for later
1975 if (screenFields.getCurrentField().isSignedNumeric()) { 2034 if (screenFields.getCurrentField().isSignedNumeric()) {
1976 if (planes.getChar(end -1) != '-') 2035 if (planes.getChar(end - 1) != '-')
1977 count--; 2036 count--;
1978 } 2037 }
1979 2038
1980 int pos = screenFields.getCurrentField().startPos(); 2039 int pos = screenFields.getCurrentField().startPos();
1981 2040
1982 while (count-- >= 0) { 2041 while (count-- >= 0) {
1983
1984 shiftRight(pos); 2042 shiftRight(pos);
1985 planes.setChar(pos,fill); 2043 planes.setChar(pos, fill);
1986
1987 setDirty(pos); 2044 setDirty(pos);
1988 2045 }
1989 }
1990
1991 } 2046 }
1992 2047
1993 private void shiftLeft(int sPos) { 2048 private void shiftLeft(int sPos) {
1994
1995 int endPos = 0; 2049 int endPos = 0;
1996
1997 int pos = sPos; 2050 int pos = sPos;
1998 int pPos = sPos; 2051 int pPos = sPos;
1999
2000 ScreenField sf = screenFields.getCurrentField(); 2052 ScreenField sf = screenFields.getCurrentField();
2001 int end; 2053 int end;
2002 int count; 2054 int count;
2055
2003 do { 2056 do {
2004 end = endOfField(pPos, false); // get the ending position of the 2057 end = endOfField(pPos, false); // get the ending position of the
2005 // first 2058 // first
2006 // non blank character in field 2059 // non blank character in field
2007
2008 count = (end - screenFields.getCurrentField().startPos()) 2060 count = (end - screenFields.getCurrentField().startPos())
2009 - screenFields.getCurrentField().getKeyPos(pPos); 2061 - screenFields.getCurrentField().getKeyPos(pPos);
2010 2062
2011 // now we loop through and shift the remaining characters to the 2063 // now we loop through and shift the remaining characters to the
2012 // left 2064 // left
2013 while (count-- > 0) { 2065 while (count-- > 0) {
2014 pos++; 2066 pos++;
2015 planes.setChar(pPos,planes.getChar(pos)); 2067 planes.setChar(pPos, planes.getChar(pos));
2016 setDirty(pPos); 2068 setDirty(pPos);
2017 pPos = pos; 2069 pPos = pos;
2018
2019 } 2070 }
2020 2071
2021 if (screenFields.isCurrentFieldContinued()) { 2072 if (screenFields.isCurrentFieldContinued()) {
2022 gotoFieldNext(); 2073 gotoFieldNext();
2074
2023 if (screenFields.getCurrentField().isContinuedFirst()) 2075 if (screenFields.getCurrentField().isContinuedFirst())
2024 break; 2076 break;
2025 2077
2026 pos = screenFields.getCurrentField().startPos(); 2078 pos = screenFields.getCurrentField().startPos();
2027 planes.setChar(pPos,planes.getChar(pos)); 2079 planes.setChar(pPos, planes.getChar(pos));
2028 setDirty(pPos); 2080 setDirty(pPos);
2029
2030 pPos = pos; 2081 pPos = pos;
2031
2032 } 2082 }
2033 } while (screenFields.isCurrentFieldContinued() 2083 }
2084 while (screenFields.isCurrentFieldContinued()
2034 && !screenFields.getCurrentField().isContinuedFirst()); 2085 && !screenFields.getCurrentField().isContinuedFirst());
2035 2086
2036 if (end >= 0 && count >= -1) { 2087 if (end >= 0 && count >= -1) {
2037
2038 endPos = end; 2088 endPos = end;
2039 } else { 2089 }
2090 else {
2040 endPos = sPos; 2091 endPos = sPos;
2041
2042 } 2092 }
2043 2093
2044 screenFields.setCurrentField(sf); 2094 screenFields.setCurrentField(sf);
2045 planes.setChar(endPos,initChar); 2095 planes.setChar(endPos, initChar);
2046 setDirty(endPos); 2096 setDirty(endPos);
2047 goto_XY(screenFields.getCurrentFieldPos()); 2097 goto_XY(screenFields.getCurrentFieldPos());
2048 sf = null; 2098 sf = null;
2049
2050 } 2099 }
2051 2100
2052 private void shiftRight(int sPos) { 2101 private void shiftRight(int sPos) {
2053
2054 int end = endOfField(true); // get the ending position of the first 2102 int end = endOfField(true); // get the ending position of the first
2055 // non blank character in field 2103 // non blank character in field
2056 int pos = end; 2104 int pos = end;
2057 int pPos = end; 2105 int pPos = end;
2058
2059 int count = end - sPos; 2106 int count = end - sPos;
2060 2107
2061 // now we loop through and shift the remaining characters to the right 2108 // now we loop through and shift the remaining characters to the right
2062 while (count-- > 0) { 2109 while (count-- > 0) {
2063
2064 pos--; 2110 pos--;
2065 planes.setChar(pPos, planes.getChar(pos)); 2111 planes.setChar(pPos, planes.getChar(pos));
2066 setDirty(pPos); 2112 setDirty(pPos);
2067
2068 pPos = pos; 2113 pPos = pos;
2069 } 2114 }
2070 } 2115 }
2071 2116
2072 public int getRow(int pos) { 2117 public int getRow(int pos) {
2073
2074 // if (pos == 0) 2118 // if (pos == 0)
2075 // return 1; 2119 // return 1;
2076
2077 int row = pos / numCols; 2120 int row = pos / numCols;
2078 2121
2079 if (row < 0) { 2122 if (row < 0) {
2080
2081 row = lastPos / numCols; 2123 row = lastPos / numCols;
2082 } 2124 }
2125
2083 if (row > (lenScreen / numCols) - 1) 2126 if (row > (lenScreen / numCols) - 1)
2084 row = (lenScreen / numCols) - 1; 2127 row = (lenScreen / numCols) - 1;
2085 2128
2086 return row; 2129 return row;
2087
2088 } 2130 }
2089 2131
2090 public int getCol(int pos) { 2132 public int getCol(int pos) {
2091 int col = pos % (getColumns()); 2133 int col = pos % (getColumns());
2134
2092 if (col > 0) return col; 2135 if (col > 0) return col;
2136
2093 return 0; 2137 return 0;
2094 } 2138 }
2095 2139
2096 /** 2140 /**
2097 * This routine is 0 based offset. So to get row 20,1 then pass row 19,0 2141 * This routine is 0 based offset. So to get row 20,1 then pass row 19,0
2099 * @param row 2143 * @param row
2100 * @param col 2144 * @param col
2101 * @return 2145 * @return
2102 */ 2146 */
2103 public int getPos(int row, int col) { 2147 public int getPos(int row, int col) {
2104
2105 return (row * numCols) + col; 2148 return (row * numCols) + col;
2106 } 2149 }
2107 2150
2108 /** 2151 /**
2109 * Current position is based on offsets of 1,1 not 0,0 of the current 2152 * Current position is based on offsets of 1,1 not 0,0 of the current
2110 * position of the screen 2153 * position of the screen
2111 * 2154 *
2112 * @return int 2155 * @return int
2113 */ 2156 */
2114 public int getCurrentPos() { 2157 public int getCurrentPos() {
2115
2116 // return lastPos + numCols + 1; 2158 // return lastPos + numCols + 1;
2117 return lastPos + 1; 2159 return lastPos + 1;
2118
2119 } 2160 }
2120 2161
2121 /** 2162 /**
2122 * I got this information from a tcp trace of each error. I could not find 2163 * I got this information from a tcp trace of each error. I could not find
2123 * any documenation for this. Maybe there is but I could not find it. If 2164 * any documenation for this. Maybe there is but I could not find it. If
2183 private void displayError(int ec) { 2224 private void displayError(int ec) {
2184 saveHomePos = homePos; 2225 saveHomePos = homePos;
2185 homePos = lastPos + numCols + 1; 2226 homePos = lastPos + numCols + 1;
2186 pendingInsert = true; 2227 pendingInsert = true;
2187 sessionVT.sendNegResponse2(ec); 2228 sessionVT.sendNegResponse2(ec);
2188
2189 } 2229 }
2190 2230
2191 private void process_XY(int pos) { 2231 private void process_XY(int pos) {
2192
2193 if (pos < 0) 2232 if (pos < 0)
2194 pos = lenScreen + pos; 2233 pos = lenScreen + pos;
2234
2195 if (pos > lenScreen - 1) 2235 if (pos > lenScreen - 1)
2196 pos = pos - lenScreen; 2236 pos = pos - lenScreen;
2197 2237
2198 // if there was a field exit error then we need to treat the movement 2238 // if there was a field exit error then we need to treat the movement
2199 // of the cursor in a special way that equals that of Client Access. 2239 // of the cursor in a special way that equals that of Client Access.
2211 // Now to make it work like Client Access if the cursor is a back space 2251 // Now to make it work like Client Access if the cursor is a back space
2212 // then do not move the cursor but place it on the last field. All 2252 // then do not move the cursor but place it on the last field. All
2213 // other keys will reset the field position so that entering over the 2253 // other keys will reset the field position so that entering over the
2214 // last character will not cause an error but replace that character or 2254 // last character will not cause an error but replace that character or
2215 // just plain move the cursor if the key was to do that. 2255 // just plain move the cursor if the key was to do that.
2216
2217 ScreenField sf = screenFields.getCurrentField(); 2256 ScreenField sf = screenFields.getCurrentField();
2257
2218 if (feError) { 2258 if (feError) {
2219 feError = false; 2259 feError = false;
2220 sf.changePos(-1); 2260 sf.changePos(-1);
2221 } else { 2261 }
2222 if (sf != null&& sf.isFER()){ 2262 else {
2263 if (sf != null && sf.isFER()) {
2223 if ((sf.getCurrentPos() 2264 if ((sf.getCurrentPos()
2224 > sf.endPos())) { 2265 > sf.endPos())) {
2225 if (sf.withinField(pos)) { 2266 if (sf.withinField(pos)) {
2226 sf.getKeyPos(pos); 2267 sf.getKeyPos(pos);
2227 return; 2268 return;
2228 } 2269 }
2270
2229 sf.getKeyPos(sf.endPos()); 2271 sf.getKeyPos(sf.endPos());
2230 } 2272 }
2231 } 2273 }
2232 2274
2233 goto_XY(pos); 2275 goto_XY(pos);
2234 } 2276 }
2235 } 2277 }
2236 2278
2237 public boolean isUsingGuiInterface() { 2279 public boolean isUsingGuiInterface() {
2238
2239 return guiInterface; 2280 return guiInterface;
2240 } 2281 }
2241 2282
2242 /** 2283 /**
2243 * Convinience class to return if the cursor is in a field or not. 2284 * Convinience class to return if the cursor is in a field or not.
2244 * 2285 *
2245 * @return true or false 2286 * @return true or false
2246 */ 2287 */
2247 2288
2248 protected boolean isInField() { 2289 protected boolean isInField() {
2249
2250 return isInField(lastPos, true); 2290 return isInField(lastPos, true);
2251 } 2291 }
2252 2292
2253 /** 2293 /**
2254 * 2294 *
2259 * @param pos 2299 * @param pos
2260 * @param chgToField 2300 * @param chgToField
2261 * @return true or false 2301 * @return true or false
2262 */ 2302 */
2263 public boolean isInField(int pos, boolean chgToField) { 2303 public boolean isInField(int pos, boolean chgToField) {
2264
2265 return screenFields.isInField(pos, chgToField); 2304 return screenFields.isInField(pos, chgToField);
2266 } 2305 }
2267 2306
2268 /** 2307 /**
2269 * 2308 *
2273 * 2312 *
2274 * @param pos 2313 * @param pos
2275 * @return true or false 2314 * @return true or false
2276 */ 2315 */
2277 public boolean isInField(int pos) { 2316 public boolean isInField(int pos) {
2278
2279 return screenFields.isInField(pos, true); 2317 return screenFields.isInField(pos, true);
2280 } 2318 }
2281 2319
2282 /** 2320 /**
2283 * Convinience class to return if the position at row and column that is 2321 * Convinience class to return if the position at row and column that is
2287 * @param row 2325 * @param row
2288 * @param col 2326 * @param col
2289 * @return true or false 2327 * @return true or false
2290 */ 2328 */
2291 public boolean isInField(int row, int col) { 2329 public boolean isInField(int row, int col) {
2292
2293 return isInField(row, col, true); 2330 return isInField(row, col, true);
2294 } 2331 }
2295 2332
2296 /** 2333 /**
2297 * 2334 *
2313 * Gets the length of the screen - number of rows times number of columns 2350 * Gets the length of the screen - number of rows times number of columns
2314 * 2351 *
2315 * @return int value of screen length 2352 * @return int value of screen length
2316 */ 2353 */
2317 public int getScreenLength() { 2354 public int getScreenLength() {
2318
2319 return lenScreen; 2355 return lenScreen;
2320 } 2356 }
2321 2357
2322 /** 2358 /**
2323 * Get the number or rows available. 2359 * Get the number or rows available.
2324 * 2360 *
2325 * @return number of rows 2361 * @return number of rows
2326 */ 2362 */
2327 public int getRows() { 2363 public int getRows() {
2328
2329 return numRows; 2364 return numRows;
2330
2331 } 2365 }
2332 2366
2333 /** 2367 /**
2334 * Get the number of columns available. 2368 * Get the number of columns available.
2335 * 2369 *
2336 * @return number of columns 2370 * @return number of columns
2337 */ 2371 */
2338 public int getColumns() { 2372 public int getColumns() {
2339
2340 return numCols; 2373 return numCols;
2341
2342 } 2374 }
2343 2375
2344 /** 2376 /**
2345 * Get the current row where the cursor is 2377 * Get the current row where the cursor is
2346 * 2378 *
2347 * @return the cursor current row position 1,1 based 2379 * @return the cursor current row position 1,1 based
2348 */ 2380 */
2349 public int getCurrentRow() { 2381 public int getCurrentRow() {
2350
2351 return (lastPos / numCols) + 1; 2382 return (lastPos / numCols) + 1;
2352
2353 } 2383 }
2354 2384
2355 /** 2385 /**
2356 * Get the current column where the cursor is 2386 * Get the current column where the cursor is
2357 * 2387 *
2358 * @return the cursor current column position 1,1 based 2388 * @return the cursor current column position 1,1 based
2359 */ 2389 */
2360 public int getCurrentCol() { 2390 public int getCurrentCol() {
2361
2362 return (lastPos % numCols) + 1; 2391 return (lastPos % numCols) + 1;
2363
2364 } 2392 }
2365 2393
2366 /** 2394 /**
2367 * The last position of the cursor on the screen - Note - position is based 2395 * The last position of the cursor on the screen - Note - position is based
2368 * 0,0 2396 * 0,0
2369 * 2397 *
2370 * @return last position 2398 * @return last position
2371 */ 2399 */
2372 protected int getLastPos() { 2400 protected int getLastPos() {
2373
2374 return lastPos; 2401 return lastPos;
2375
2376 } 2402 }
2377 2403
2378 /** 2404 /**
2379 * Hotspot More... string 2405 * Hotspot More... string
2380 * 2406 *
2403 char[] sac = new char[lenScreen]; 2429 char[] sac = new char[lenScreen];
2404 char c; 2430 char c;
2405 2431
2406 for (int x = 0; x < lenScreen; x++) { 2432 for (int x = 0; x < lenScreen; x++) {
2407 c = planes.getChar(x); 2433 c = planes.getChar(x);
2434
2408 // only draw printable characters (in this case >= ' ') 2435 // only draw printable characters (in this case >= ' ')
2409 if ((c >= ' ') && (!planes.isAttributePlace(x))) { 2436 if ((c >= ' ') && (!planes.isAttributePlace(x))) {
2410 sac[x] = c; 2437 sac[x] = c;
2411 // TODO: implement the underline check here 2438 // TODO: implement the underline check here
2412 // if (screen[x].underLine && c <= ' ') 2439 // if (screen[x].underLine && c <= ' ')
2413 // sac[x] = '_'; 2440 // sac[x] = '_';
2414 } else 2441 }
2442 else
2415 sac[x] = ' '; 2443 sac[x] = ' ';
2416 } 2444 }
2417 2445
2418 return sac; 2446 return sac;
2419 } 2447 }
2420 2448
2421 public char[] getData(int startRow, int startCol, int endRow, int endCol, int plane) { 2449 public char[] getData(int startRow, int startCol, int endRow, int endCol, int plane) {
2422 try { 2450 try {
2423 int from = getPos(startRow,startCol); 2451 int from = getPos(startRow, startCol);
2424 int to = getPos(endRow,endCol); 2452 int to = getPos(endRow, endCol);
2453
2425 if (from > to) { 2454 if (from > to) {
2426
2427 int f = from; 2455 int f = from;
2428 to = f; 2456 to = f;
2429 from = f; 2457 from = f;
2430 } 2458 }
2431 return planes.getPlaneData(from,to,plane); 2459
2460 return planes.getPlaneData(from, to, plane);
2432 } 2461 }
2433 catch (Exception oe) { 2462 catch (Exception oe) {
2434 return null; 2463 return null;
2435 } 2464 }
2436
2437 } 2465 }
2438 2466
2439 /** 2467 /**
2440 * <p> 2468 * <p>
2441 * GetScreen retrieves the various planes associated with the presentation 2469 * GetScreen retrieves the various planes associated with the presentation
2456 * @param bufferLength 2484 * @param bufferLength
2457 * @param plane 2485 * @param plane
2458 * @return The number of characters copied to the buffer 2486 * @return The number of characters copied to the buffer
2459 * @throws OhioException 2487 * @throws OhioException
2460 */ 2488 */
2489
2461 public synchronized int GetScreen(char buffer[], int bufferLength, int plane) 2490 public synchronized int GetScreen(char buffer[], int bufferLength, int plane)
2462 // throws OhioException { 2491 // throws OhioException {
2463 { 2492 {
2464 return GetScreen(buffer,bufferLength,0,lenScreen,plane); 2493 return GetScreen(buffer, bufferLength, 0, lenScreen, plane);
2465
2466 } 2494 }
2467 2495
2468 /** 2496 /**
2469 * <p> 2497 * <p>
2470 * GetScreen retrieves the various planes associated with the presentation 2498 * GetScreen retrieves the various planes associated with the presentation
2487 * @param length 2515 * @param length
2488 * @param plane 2516 * @param plane
2489 * @return The number of characters copied to the buffer 2517 * @return The number of characters copied to the buffer
2490 * @throws OhioException 2518 * @throws OhioException
2491 */ 2519 */
2520
2492 public synchronized int GetScreen(char buffer[], int bufferLength, int from, 2521 public synchronized int GetScreen(char buffer[], int bufferLength, int from,
2493 int length, int plane) 2522 int length, int plane)
2494 // throws OhioException { 2523 // throws OhioException {
2495 { 2524 {
2496 2525 return planes.GetScreen(buffer, bufferLength, from, length, plane);
2497 return planes.GetScreen(buffer,bufferLength, from, length, plane);
2498 } 2526 }
2499 2527
2500 /** 2528 /**
2501 * <p> 2529 * <p>
2502 * GetScreen retrieves the various planes associated with the presentation 2530 * GetScreen retrieves the various planes associated with the presentation
2521 * @param length 2549 * @param length
2522 * @param plane 2550 * @param plane
2523 * @return The number of characters copied to the buffer. 2551 * @return The number of characters copied to the buffer.
2524 * @throws OhioException 2552 * @throws OhioException
2525 */ 2553 */
2554
2526 public synchronized int GetScreen(char buffer[], int bufferLength, int row, 2555 public synchronized int GetScreen(char buffer[], int bufferLength, int row,
2527 int col, int length, int plane) 2556 int col, int length, int plane)
2528 // throws OhioException { 2557 // throws OhioException {
2529 { 2558 {
2530 // Call GetScreen function after converting row and column to 2559 // Call GetScreen function after converting row and column to
2531 // a position. 2560 // a position.
2532 return planes.GetScreen(buffer,bufferLength, row, col, length, plane); 2561 return planes.GetScreen(buffer, bufferLength, row, col, length, plane);
2533 } 2562 }
2534 2563
2535 /** 2564 /**
2536 * <p> 2565 * <p>
2537 * GetScreenRect retrieves data from the various planes associated with the 2566 * GetScreenRect retrieves data from the various planes associated with the
2560 * @param endPos 2589 * @param endPos
2561 * @param plane 2590 * @param plane
2562 * @return The number of characters copied to the buffer 2591 * @return The number of characters copied to the buffer
2563 * @throws OhioException 2592 * @throws OhioException
2564 */ 2593 */
2594
2565 public synchronized int GetScreenRect(char buffer[], int bufferLength, 2595 public synchronized int GetScreenRect(char buffer[], int bufferLength,
2566 int startPos, int endPos, int plane) 2596 int startPos, int endPos, int plane)
2567 // throws OhioException { 2597 // throws OhioException {
2568 { 2598 {
2569 return planes.GetScreenRect(buffer, bufferLength, startPos, endPos, plane); 2599 return planes.GetScreenRect(buffer, bufferLength, startPos, endPos, plane);
2570
2571 } 2600 }
2572 2601
2573 /** 2602 /**
2574 * <p> 2603 * <p>
2575 * GetScreenRect retrieves data from the various planes associated with the 2604 * GetScreenRect retrieves data from the various planes associated with the
2600 * @param endCol 2629 * @param endCol
2601 * @param plane 2630 * @param plane
2602 * @return The number characters copied to the buffer 2631 * @return The number characters copied to the buffer
2603 * @throws OhioException 2632 * @throws OhioException
2604 */ 2633 */
2634
2605 public synchronized int GetScreenRect(char buffer[], int bufferLength, 2635 public synchronized int GetScreenRect(char buffer[], int bufferLength,
2606 int startRow, int startCol, 2636 int startRow, int startCol,
2607 int endRow, int endCol, int plane) 2637 int endRow, int endCol, int plane)
2608 // throws OhioException { 2638 // throws OhioException {
2609 { 2639 {
2610
2611 return planes.GetScreenRect(buffer, bufferLength, startRow, startCol, endRow, 2640 return planes.GetScreenRect(buffer, bufferLength, startRow, startCol, endRow,
2612 endCol, plane); 2641 endCol, plane);
2613 } 2642 }
2614 2643
2615 public synchronized boolean[] getActiveAidKeys() { 2644 public synchronized boolean[] getActiveAidKeys() {
2616 return sessionVT.getActiveAidKeys(); 2645 return sessionVT.getActiveAidKeys();
2617 } 2646 }
2618 2647
2619 protected synchronized void setScreenData(String text, int location) { 2648 protected synchronized void setScreenData(String text, int location) {
2620 // throws OhioException { 2649 // throws OhioException {
2621
2622 if (location < 0 || location > lenScreen) { 2650 if (location < 0 || location > lenScreen) {
2623 return; 2651 return;
2624 // throw new OhioException(sessionVT.getSessionConfiguration(), 2652 // throw new OhioException(sessionVT.getSessionConfiguration(),
2625 // OhioScreen5250.class.getName(), "osohio.screen.ohio00300", 1); 2653 // OhioScreen5250.class.getName(), "osohio.screen.ohio00300", 1);
2626 } 2654 }
2627 2655
2628 int pos = location; 2656 int pos = location;
2629
2630 int l = text.length(); 2657 int l = text.length();
2631 boolean updated = false; 2658 boolean updated = false;
2632 boolean flag = false; 2659 boolean flag = false;
2633 int x =0; 2660 int x = 0;
2661
2634 for (; x < l; x++) { 2662 for (; x < l; x++) {
2635 if (isInField(pos + x,true)) { 2663 if (isInField(pos + x, true)) {
2636 if (!screenFields.getCurrentField().isBypassField()) { 2664 if (!screenFields.getCurrentField().isBypassField()) {
2637 if (!flag) { 2665 if (!flag) {
2638 screenFields.getCurrentField().setMDT(); 2666 screenFields.getCurrentField().setMDT();
2639 updated = true; 2667 updated = true;
2640 resetDirty(pos + x); 2668 resetDirty(pos + x);
2644 2672
2645 planes.screen[pos + x] = text.charAt(x); 2673 planes.screen[pos + x] = text.charAt(x);
2646 setDirty(pos + x); 2674 setDirty(pos + x);
2647 } 2675 }
2648 } 2676 }
2649 2677 }
2650 } 2678
2651 lastPos = pos + x; 2679 lastPos = pos + x;
2680
2652 if (updated) { 2681 if (updated) {
2653 fireScreenChanged(); 2682 fireScreenChanged();
2654 } 2683 }
2655
2656 } 2684 }
2657 2685
2658 /** 2686 /**
2659 * This routine is based on offset 1,1 not 0,0 it will translate to offset 2687 * This routine is based on offset 1,1 not 0,0 it will translate to offset
2660 * 0,0 and call the goto_XY(int pos) it is mostly used from external classes 2688 * 0,0 and call the goto_XY(int pos) it is mostly used from external classes
2680 * set the content of the field at (l,c) to data 2708 * set the content of the field at (l,c) to data
2681 * if l == -1, set the current field contents to data 2709 * if l == -1, set the current field contents to data
2682 */ 2710 */
2683 public void setField(int l, int c, char [] data) { 2711 public void setField(int l, int c, char [] data) {
2684 ScreenField cf; 2712 ScreenField cf;
2713
2685 if (l >= 0) { 2714 if (l >= 0) {
2686 int position = l * numCols + c; 2715 int position = l * numCols + c;
2687 isInField(position, true); 2716 isInField(position, true);
2688 } 2717 }
2718
2689 if ((data != null) && (data.length > 0)) { 2719 if ((data != null) && (data.length > 0)) {
2690 cf = screenFields.getCurrentField(); 2720 cf = screenFields.getCurrentField();
2691 cf.setString(new String(data)); 2721 cf.setString(new String(data));
2692 lastPos = cf.getStartPos(); 2722 lastPos = cf.getStartPos();
2693 setDirty(lastPos); 2723 setDirty(lastPos);
2694 setDirty(lastPos + cf.getLength()); 2724 setDirty(lastPos + cf.getLength());
2695 } 2725 }
2726
2696 updateDirty(); 2727 updateDirty();
2697 } 2728 }
2698 2729
2699 /** 2730 /**
2700 * Set the current working field to the field number specified. 2731 * Set the current working field to the field number specified.
2702 * @param f - 2733 * @param f -
2703 * numeric field number on the screen 2734 * numeric field number on the screen
2704 * @return true or false whether it was sucessful 2735 * @return true or false whether it was sucessful
2705 */ 2736 */
2706 public boolean gotoField(int f) { 2737 public boolean gotoField(int f) {
2707
2708 int sizeFields = screenFields.getSize(); 2738 int sizeFields = screenFields.getSize();
2709 2739
2710 if (f > sizeFields || f <= 0) 2740 if (f > sizeFields || f <= 0)
2711 return false; 2741 return false;
2712 2742
2713 screenFields.setCurrentField(screenFields.getField(f - 1)); 2743 screenFields.setCurrentField(screenFields.getField(f - 1));
2714 2744
2715 while (screenFields.isCurrentFieldBypassField() && f < sizeFields) { 2745 while (screenFields.isCurrentFieldBypassField() && f < sizeFields) {
2716
2717 screenFields.setCurrentField(screenFields.getField(f++)); 2746 screenFields.setCurrentField(screenFields.getField(f++));
2718 2747 }
2719 } 2748
2720 return gotoField(screenFields.getCurrentField()); 2749 return gotoField(screenFields.getCurrentField());
2721 } 2750 }
2722 2751
2723 /** 2752 /**
2724 * Convenience method to set the field object passed as the currect working 2753 * Convenience method to set the field object passed as the currect working
2731 protected boolean gotoField(ScreenField f) { 2760 protected boolean gotoField(ScreenField f) {
2732 if (f != null) { 2761 if (f != null) {
2733 goto_XY(f.startPos()); 2762 goto_XY(f.startPos());
2734 return true; 2763 return true;
2735 } 2764 }
2765
2736 return false; 2766 return false;
2737 } 2767 }
2738 2768
2739 /** 2769 /**
2740 * Convenience class to position the cursor to the next word on the screen 2770 * Convenience class to position the cursor to the next word on the screen
2741 * 2771 *
2742 */ 2772 */
2743 private void gotoNextWord() { 2773 private void gotoNextWord() {
2744
2745 int pos = lastPos; 2774 int pos = lastPos;
2746 2775
2747 if (planes.getChar(lastPos) > ' ') { 2776 if (planes.getChar(lastPos) > ' ') {
2748 advancePos(); 2777 advancePos();
2778
2749 // get the next space character 2779 // get the next space character
2750 while (planes.getChar(lastPos) > ' ' && pos != lastPos) { 2780 while (planes.getChar(lastPos) > ' ' && pos != lastPos) {
2751 advancePos(); 2781 advancePos();
2752 } 2782 }
2753 } else 2783 }
2784 else
2754 advancePos(); 2785 advancePos();
2755 2786
2756 // now that we are positioned on the next space character get the 2787 // now that we are positioned on the next space character get the
2757 // next none space character 2788 // next none space character
2758 while (planes.getChar(lastPos) <= ' ' && pos != lastPos) { 2789 while (planes.getChar(lastPos) <= ' ' && pos != lastPos) {
2759 advancePos(); 2790 advancePos();
2760 } 2791 }
2761
2762 } 2792 }
2763 2793
2764 /** 2794 /**
2765 * Convenience class to position the cursor to the previous word on the 2795 * Convenience class to position the cursor to the previous word on the
2766 * screen 2796 * screen
2767 * 2797 *
2768 */ 2798 */
2769 private void gotoPrevWord() { 2799 private void gotoPrevWord() {
2770
2771 int pos = lastPos; 2800 int pos = lastPos;
2772
2773 changePos(-1); 2801 changePos(-1);
2774 2802
2775 // position previous white space character 2803 // position previous white space character
2776 while (planes.getChar(lastPos) <= ' ') { 2804 while (planes.getChar(lastPos) <= ' ') {
2777 changePos(-1); 2805 changePos(-1);
2806
2778 if (pos == lastPos) 2807 if (pos == lastPos)
2779 break; 2808 break;
2780 } 2809 }
2781 2810
2782 changePos(-1); 2811 changePos(-1);
2812
2783 // get the previous space character 2813 // get the previous space character
2784 while (planes.getChar(lastPos) > ' ' && pos != lastPos) { 2814 while (planes.getChar(lastPos) > ' ' && pos != lastPos) {
2785 changePos(-1); 2815 changePos(-1);
2786 } 2816 }
2787 2817
2788 // and position one position more should give us the beginning of word 2818 // and position one position more should give us the beginning of word
2789 advancePos(); 2819 advancePos();
2790
2791 } 2820 }
2792 2821
2793 /** 2822 /**
2794 * Convinience class to position to the next field on the screen. 2823 * Convinience class to position to the next field on the screen.
2795 * 2824 *
2796 * @see org.tn5250j.ScreenFields 2825 * @see org.tn5250j.ScreenFields
2797 */ 2826 */
2798 private void gotoFieldNext() { 2827 private void gotoFieldNext() {
2799
2800 if (screenFields.isCurrentFieldHighlightedEntry()) 2828 if (screenFields.isCurrentFieldHighlightedEntry())
2801 unsetFieldHighlighted(screenFields.getCurrentField()); 2829 unsetFieldHighlighted(screenFields.getCurrentField());
2802 2830
2803 screenFields.gotoFieldNext(); 2831 screenFields.gotoFieldNext();
2804 2832
2810 * Convinience class to position to the previous field on the screen. 2838 * Convinience class to position to the previous field on the screen.
2811 * 2839 *
2812 * @see org.tn5250j.ScreenFields 2840 * @see org.tn5250j.ScreenFields
2813 */ 2841 */
2814 private void gotoFieldPrev() { 2842 private void gotoFieldPrev() {
2815
2816 if (screenFields.isCurrentFieldHighlightedEntry()) 2843 if (screenFields.isCurrentFieldHighlightedEntry())
2817 unsetFieldHighlighted(screenFields.getCurrentField()); 2844 unsetFieldHighlighted(screenFields.getCurrentField());
2818 2845
2819 screenFields.gotoFieldPrev(); 2846 screenFields.gotoFieldPrev();
2820 2847
2821 if (screenFields.isCurrentFieldHighlightedEntry()) 2848 if (screenFields.isCurrentFieldHighlightedEntry())
2822 setFieldHighlighted(screenFields.getCurrentField()); 2849 setFieldHighlighted(screenFields.getCurrentField());
2823
2824 } 2850 }
2825 2851
2826 /* *** NEVER USED LOCALLY ************************************************** */ 2852 /* *** NEVER USED LOCALLY ************************************************** */
2827 // /** 2853 // /**
2828 // * Used to restrict the cursor to a particular position on the screen. Used 2854 // * Used to restrict the cursor to a particular position on the screen. Used
2858 * @param ll 2884 * @param ll
2859 * @param bottom 2885 * @param bottom
2860 * @param lr 2886 * @param lr
2861 */ 2887 */
2862 protected void createWindow(int depth, int width, int type, boolean gui, 2888 protected void createWindow(int depth, int width, int type, boolean gui,
2863 int monoAttr, int colorAttr, int ul, int upper, int ur, int left, 2889 int monoAttr, int colorAttr, int ul, int upper, int ur, int left,
2864 int right, int ll, int bottom, int lr) { 2890 int right, int ll, int bottom, int lr) {
2865
2866 int c = getCol(lastPos); 2891 int c = getCol(lastPos);
2867 int w = 0; 2892 int w = 0;
2868 width++; 2893 width++;
2869
2870 w = width; 2894 w = width;
2871 // set leading attribute byte 2895 // set leading attribute byte
2872 // screen[lastPos].setCharAndAttr(initChar, initAttr, true); 2896 // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
2873 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true); 2897 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true);
2874 setDirty(lastPos); 2898 setDirty(lastPos);
2875
2876 advancePos(); 2899 advancePos();
2877 // set upper left 2900 // set upper left
2878 // screen[lastPos].setCharAndAttr((char) ul, colorAttr, false); 2901 // screen[lastPos].setCharAndAttr((char) ul, colorAttr, false);
2879 planes.setScreenCharAndAttr(lastPos, (char) ul, colorAttr, false); 2902 planes.setScreenCharAndAttr(lastPos, (char) ul, colorAttr, false);
2903
2880 if (gui) { 2904 if (gui) {
2881 // screen[lastPos].setUseGUI(UPPER_LEFT); 2905 // screen[lastPos].setUseGUI(UPPER_LEFT);
2882 planes.setUseGUI(lastPos, UPPER_LEFT); 2906 planes.setUseGUI(lastPos, UPPER_LEFT);
2883 } 2907 }
2908
2884 setDirty(lastPos); 2909 setDirty(lastPos);
2885
2886 advancePos(); 2910 advancePos();
2887 2911
2888 // draw top row 2912 // draw top row
2889 2913
2890 while (w-- >= 0) { 2914 while (w-- >= 0) {
2891 // screen[lastPos].setCharAndAttr((char) upper, colorAttr, false); 2915 // screen[lastPos].setCharAndAttr((char) upper, colorAttr, false);
2892 planes.setScreenCharAndAttr(lastPos, (char) upper, colorAttr, false); 2916 planes.setScreenCharAndAttr(lastPos, (char) upper, colorAttr, false);
2917
2893 if (gui) { 2918 if (gui) {
2894 // screen[lastPos].setUseGUI(UPPER); 2919 // screen[lastPos].setUseGUI(UPPER);
2895 planes.setUseGUI(lastPos,UPPER); 2920 planes.setUseGUI(lastPos, UPPER);
2896 } 2921 }
2922
2897 setDirty(lastPos); 2923 setDirty(lastPos);
2898 advancePos(); 2924 advancePos();
2899 } 2925 }
2900 2926
2901 // set upper right 2927 // set upper right
2902 // screen[lastPos].setCharAndAttr((char) ur, colorAttr, false); 2928 // screen[lastPos].setCharAndAttr((char) ur, colorAttr, false);
2903 planes.setScreenCharAndAttr(lastPos,(char) ur, colorAttr, false); 2929 planes.setScreenCharAndAttr(lastPos, (char) ur, colorAttr, false);
2904 2930
2905 if (gui) { 2931 if (gui) {
2906 // screen[lastPos].setUseGUI(UPPER_RIGHT); 2932 // screen[lastPos].setUseGUI(UPPER_RIGHT);
2907 planes.setUseGUI(lastPos, UPPER_RIGHT); 2933 planes.setUseGUI(lastPos, UPPER_RIGHT);
2908 } 2934 }
2935
2909 setDirty(lastPos); 2936 setDirty(lastPos);
2910 advancePos(); 2937 advancePos();
2911
2912 // set ending attribute byte 2938 // set ending attribute byte
2913 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); 2939 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true);
2914
2915 setDirty(lastPos); 2940 setDirty(lastPos);
2916
2917 lastPos = ((getRow(lastPos) + 1) * numCols) + c; 2941 lastPos = ((getRow(lastPos) + 1) * numCols) + c;
2918 2942
2919 // now handle body of window 2943 // now handle body of window
2920 while (depth-- > 0) { 2944 while (depth-- > 0) {
2921
2922 // set leading attribute byte 2945 // set leading attribute byte
2923 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); 2946 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true);
2924 setDirty(lastPos); 2947 setDirty(lastPos);
2925 advancePos(); 2948 advancePos();
2926
2927 // set left 2949 // set left
2928 planes.setScreenCharAndAttr(lastPos, (char) left, colorAttr, false); 2950 planes.setScreenCharAndAttr(lastPos, (char) left, colorAttr, false);
2929 2951
2930 if (gui) { 2952 if (gui) {
2931 planes.setUseGUI(lastPos,GUI_LEFT); 2953 planes.setUseGUI(lastPos, GUI_LEFT);
2932 } 2954 }
2955
2933 setDirty(lastPos); 2956 setDirty(lastPos);
2934 advancePos(); 2957 advancePos();
2935
2936 w = width; 2958 w = width;
2959
2937 // fill it in 2960 // fill it in
2938 while (w-- >= 0) { 2961 while (w-- >= 0) {
2939 // screen[lastPos].setCharAndAttr(initChar, initAttr, true); 2962 // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
2940 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); 2963 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true);
2941 // screen[lastPos].setUseGUI(NO_GUI); 2964 // screen[lastPos].setUseGUI(NO_GUI);
2942 planes.setUseGUI(lastPos,NO_GUI); 2965 planes.setUseGUI(lastPos, NO_GUI);
2943 setDirty(lastPos); 2966 setDirty(lastPos);
2944 advancePos(); 2967 advancePos();
2945 } 2968 }
2946 2969
2947 // set right 2970 // set right
2948 // screen[lastPos].setCharAndAttr((char) right, colorAttr, false); 2971 // screen[lastPos].setCharAndAttr((char) right, colorAttr, false);
2949 planes.setScreenCharAndAttr(lastPos,(char) right, colorAttr, false); 2972 planes.setScreenCharAndAttr(lastPos, (char) right, colorAttr, false);
2973
2950 if (gui) { 2974 if (gui) {
2951 // screen[lastPos].setUseGUI(RIGHT); 2975 // screen[lastPos].setUseGUI(RIGHT);
2952 planes.setUseGUI(lastPos,GUI_RIGHT); 2976 planes.setUseGUI(lastPos, GUI_RIGHT);
2953 } 2977 }
2954 2978
2955 setDirty(lastPos); 2979 setDirty(lastPos);
2956 advancePos(); 2980 advancePos();
2957
2958 // set ending attribute byte 2981 // set ending attribute byte
2959 // screen[lastPos].setCharAndAttr(initChar, initAttr, true); 2982 // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
2960 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); 2983 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true);
2961 setDirty(lastPos); 2984 setDirty(lastPos);
2962
2963 lastPos = ((getRow(lastPos) + 1) * numCols) + c; 2985 lastPos = ((getRow(lastPos) + 1) * numCols) + c;
2964 } 2986 }
2965 2987
2966 // set leading attribute byte 2988 // set leading attribute byte
2967 // screen[lastPos].setCharAndAttr(initChar, initAttr, true); 2989 // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
2968 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); 2990 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true);
2969 setDirty(lastPos); 2991 setDirty(lastPos);
2970 advancePos(); 2992 advancePos();
2971
2972 // set lower left 2993 // set lower left
2973 // screen[lastPos].setCharAndAttr((char) ll, colorAttr, false); 2994 // screen[lastPos].setCharAndAttr((char) ll, colorAttr, false);
2974 planes.setScreenCharAndAttr(lastPos,(char) ll, colorAttr, false); 2995 planes.setScreenCharAndAttr(lastPos, (char) ll, colorAttr, false);
2996
2975 if (gui) { 2997 if (gui) {
2976 // screen[lastPos].setUseGUI(LOWER_LEFT); 2998 // screen[lastPos].setUseGUI(LOWER_LEFT);
2977 planes.setUseGUI(lastPos,LOWER_LEFT); 2999 planes.setUseGUI(lastPos, LOWER_LEFT);
2978 } 3000 }
3001
2979 setDirty(lastPos); 3002 setDirty(lastPos);
2980 advancePos(); 3003 advancePos();
2981
2982 w = width; 3004 w = width;
2983 3005
2984 // draw bottom row 3006 // draw bottom row
2985 while (w-- >= 0) { 3007 while (w-- >= 0) {
2986 planes.setScreenCharAndAttr(lastPos,(char) bottom, colorAttr, false); 3008 planes.setScreenCharAndAttr(lastPos, (char) bottom, colorAttr, false);
3009
2987 if (gui) { 3010 if (gui) {
2988 planes.setUseGUI(lastPos,BOTTOM); 3011 planes.setUseGUI(lastPos, BOTTOM);
2989 } 3012 }
3013
2990 setDirty(lastPos); 3014 setDirty(lastPos);
2991 advancePos(); 3015 advancePos();
2992 } 3016 }
2993 3017
2994 // set lower right 3018 // set lower right
2995 planes.setScreenCharAndAttr(lastPos, (char) lr, colorAttr, false); 3019 planes.setScreenCharAndAttr(lastPos, (char) lr, colorAttr, false);
3020
2996 if (gui) { 3021 if (gui) {
2997 planes.setUseGUI(lastPos,LOWER_RIGHT); 3022 planes.setUseGUI(lastPos, LOWER_RIGHT);
2998 } 3023 }
2999 3024
3000 setDirty(lastPos); 3025 setDirty(lastPos);
3001 advancePos(); 3026 advancePos();
3002
3003 // set ending attribute byte 3027 // set ending attribute byte
3004 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); 3028 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true);
3005 setDirty(lastPos); 3029 setDirty(lastPos);
3006
3007 } 3030 }
3008 3031
3009 /** 3032 /**
3010 * Creates a scroll bar on the screen using the parameters provided. 3033 * Creates a scroll bar on the screen using the parameters provided.
3011 * ** we only support vertical scroll bars at the time. 3034 * ** we only support vertical scroll bars at the time.
3017 * @param sliderRowPos 3040 * @param sliderRowPos
3018 * @param sliderColPos 3041 * @param sliderColPos
3019 * @param sbSize 3042 * @param sbSize
3020 */ 3043 */
3021 protected void createScrollBar(int flag, int totalRowScrollable, 3044 protected void createScrollBar(int flag, int totalRowScrollable,
3022 int totalColScrollable, int sliderRowPos, int sliderColPos, 3045 int totalColScrollable, int sliderRowPos, int sliderColPos,
3023 int sbSize) { 3046 int sbSize) {
3024
3025 // System.out.println("Scrollbar flag: " + flag + 3047 // System.out.println("Scrollbar flag: " + flag +
3026 // " scrollable Rows: " + totalRowScrollable + 3048 // " scrollable Rows: " + totalRowScrollable +
3027 // " scrollable Cols: " + totalColScrollable + 3049 // " scrollable Cols: " + totalColScrollable +
3028 // " thumb Row: " + sliderRowPos + 3050 // " thumb Row: " + sliderRowPos +
3029 // " thumb Col: " + sliderColPos + 3051 // " thumb Col: " + sliderColPos +
3030 // " size: " + sbSize + 3052 // " size: " + sbSize +
3031 // " row: " + getRow(lastPos) + 3053 // " row: " + getRow(lastPos) +
3032 // " col: " + getCol(lastPos)); 3054 // " col: " + getCol(lastPos));
3033
3034 int sp = lastPos; 3055 int sp = lastPos;
3035 int size = sbSize - 2; 3056 int size = sbSize - 2;
3036 3057 int thumbPos = (int)(size * ((float) sliderColPos / (float) totalColScrollable));
3037 int thumbPos = (int) (size * ((float) sliderColPos / (float) totalColScrollable));
3038 // System.out.println(thumbPos); 3058 // System.out.println(thumbPos);
3039 planes.setScreenCharAndAttr(sp,' ', 32, false); 3059 planes.setScreenCharAndAttr(sp, ' ', 32, false);
3040 planes.setUseGUI(sp,BUTTON_SB_UP); 3060 planes.setUseGUI(sp, BUTTON_SB_UP);
3041
3042 int ctr = 0; 3061 int ctr = 0;
3062
3043 while (ctr < size) { 3063 while (ctr < size) {
3044 sp += numCols; 3064 sp += numCols;
3045 planes.setScreenCharAndAttr(sp,' ', 32, false); 3065 planes.setScreenCharAndAttr(sp, ' ', 32, false);
3066
3046 if (ctr == thumbPos) 3067 if (ctr == thumbPos)
3047 planes.setUseGUI(sp,BUTTON_SB_THUMB); 3068 planes.setUseGUI(sp, BUTTON_SB_THUMB);
3048 else 3069 else
3049 planes.setUseGUI(sp, BUTTON_SB_GUIDE); 3070 planes.setUseGUI(sp, BUTTON_SB_GUIDE);
3071
3050 ctr++; 3072 ctr++;
3051 } 3073 }
3074
3052 sp += numCols; 3075 sp += numCols;
3053
3054
3055 planes.setScreenCharAndAttr(sp, ' ', 32, false); 3076 planes.setScreenCharAndAttr(sp, ' ', 32, false);
3056 planes.setUseGUI(sp, BUTTON_SB_DN); 3077 planes.setUseGUI(sp, BUTTON_SB_DN);
3057 } 3078 }
3058 3079
3059 /** 3080 /**
3066 * @param monoAttr 3087 * @param monoAttr
3067 * @param colorAttr 3088 * @param colorAttr
3068 * @param title 3089 * @param title
3069 */ 3090 */
3070 protected void writeWindowTitle(int pos, int depth, int width, 3091 protected void writeWindowTitle(int pos, int depth, int width,
3071 byte orientation, int monoAttr, int colorAttr, StringBuffer title) { 3092 byte orientation, int monoAttr, int colorAttr, StringBuffer title) {
3072
3073 int len = title.length(); 3093 int len = title.length();
3074 3094
3075 // get bit 0 and 1 for interrogation 3095 // get bit 0 and 1 for interrogation
3076 switch (orientation & 0xc0) { 3096 switch (orientation & 0xc0) {
3077 case 0x40: // right 3097 case 0x40: // right
3078 pos += (4 + width - len); 3098 pos += (4 + width - len);
3079 break; 3099 break;
3080 case 0x80: // left 3100
3081 pos += 2; 3101 case 0x80: // left
3082 break; 3102 pos += 2;
3083 default: // center 3103 break;
3084 // this is to place the position to the first text position of the 3104
3085 // window 3105 default: // center
3086 // the position passed in is the first attribute position, the next 3106 // this is to place the position to the first text position of the
3087 // is the border character and then there is another attribute after 3107 // window
3088 // that. 3108 // the position passed in is the first attribute position, the next
3089 pos += (3 + ((width / 2) - (len / 2))); 3109 // is the border character and then there is another attribute after
3090 break; 3110 // that.
3091 3111 pos += (3 + ((width / 2) - (len / 2)));
3112 break;
3092 } 3113 }
3093 3114
3094 // if bit 2 is on then this is a footer 3115 // if bit 2 is on then this is a footer
3095 if ((orientation & 0x20) == 0x20) 3116 if ((orientation & 0x20) == 0x20)
3096 pos += ((depth + 1) * numCols); 3117 pos += ((depth + 1) * numCols);
3099 // + "," + getCol(pos) + "," + ((orientation >> 6) & 0xf0)); 3120 // + "," + getCol(pos) + "," + ((orientation >> 6) & 0xf0));
3100 3121
3101 for (int x = 0; x < len; x++) { 3122 for (int x = 0; x < len; x++) {
3102 planes.setChar(pos, title.charAt(x)); 3123 planes.setChar(pos, title.charAt(x));
3103 planes.setUseGUI(pos++, NO_GUI); 3124 planes.setUseGUI(pos++, NO_GUI);
3104
3105 } 3125 }
3106 } 3126 }
3107 3127
3108 /** 3128 /**
3109 * Roll the screen up or down. 3129 * Roll the screen up or down.
3117 * @param direction 3137 * @param direction
3118 * @param topLine 3138 * @param topLine
3119 * @param bottomLine 3139 * @param bottomLine
3120 */ 3140 */
3121 protected void rollScreen(int direction, int topLine, int bottomLine) { 3141 protected void rollScreen(int direction, int topLine, int bottomLine) {
3122
3123 // get the number of lines which are the last 5 bits 3142 // get the number of lines which are the last 5 bits
3124 /* int lines = direction & 0x7F; */ 3143 /* int lines = direction & 0x7F; */
3125 // get the direction of the roll which is the first bit 3144 // get the direction of the roll which is the first bit
3126 // 0 - up 3145 // 0 - up
3127 // 1 - down 3146 // 1 - down
3128 int updown = direction & 0x80; 3147 int updown = direction & 0x80;
3129 final int lines = direction & 0x7F; 3148 final int lines = direction & 0x7F;
3130
3131 // calculate the reference points for the move. 3149 // calculate the reference points for the move.
3132 int start = this.getPos(topLine - 1, 0); 3150 int start = this.getPos(topLine - 1, 0);
3133 int end = this.getPos(bottomLine - 1, numCols - 1); 3151 int end = this.getPos(bottomLine - 1, numCols - 1);
3134 int len = end - start; 3152 int len = end - start;
3135 3153
3136 // System.out.println(" starting roll"); 3154 // System.out.println(" starting roll");
3137 // dumpScreen(); 3155 // dumpScreen();
3138 switch (updown) { 3156 switch (updown) {
3139 case 0: 3157 case 0:
3140 // Now round em up and head em UP. 3158
3141 for (int x = start; x < end + numCols; x++) { 3159 // Now round em up and head em UP.
3142 if (x + lines * numCols >= lenScreen) { 3160 for (int x = start; x < end + numCols; x++) {
3143 //Clear at the end 3161 if (x + lines * numCols >= lenScreen) {
3144 planes.setChar(x, ' '); 3162 //Clear at the end
3145 } else { 3163 planes.setChar(x, ' ');
3146 planes.setChar(x, planes.getChar(x + lines * numCols )); 3164 }
3147 } 3165 else {
3148 } 3166 planes.setChar(x, planes.getChar(x + lines * numCols));
3149 break; 3167 }
3150 case 1: 3168 }
3151 // Now round em up and head em DOWN. 3169
3152 for (int x = end + numCols; x > 0; x--) { 3170 break;
3153 if ((x - lines * numCols ) < 0 ) { 3171
3154 //Do nothing ... tooo small!!! 3172 case 1:
3155 } else { 3173
3156 planes.setChar(x - lines * numCols, planes.getChar(x)); 3174 // Now round em up and head em DOWN.
3157 //and clear 3175 for (int x = end + numCols; x > 0; x--) {
3158 planes.setChar(x, ' '); 3176 if ((x - lines * numCols) < 0) {
3159 } 3177 //Do nothing ... tooo small!!!
3160 } 3178 }
3161 break; 3179 else {
3162 default: 3180 planes.setChar(x - lines * numCols, planes.getChar(x));
3163 Log.w(TAG," Invalid roll parameter - please report this"); 3181 //and clear
3164 } 3182 planes.setChar(x, ' ');
3183 }
3184 }
3185
3186 break;
3187
3188 default:
3189 Log.w(TAG, " Invalid roll parameter - please report this");
3190 }
3191
3165 // System.out.println(" end roll"); 3192 // System.out.println(" end roll");
3166 // dumpScreen(); 3193 // dumpScreen();
3167
3168 } 3194 }
3169 3195
3170 public void dumpScreen() { 3196 public void dumpScreen() {
3171
3172 StringBuffer sb = new StringBuffer(); 3197 StringBuffer sb = new StringBuffer();
3173 char[] s = getScreenAsChars(); 3198 char[] s = getScreenAsChars();
3174 int c = getColumns(); 3199 int c = getColumns();
3175 int l = getRows() * c; 3200 int l = getRows() * c;
3176 int col = 0; 3201 int col = 0;
3202
3177 for (int x = 0; x < l; x++, col++) { 3203 for (int x = 0; x < l; x++, col++) {
3178 sb.append(s[x]); 3204 sb.append(s[x]);
3205
3179 if (col == c) { 3206 if (col == c) {
3180 sb.append('\n'); 3207 sb.append('\n');
3181 col = 0; 3208 col = 0;
3182 } 3209 }
3183 } 3210 }
3184 Log.i(TAG,sb.toString()); 3211
3185 3212 Log.i(TAG, sb.toString());
3186 } 3213 }
3187 3214
3188 /** 3215 /**
3189 * Add a field to the field format table. 3216 * Add a field to the field format table.
3190 * 3217 *
3194 * @param ffw2 - Field format word 2 3221 * @param ffw2 - Field format word 2
3195 * @param fcw1 - Field control word 1 3222 * @param fcw1 - Field control word 1
3196 * @param fcw2 - Field control word 2 3223 * @param fcw2 - Field control word 2
3197 */ 3224 */
3198 protected void addField(int attr, int len, int ffw1, int ffw2, int fcw1, 3225 protected void addField(int attr, int len, int ffw1, int ffw2, int fcw1,
3199 int fcw2) { 3226 int fcw2) {
3200
3201 lastAttr = attr; 3227 lastAttr = attr;
3202
3203 planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true); 3228 planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true);
3204
3205 setDirty(lastPos); 3229 setDirty(lastPos);
3206
3207 advancePos(); 3230 advancePos();
3208
3209 ScreenField sf = null; 3231 ScreenField sf = null;
3210 3232
3211 // from 14.6.12 for Start of Field Order 5940 function manual 3233 // from 14.6.12 for Start of Field Order 5940 function manual
3212 // examine the format table for an entry that begins at the current 3234 // examine the format table for an entry that begins at the current
3213 // starting address plus 1. 3235 // starting address plus 1.
3214 if (screenFields.existsAtPos(lastPos)) { 3236 if (screenFields.existsAtPos(lastPos)) {
3215 screenFields.setCurrentFieldFFWs(ffw1, ffw2); 3237 screenFields.setCurrentFieldFFWs(ffw1, ffw2);
3216 } else { 3238 }
3239 else {
3217 sf = screenFields.setField(attr, getRow(lastPos), getCol(lastPos), 3240 sf = screenFields.setField(attr, getRow(lastPos), getCol(lastPos),
3218 len, ffw1, ffw2, fcw1, fcw2); 3241 len, ffw1, ffw2, fcw1, fcw2);
3219 lastPos = sf.startPos(); 3242 lastPos = sf.startPos();
3220 int x = len; 3243 int x = len;
3221
3222 boolean gui = guiInterface; 3244 boolean gui = guiInterface;
3245
3223 if (sf.isBypassField()) 3246 if (sf.isBypassField())
3224 gui = false; 3247 gui = false;
3225 3248
3226 while (x-- > 0) { 3249 while (x-- > 0) {
3227
3228 if (planes.getChar(lastPos) == 0) 3250 if (planes.getChar(lastPos) == 0)
3229 planes.setScreenCharAndAttr(lastPos, ' ', lastAttr, false); 3251 planes.setScreenCharAndAttr(lastPos, ' ', lastAttr, false);
3230 else 3252 else
3231 planes.setScreenAttr(lastPos,lastAttr); 3253 planes.setScreenAttr(lastPos, lastAttr);
3232 3254
3233 if (gui) { 3255 if (gui) {
3234 planes.setUseGUI(lastPos,FIELD_MIDDLE); 3256 planes.setUseGUI(lastPos, FIELD_MIDDLE);
3235 } 3257 }
3236 3258
3237 // now we set the field plane attributes 3259 // now we set the field plane attributes
3238 planes.setScreenFieldAttr(lastPos,ffw1); 3260 planes.setScreenFieldAttr(lastPos, ffw1);
3239
3240 advancePos(); 3261 advancePos();
3241
3242 } 3262 }
3243 3263
3244 if (gui) 3264 if (gui)
3245 if (len > 1) { 3265 if (len > 1) {
3246 planes.setUseGUI(sf.startPos(), FIELD_LEFT); 3266 planes.setUseGUI(sf.startPos(), FIELD_LEFT);
3247 3267
3248 if (lastPos > 0) 3268 if (lastPos > 0)
3249 planes.setUseGUI(lastPos - 1, FIELD_RIGHT); 3269 planes.setUseGUI(lastPos - 1, FIELD_RIGHT);
3250 else 3270 else
3251 planes.setUseGUI(lastPos,FIELD_RIGHT); 3271 planes.setUseGUI(lastPos, FIELD_RIGHT);
3252
3253 } 3272 }
3254 else { 3273 else {
3255 planes.setUseGUI(lastPos - 1,FIELD_ONE); 3274 planes.setUseGUI(lastPos - 1, FIELD_ONE);
3256 } 3275 }
3257 3276
3258 // screen[lastPos].setCharAndAttr(initChar,initAttr,true); 3277 // screen[lastPos].setCharAndAttr(initChar,initAttr,true);
3259 setEndingAttr(initAttr); 3278 setEndingAttr(initAttr);
3260
3261 lastPos = sf.startPos(); 3279 lastPos = sf.startPos();
3262 } 3280 }
3263 3281
3264 // if (fcw1 != 0 || fcw2 != 0) { 3282 // if (fcw1 != 0 || fcw2 != 0) {
3265
3266 // System.out.println("lr = " + lastRow + " lc = " + lastCol + " " + 3283 // System.out.println("lr = " + lastRow + " lc = " + lastCol + " " +
3267 // sf.toString()); 3284 // sf.toString());
3268 // } 3285 // }
3269 sf = null; 3286 sf = null;
3270
3271 } 3287 }
3272 3288
3273 3289
3274 // public void addChoiceField(int attr, int len, int ffw1, int ffw2, int 3290 // public void addChoiceField(int attr, int len, int ffw1, int ffw2, int
3275 // fcw1, int fcw2) { 3291 // fcw1, int fcw2) {
3363 * Redraw the fields on the screen. Used for gui enhancement to redraw the 3379 * Redraw the fields on the screen. Used for gui enhancement to redraw the
3364 * fields when toggling 3380 * fields when toggling
3365 * 3381 *
3366 */ 3382 */
3367 protected void drawFields() { 3383 protected void drawFields() {
3368
3369 ScreenField sf; 3384 ScreenField sf;
3370
3371 int sizeFields = screenFields.getSize(); 3385 int sizeFields = screenFields.getSize();
3386
3372 for (int x = 0; x < sizeFields; x++) { 3387 for (int x = 0; x < sizeFields; x++) {
3373
3374 sf = screenFields.getField(x); 3388 sf = screenFields.getField(x);
3375 3389
3376 if (!sf.isBypassField()) { 3390 if (!sf.isBypassField()) {
3377 int pos = sf.startPos(); 3391 int pos = sf.startPos();
3378
3379 int l = sf.length; 3392 int l = sf.length;
3380
3381 boolean f = true; 3393 boolean f = true;
3382 3394
3383 if (l >= lenScreen) 3395 if (l >= lenScreen)
3384 l = lenScreen - 1; 3396 l = lenScreen - 1;
3385 3397
3386 if (l > 1) { 3398 if (l > 1) {
3387 while (l-- > 0) { 3399 while (l-- > 0) {
3388
3389 if (guiInterface && f) { 3400 if (guiInterface && f) {
3390 planes.setUseGUI(pos,FIELD_LEFT); 3401 planes.setUseGUI(pos, FIELD_LEFT);
3391 f = false; 3402 f = false;
3392 } else {
3393
3394 planes.setUseGUI(pos,FIELD_MIDDLE);
3395
3396 } 3403 }
3404 else {
3405 planes.setUseGUI(pos, FIELD_MIDDLE);
3406 }
3397 3407
3398 if (guiInterface && l == 0) { 3408 if (guiInterface && l == 0) {
3399 planes.setUseGUI(pos,FIELD_RIGHT); 3409 planes.setUseGUI(pos, FIELD_RIGHT);
3400 } 3410 }
3401 3411
3402 setDirty(pos++); 3412 setDirty(pos++);
3403 } 3413 }
3404 } else { 3414 }
3405 planes.setUseGUI(pos,FIELD_ONE); 3415 else {
3416 planes.setUseGUI(pos, FIELD_ONE);
3406 } 3417 }
3407 } 3418 }
3408 } 3419 }
3409 3420
3410 //updateDirty(); 3421 //updateDirty();
3417 * @param sf - 3428 * @param sf -
3418 * Field to be redrawn 3429 * Field to be redrawn
3419 * @see org.tn5250j.ScreenField.java 3430 * @see org.tn5250j.ScreenField.java
3420 */ 3431 */
3421 protected void drawField(ScreenField sf) { 3432 protected void drawField(ScreenField sf) {
3422
3423 int pos = sf.startPos(); 3433 int pos = sf.startPos();
3424
3425 int x = sf.length; 3434 int x = sf.length;
3426 3435
3427 while (x-- > 0) { 3436 while (x-- > 0) {
3428 setDirty(pos++); 3437 setDirty(pos++);
3429 } 3438 }
3430 3439
3431 updateDirty(); 3440 updateDirty();
3432
3433 } 3441 }
3434 3442
3435 /** 3443 /**
3436 * Set the field to be displayed as highlighted. 3444 * Set the field to be displayed as highlighted.
3437 * 3445 *
3438 * @param sf - 3446 * @param sf -
3439 * Field to be highlighted 3447 * Field to be highlighted
3440 */ 3448 */
3441 protected void setFieldHighlighted(ScreenField sf) { 3449 protected void setFieldHighlighted(ScreenField sf) {
3442
3443 int pos = sf.startPos(); 3450 int pos = sf.startPos();
3444
3445 int x = sf.length; 3451 int x = sf.length;
3446 int na = sf.getHighlightedAttr(); 3452 int na = sf.getHighlightedAttr();
3447 3453
3448 while (x-- > 0) { 3454 while (x-- > 0) {
3449 planes.setScreenAttr(pos,na); 3455 planes.setScreenAttr(pos, na);
3450 setDirty(pos++); 3456 setDirty(pos++);
3451 } 3457 }
3458
3452 fireScreenChanged(); 3459 fireScreenChanged();
3453
3454 } 3460 }
3455 3461
3456 /** 3462 /**
3457 * Draw the field as un higlighted. This is used to reset the field 3463 * Draw the field as un higlighted. This is used to reset the field
3458 * presentation on the screen after the field is exited. 3464 * presentation on the screen after the field is exited.
3459 * 3465 *
3460 * @param sf - 3466 * @param sf -
3461 * Field to be unhighlighted 3467 * Field to be unhighlighted
3462 */ 3468 */
3463 protected void unsetFieldHighlighted(ScreenField sf) { 3469 protected void unsetFieldHighlighted(ScreenField sf) {
3464
3465 int pos = sf.startPos(); 3470 int pos = sf.startPos();
3466
3467 int x = sf.length; 3471 int x = sf.length;
3468 int na = sf.getAttr(); 3472 int na = sf.getAttr();
3469 3473
3470 while (x-- > 0) { 3474 while (x-- > 0) {
3471 planes.setScreenAttr(pos,na); 3475 planes.setScreenAttr(pos, na);
3472 setDirty(pos++); 3476 setDirty(pos++);
3473 } 3477 }
3478
3474 fireScreenChanged(); 3479 fireScreenChanged();
3475
3476 } 3480 }
3477 3481
3478 protected void setChar(int cByte) { 3482 protected void setChar(int cByte) {
3479 if (lastPos > 0) { 3483 if (lastPos > 0) {
3480 lastAttr = planes.getCharAttr(lastPos - 1); 3484 lastAttr = planes.getCharAttr(lastPos - 1);
3481 } 3485 }
3486
3482 if (cByte > 0 && (char)cByte < ' ') { 3487 if (cByte > 0 && (char)cByte < ' ') {
3483 planes.setScreenCharAndAttr(lastPos, (char) 0x00, 33, false); 3488 planes.setScreenCharAndAttr(lastPos, (char) 0x00, 33, false);
3484 setDirty(lastPos); 3489 setDirty(lastPos);
3485 advancePos(); 3490 advancePos();
3486 } else { 3491 }
3492 else {
3487 planes.setScreenCharAndAttr(lastPos, (char) cByte, lastAttr, false); 3493 planes.setScreenCharAndAttr(lastPos, (char) cByte, lastAttr, false);
3488 setDirty(lastPos); 3494 setDirty(lastPos);
3495
3489 if (guiInterface && !isInField(lastPos, false)) { 3496 if (guiInterface && !isInField(lastPos, false)) {
3490 planes.setUseGUI(lastPos, NO_GUI); 3497 planes.setUseGUI(lastPos, NO_GUI);
3491 } 3498 }
3499
3492 advancePos(); 3500 advancePos();
3493 } 3501 }
3494 } 3502 }
3495 3503
3496 protected void setEndingAttr(int cByte) { 3504 protected void setEndingAttr(int cByte) {
3499 lastAttr = attr; 3507 lastAttr = attr;
3500 } 3508 }
3501 3509
3502 protected void setAttr(int cByte) { 3510 protected void setAttr(int cByte) {
3503 lastAttr = cByte; 3511 lastAttr = cByte;
3504
3505 // int sattr = screen[lastPos].getCharAttr(); 3512 // int sattr = screen[lastPos].getCharAttr();
3506 // System.out.println("changing from " + sattr + " to attr " + lastAttr 3513 // System.out.println("changing from " + sattr + " to attr " + lastAttr
3507 // + 3514 // +
3508 // " at " + (this.getRow(lastPos) + 1) + "," + (this.getCol(lastPos) + 3515 // " at " + (this.getRow(lastPos) + 1) + "," + (this.getCol(lastPos) +
3509 // 1)); 3516 // 1));
3510 planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true); 3517 planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true);
3511 setDirty(lastPos); 3518 setDirty(lastPos);
3512
3513 advancePos(); 3519 advancePos();
3514 int pos = lastPos; 3520 int pos = lastPos;
3515
3516 int times = 0; 3521 int times = 0;
3517 // sattr = screen[lastPos].getCharAttr(); 3522 // sattr = screen[lastPos].getCharAttr();
3518 // System.out.println(" next position after change " + sattr + " last 3523 // System.out.println(" next position after change " + sattr + " last
3519 // attr " + lastAttr + 3524 // attr " + lastAttr +
3520 // " at " + (this.getRow(lastPos) + 1) + "," + (this.getCol(lastPos) + 3525 // " at " + (this.getRow(lastPos) + 1) + "," + (this.getCol(lastPos) +
3521 // 1) + 3526 // 1) +
3522 // " attr place " + screen[lastPos].isAttributePlace()); 3527 // " attr place " + screen[lastPos].isAttributePlace());
3523 3528
3524 while (planes.getCharAttr(lastPos) != lastAttr 3529 while (planes.getCharAttr(lastPos) != lastAttr
3525 && !planes.isAttributePlace(lastPos)) { 3530 && !planes.isAttributePlace(lastPos)) {
3526
3527 planes.setScreenAttr(lastPos, lastAttr); 3531 planes.setScreenAttr(lastPos, lastAttr);
3532
3528 if (guiInterface && !isInField(lastPos, false)) { 3533 if (guiInterface && !isInField(lastPos, false)) {
3529 int g = planes.getWhichGUI(lastPos); 3534 int g = planes.getWhichGUI(lastPos);
3535
3530 if (g >= FIELD_LEFT && g <= FIELD_ONE) 3536 if (g >= FIELD_LEFT && g <= FIELD_ONE)
3531 planes.setUseGUI(lastPos,NO_GUI); 3537 planes.setUseGUI(lastPos, NO_GUI);
3532 } 3538 }
3539
3533 setDirty(lastPos); 3540 setDirty(lastPos);
3534
3535 times++; 3541 times++;
3536 advancePos(); 3542 advancePos();
3537 } 3543 }
3538 3544
3539 // sanity check for right now 3545 // sanity check for right now
3540 // if (times > 200) 3546 // if (times > 200)
3541 // System.out.println(" setAttr = " + times + " start = " + (sr + 1) + 3547 // System.out.println(" setAttr = " + times + " start = " + (sr + 1) +
3542 // "," + (sc + 1)); 3548 // "," + (sc + 1));
3543
3544 lastPos = pos; 3549 lastPos = pos;
3545 } 3550 }
3546 3551
3547 protected void setScreenCharAndAttr(char right, int colorAttr, boolean isAttr) { 3552 protected void setScreenCharAndAttr(char right, int colorAttr, boolean isAttr) {
3548 3553 planes.setScreenCharAndAttr(lastPos, right, colorAttr, isAttr);
3549 planes.setScreenCharAndAttr(lastPos,right, colorAttr, isAttr);
3550 setDirty(lastPos); 3554 setDirty(lastPos);
3551 advancePos(); 3555 advancePos();
3552
3553 } 3556 }
3554 3557
3555 protected void setScreenCharAndAttr(char right, int colorAttr, 3558 protected void setScreenCharAndAttr(char right, int colorAttr,
3556 int whichGui, boolean isAttr) { 3559 int whichGui, boolean isAttr) {
3557 3560 planes.setScreenCharAndAttr(lastPos, right, colorAttr, isAttr);
3558 planes.setScreenCharAndAttr(lastPos,right, colorAttr, isAttr); 3561 planes.setUseGUI(lastPos, whichGui);
3559 planes.setUseGUI(lastPos,whichGui);
3560
3561 setDirty(lastPos); 3562 setDirty(lastPos);
3562 advancePos(); 3563 advancePos();
3563
3564 } 3564 }
3565 3565
3566 /** 3566 /**
3567 * Draw or redraw the dirty parts of the screen and display them. 3567 * Draw or redraw the dirty parts of the screen and display them.
3568 * 3568 *
3574 protected void updateDirty() { 3574 protected void updateDirty() {
3575 fireScreenChanged(); 3575 fireScreenChanged();
3576 } 3576 }
3577 3577
3578 protected void setDirty(int pos) { 3578 protected void setDirty(int pos) {
3579 3579 int minr = Math.min(getRow(pos), getRow(dirtyScreen.x));
3580 int minr = Math.min(getRow(pos),getRow(dirtyScreen.x)); 3580 int minc = Math.min(getCol(pos), getCol(dirtyScreen.x));
3581 int minc = Math.min(getCol(pos),getCol(dirtyScreen.x)); 3581 int maxr = Math.max(getRow(pos), getRow(dirtyScreen.y));
3582 3582 int maxc = Math.max(getCol(pos), getCol(dirtyScreen.y));
3583 int maxr = Math.max(getRow(pos),getRow(dirtyScreen.y)); 3583 int x1 = getPos(minr, minc);
3584 int maxc = Math.max(getCol(pos),getCol(dirtyScreen.y)); 3584 int x2 = getPos(maxr, maxc);
3585 3585 dirtyScreen.setBounds(x1, x2, 0, 0);
3586 int x1 = getPos(minr,minc);
3587 int x2 = getPos(maxr,maxc);
3588
3589 dirtyScreen.setBounds(x1,x2,0,0);
3590
3591 } 3586 }
3592 3587
3593 private void resetDirty(int pos) { 3588 private void resetDirty(int pos) {
3594 3589 dirtyScreen.setBounds(pos, pos, 0, 0);
3595 dirtyScreen.setBounds(pos,pos,0,0);
3596
3597 } 3590 }
3598 3591
3599 /** 3592 /**
3600 * Change the screen position by one column 3593 * Change the screen position by one column
3601 */ 3594 */
3613 * cursor is moved to first position of the screen. 3606 * cursor is moved to first position of the screen.
3614 * 3607 *
3615 * @param i 3608 * @param i
3616 */ 3609 */
3617 protected void changePos(int i) { 3610 protected void changePos(int i) {
3618
3619 lastPos += i; 3611 lastPos += i;
3612
3620 if (lastPos < 0) 3613 if (lastPos < 0)
3621 lastPos = lenScreen + lastPos; 3614 lastPos = lenScreen + lastPos;
3615
3622 if (lastPos > lenScreen - 1) 3616 if (lastPos > lenScreen - 1)
3623 lastPos = lastPos - lenScreen; 3617 lastPos = lastPos - lenScreen;
3624 3618
3625 // System.out.println(lastRow + "," + ((lastPos) / numCols) + "," + 3619 // System.out.println(lastRow + "," + ((lastPos) / numCols) + "," +
3626 // lastCol + "," + ((lastPos) % numCols) + "," + 3620 // lastCol + "," + ((lastPos) % numCols) + "," +
3627 // ((lastRow * numCols) + lastCol) + "," + 3621 // ((lastRow * numCols) + lastCol) + "," +
3628 // (lastPos)); 3622 // (lastPos));
3629
3630 } 3623 }
3631 3624
3632 protected void goHome() { 3625 protected void goHome() {
3633
3634 // now we try to move to first input field according to 3626 // now we try to move to first input field according to
3635 // 14.6 WRITE TO DISPLAY Command 3627 // 14.6 WRITE TO DISPLAY Command
3636 // ? If the WTD command is valid, after the command is processed, 3628 // ? If the WTD command is valid, after the command is processed,
3637 // the cursor moves to one of three locations: 3629 // the cursor moves to one of three locations:
3638 // - The location set by an insert cursor order (unless control 3630 // - The location set by an insert cursor order (unless control
3639 // character byte 1, bit 1 is equal to B'1'.) 3631 // character byte 1, bit 1 is equal to B'1'.)
3640 // - The start of the first non-bypass input field defined in the 3632 // - The start of the first non-bypass input field defined in the
3641 // format table 3633 // format table
3642 // - A default starting address of row 1 column 1. 3634 // - A default starting address of row 1 column 1.
3643
3644 if (pendingInsert && homePos > 0) { 3635 if (pendingInsert && homePos > 0) {
3645 setCursor(getRow(homePos), getCol(homePos)); 3636 setCursor(getRow(homePos), getCol(homePos));
3646 isInField(); // we now check if we are in a field 3637 isInField(); // we now check if we are in a field
3647 } else { 3638 }
3639 else {
3648 if (!gotoField(1)) { 3640 if (!gotoField(1)) {
3649 homePos = getPos(1, 1); 3641 homePos = getPos(1, 1);
3650 setCursor(1, 1); 3642 setCursor(1, 1);
3651 isInField(0, 0); // we now check if we are in a field 3643 isInField(0, 0); // we now check if we are in a field
3652 } else { 3644 }
3645 else {
3653 homePos = getPos(getCurrentRow(), getCurrentCol()); 3646 homePos = getPos(getCurrentRow(), getCurrentCol());
3654 } 3647 }
3655 } 3648 }
3656 } 3649 }
3657 3650
3658 protected void setPendingInsert(boolean flag, int icX, int icY) { 3651 protected void setPendingInsert(boolean flag, int icX, int icY) {
3659 pendingInsert = flag; 3652 pendingInsert = flag;
3653
3660 if (pendingInsert) { 3654 if (pendingInsert) {
3661 homePos = getPos(icX, icY); 3655 homePos = getPos(icX, icY);
3662 } 3656 }
3663 3657
3664 if (!isStatusErrorCode()) { 3658 if (!isStatusErrorCode()) {
3675 * Set the error line number to that of number passed. 3669 * Set the error line number to that of number passed.
3676 * 3670 *
3677 * @param line 3671 * @param line
3678 */ 3672 */
3679 protected void setErrorLine(int line) { 3673 protected void setErrorLine(int line) {
3680
3681 planes.setErrorLine(line); 3674 planes.setErrorLine(line);
3682 } 3675 }
3683 3676
3684 /** 3677 /**
3685 * Returns the current error line number 3678 * Returns the current error line number
3702 * Restores the error line characters from the save buffer. 3695 * Restores the error line characters from the save buffer.
3703 * 3696 *
3704 * @see #saveErrorLine() 3697 * @see #saveErrorLine()
3705 */ 3698 */
3706 protected void restoreErrorLine() { 3699 protected void restoreErrorLine() {
3707
3708 if (planes.isErrorLineSaved()) { 3700 if (planes.isErrorLineSaved()) {
3709 planes.restoreErrorLine(); 3701 planes.restoreErrorLine();
3710 fireScreenChanged(planes.getErrorLine()-1,0,planes.getErrorLine()-1,numCols - 1); 3702 fireScreenChanged(planes.getErrorLine() - 1, 0, planes.getErrorLine() - 1, numCols - 1);
3711 } 3703 }
3712 } 3704 }
3713 3705
3714 protected void setStatus(byte attr, byte value, String s) { 3706 protected void setStatus(byte attr, byte value, String s) {
3715
3716 // set the status area 3707 // set the status area
3717 switch (attr) { 3708 switch (attr) {
3718 3709 case STATUS_SYSTEM:
3719 case STATUS_SYSTEM: 3710 if (value == STATUS_VALUE_ON) {
3720 if (value == STATUS_VALUE_ON) { 3711 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, s);
3721 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, s); 3712 }
3722 } 3713 else {
3723 else { 3714 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED, ScreenOIA.OIA_LEVEL_NOT_INHIBITED, s);
3724 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED,ScreenOIA.OIA_LEVEL_NOT_INHIBITED,s); 3715 }
3725 } 3716
3726 break; 3717 break;
3727 3718
3728 case STATUS_ERROR_CODE: 3719 case STATUS_ERROR_CODE:
3729 if (value == STATUS_VALUE_ON) { 3720 if (value == STATUS_VALUE_ON) {
3730 setPrehelpState(true, true, false); 3721 setPrehelpState(true, true, false);
3731 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, 3722 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
3732 ScreenOIA.OIA_LEVEL_INPUT_ERROR,s); 3723 ScreenOIA.OIA_LEVEL_INPUT_ERROR, s);
3733 3724 sessionVT.signalBell();
3734 sessionVT.signalBell(); 3725 }
3735 } else { 3726 else {
3736 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED, 3727 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED,
3737 ScreenOIA.OIA_LEVEL_NOT_INHIBITED); 3728 ScreenOIA.OIA_LEVEL_NOT_INHIBITED);
3738 setPrehelpState(false, true, true); 3729 setPrehelpState(false, true, true);
3739 homePos = saveHomePos; 3730 homePos = saveHomePos;
3740 saveHomePos = 0; 3731 saveHomePos = 0;
3741 pendingInsert = false; 3732 pendingInsert = false;
3742 } 3733 }
3743 break; 3734
3744 3735 break;
3745 } 3736 }
3746 } 3737 }
3747 3738
3748 protected boolean isStatusErrorCode() { 3739 protected boolean isStatusErrorCode() {
3749
3750 return oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_ERROR; 3740 return oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_ERROR;
3751
3752 } 3741 }
3753 3742
3754 /** 3743 /**
3755 * This routine clears the screen, resets row and column to 0, resets the 3744 * This routine clears the screen, resets row and column to 0, resets the
3756 * last attribute to 32, clears the fields, turns insert mode off, 3745 * last attribute to 32, clears the fields, turns insert mode off,
3757 * clears/initializes the screen character array. 3746 * clears/initializes the screen character array.
3758 */ 3747 */
3759 protected void clearAll() { 3748 protected void clearAll() {
3760
3761 lastAttr = 32; 3749 lastAttr = 32;
3762 lastPos = 0; 3750 lastPos = 0;
3763
3764 clearTable(); 3751 clearTable();
3765 clearScreen(); 3752 clearScreen();
3766 planes.setScreenAttr(0, initAttr); 3753 planes.setScreenAttr(0, initAttr);
3767 oia.setInsertMode(false); 3754 oia.setInsertMode(false);
3768 } 3755 }
3769 3756
3770 /** 3757 /**
3771 * Clear the fields table 3758 * Clear the fields table
3772 */ 3759 */
3773 protected void clearTable() { 3760 protected void clearTable() {
3774
3775 oia.setKeyBoardLocked(true); 3761 oia.setKeyBoardLocked(true);
3776 screenFields.clearFFT(); 3762 screenFields.clearFFT();
3777 planes.initalizeFieldPlanes(); 3763 planes.initalizeFieldPlanes();
3778 pendingInsert = false; 3764 pendingInsert = false;
3779 homePos = -1; 3765 homePos = -1;
3782 /** 3768 /**
3783 * Clear the gui constructs 3769 * Clear the gui constructs
3784 * 3770 *
3785 */ 3771 */
3786 protected void clearGuiStuff() { 3772 protected void clearGuiStuff() {
3787
3788 for (int x = 0; x < lenScreen; x++) { 3773 for (int x = 0; x < lenScreen; x++) {
3789 planes.setUseGUI(x,NO_GUI); 3774 planes.setUseGUI(x, NO_GUI);
3790 } 3775 }
3791 dirtyScreen.setBounds(0,lenScreen - 1,0,0); 3776
3777 dirtyScreen.setBounds(0, lenScreen - 1, 0, 0);
3792 } 3778 }
3793 3779
3794 /** 3780 /**
3795 * Clear the screen by setting the initial character and initial attribute 3781 * Clear the screen by setting the initial character and initial attribute
3796 * to all the positions on the screen 3782 * to all the positions on the screen
3797 */ 3783 */
3798 protected void clearScreen() { 3784 protected void clearScreen() {
3799
3800 planes.initalizePlanes(); 3785 planes.initalizePlanes();
3801 3786 dirtyScreen.setBounds(0, lenScreen - 1, 0, 0);
3802 dirtyScreen.setBounds(0,lenScreen - 1,0,0);
3803
3804 oia.clearScreen(); 3787 oia.clearScreen();
3805
3806 } 3788 }
3807 3789
3808 protected void restoreScreen() { 3790 protected void restoreScreen() {
3809
3810 lastAttr = 32; 3791 lastAttr = 32;
3811 dirtyScreen.setBounds(0,lenScreen - 1,0,0); 3792 dirtyScreen.setBounds(0, lenScreen - 1, 0, 0);
3812 updateDirty(); 3793 updateDirty();
3813 } 3794 }
3814 3795
3815 /** 3796 /**
3816 * repaint part of the screen 3797 * repaint part of the screen
3831 0xe, // light cyan 3812 0xe, // light cyan
3832 0x9, // light red 3813 0x9, // light red
3833 0xd, // light magenta/purple 3814 0xd, // light magenta/purple
3834 0x3, // brown 3815 0x3, // brown
3835 0xf // bright white 3816 0xf // bright white
3836 }; 3817 };
3818
3837 for (int r = startRow; r <= endRow; r++) { 3819 for (int r = startRow; r <= endRow; r++) {
3838 for (int c = startCol; c <= endCol; c++) { 3820 for (int c = startCol; c <= endCol; c++) {
3839 int p = getPos(r,c); 3821 int p = getPos(r, c);
3840 char ch = planes.getChar(p); 3822 char ch = planes.getChar(p);
3841 char co = planes.getCharColor(p); 3823 char co = planes.getCharColor(p);
3842 char at = planes.getCharExtended(p); 3824 char at = planes.getCharExtended(p);
3843 boolean ia = planes.isAttributePlace(p); 3825 boolean ia = planes.isAttributePlace(p);
3826
3844 if (ch < ' ') ch = ' '; 3827 if (ch < ' ') ch = ' ';
3828
3845 int bg = vt320color[(co >> 8) & 0x0f] + 1; 3829 int bg = vt320color[(co >> 8) & 0x0f] + 1;
3846 int fg = vt320color[co & 0x0f] + 1; 3830 int fg = vt320color[co & 0x0f] + 1;
3847 int ul = at & EXTENDED_5250_UNDERLINE; 3831 int ul = at & EXTENDED_5250_UNDERLINE;
3848 int nd = at & EXTENDED_5250_NON_DSP; 3832 int nd = at & EXTENDED_5250_NON_DSP;
3849 int vt_attr = (fg << VDUBuffer.COLOR_FG_SHIFT) + (bg << VDUBuffer.COLOR_BG_SHIFT); 3833 int vt_attr = (fg << VDUBuffer.COLOR_FG_SHIFT) + (bg << VDUBuffer.COLOR_BG_SHIFT);
3834
3850 if (ul > 0) vt_attr |= VDUBuffer.UNDERLINE; 3835 if (ul > 0) vt_attr |= VDUBuffer.UNDERLINE;
3836
3851 if (ia || (nd > 0)) vt_attr |= VDUBuffer.INVISIBLE; 3837 if (ia || (nd > 0)) vt_attr |= VDUBuffer.INVISIBLE;
3838
3852 buffer.putChar(c, r, ch, vt_attr); 3839 buffer.putChar(c, r, ch, vt_attr);
3853 } 3840 }
3854 } 3841 }
3842
3855 buffer.redrawPassthru(); 3843 buffer.redrawPassthru();
3856 dirtyScreen.setBounds(lenScreen,0,0,0); 3844 dirtyScreen.setBounds(lenScreen, 0, 0, 0);
3857 } 3845 }
3858 3846
3859 /** 3847 /**
3860 * repaint the dirty part of the screen 3848 * repaint the dirty part of the screen
3861 * 3849 *
3862 */ 3850 */
3851
3863 private synchronized void fireScreenChanged() { 3852 private synchronized void fireScreenChanged() {
3864 if (dirtyScreen.x > dirtyScreen.y) { 3853 if (dirtyScreen.x > dirtyScreen.y) {
3865 Log.i(TAG," x < y " + dirtyScreen); 3854 Log.i(TAG, " x < y " + dirtyScreen);
3866 return; 3855 return;
3867 } 3856 }
3857
3868 fireScreenChanged(getRow(dirtyScreen.x), getCol(dirtyScreen.x), 3858 fireScreenChanged(getRow(dirtyScreen.x), getCol(dirtyScreen.x),
3869 getRow(dirtyScreen.y), getCol(dirtyScreen.y)); 3859 getRow(dirtyScreen.y), getCol(dirtyScreen.y));
3870
3871 } 3860 }
3872 3861
3873 /** 3862 /**
3874 * update the cursor position 3863 * update the cursor position
3875 * 3864 *
3876 */ 3865 */
3866
3877 private synchronized void fireCursorChanged() { 3867 private synchronized void fireCursorChanged() {
3878 int l = getRow(lastPos); 3868 int l = getRow(lastPos);
3879 int c = getCol(lastPos); 3869 int c = getCol(lastPos);
3880 buffer.setCursorPosition(c,l); 3870 buffer.setCursorPosition(c, l);
3881 } 3871 }
3882 3872
3883 /** 3873 /**
3884 * update the screen size. 3874 * update the screen size.
3885 */ 3875 */
3900 * Utility method to share the repaint behaviour between setBounds() and 3890 * Utility method to share the repaint behaviour between setBounds() and
3901 * updateScreen. 3891 * updateScreen.
3902 */ 3892 */
3903 public void repaintScreen() { 3893 public void repaintScreen() {
3904 setCursorOff(); 3894 setCursorOff();
3905 dirtyScreen.setBounds(0,lenScreen - 1,0,0); 3895 dirtyScreen.setBounds(0, lenScreen - 1, 0, 0);
3906 updateDirty(); 3896 updateDirty();
3897
3907 // restore statuses that were on the screen before resize 3898 // restore statuses that were on the screen before resize
3908 if (oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_ERROR) { 3899 if (oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_ERROR) {
3909 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, 3900 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
3910 ScreenOIA.OIA_LEVEL_INPUT_ERROR); 3901 ScreenOIA.OIA_LEVEL_INPUT_ERROR);
3911 } 3902 }
3912 3903
3913 if (oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_INHIBITED) { 3904 if (oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_INHIBITED) {
3914 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, 3905 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
3915 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); 3906 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
3916 } 3907 }
3917 3908
3918 if (oia.isMessageWait()) 3909 if (oia.isMessageWait())
3919 oia.setMessageLightOn(); 3910 oia.setMessageLightOn();
3911
3920 setCursorOn(); 3912 setCursorOn();
3921 } 3913 }
3922 3914
3923 // ADDED BY BARRY - changed by Kenneth to use the character plane 3915 // ADDED BY BARRY - changed by Kenneth to use the character plane
3924 // This should be replaced with the getPlane methods when they are implemented 3916 // This should be replaced with the getPlane methods when they are implemented