3
|
1 /**
|
|
2 * Title: Screen5250.java
|
|
3 * Copyright: Copyright (c) 2001 - 2004
|
|
4 * Company:
|
|
5 * @author Kenneth J. Pouncey
|
|
6 * @version 0.5
|
|
7 *
|
|
8 * Description:
|
|
9 *
|
|
10 * This program is free software; you can redistribute it and/or modify
|
|
11 * it under the terms of the GNU General Public License as published by
|
|
12 * the Free Software Foundation; either version 2, or (at your option)
|
|
13 * any later version.
|
|
14 *
|
|
15 * This program is distributed in the hope that it will be useful,
|
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 * GNU General Public License for more details.
|
|
19 *
|
|
20 * You should have received a copy of the GNU General Public License
|
|
21 * along with this software; see the file COPYING. If not, write to
|
|
22 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
23 * Boston, MA 02111-1307 USA
|
|
24 *
|
|
25 */
|
|
26 package org.tn5250j.framework.tn5250;
|
|
27
|
|
28 import static org.tn5250j.TN5250jConstants.*;
|
|
29
|
|
30 import java.text.DecimalFormat;
|
|
31 import java.text.DecimalFormatSymbols;
|
|
32 import java.text.NumberFormat;
|
|
33 import java.text.ParseException;
|
|
34 import java.util.Vector;
|
|
35
|
|
36 import org.tn5250j.TN5250jConstants;
|
|
37 import org.tn5250j.event.ScreenListener;
|
|
38 import org.tn5250j.tools.logging.TN5250jLogFactory;
|
|
39 import org.tn5250j.tools.logging.TN5250jLogger;
|
|
40
|
|
41 public class Screen5250 {
|
|
42
|
|
43 private ScreenFields screenFields;
|
|
44 private int lastAttr;
|
|
45 private int lastPos;
|
|
46 private int lenScreen;
|
|
47 private KeyStrokenizer strokenizer;
|
|
48 private tnvt sessionVT;
|
|
49 private int numRows = 0;
|
|
50 private int numCols = 0;
|
|
51 protected static final int initAttr = 32;
|
|
52 protected static final char initChar = 0;
|
|
53 public boolean cursorActive = false;
|
|
54 public boolean cursorShown = false;
|
|
55 protected boolean insertMode = false;
|
|
56 private boolean keyProcessed = false;
|
|
57 private Rect dirtyScreen = new Rect();
|
|
58
|
|
59 public int homePos = 0;
|
|
60 public int saveHomePos = 0;
|
|
61 private String bufferedKeys;
|
|
62 public boolean pendingInsert = false;
|
|
63
|
|
64 public final static byte STATUS_SYSTEM = 1;
|
|
65 public final static byte STATUS_ERROR_CODE = 2;
|
|
66 public final static byte STATUS_VALUE_ON = 1;
|
|
67 public final static byte STATUS_VALUE_OFF = 2;
|
|
68
|
|
69 private StringBuffer hsMore = new StringBuffer("More...");
|
|
70 private StringBuffer hsBottom = new StringBuffer("Bottom");
|
|
71
|
|
72 // error codes to be sent to the host on an error
|
|
73 private final static int ERR_CURSOR_PROTECTED = 0x05;
|
|
74 private final static int ERR_INVALID_SIGN = 0x11;
|
|
75 private final static int ERR_NO_ROOM_INSERT = 0x12;
|
|
76 private final static int ERR_NUMERIC_ONLY = 0x09;
|
|
77 private final static int ERR_DUP_KEY_NOT_ALLOWED = 0x19;
|
|
78 private final static int ERR_NUMERIC_09 = 0x10;
|
|
79 private final static int ERR_FIELD_MINUS = 0x16;
|
|
80 private final static int ERR_FIELD_EXIT_INVALID = 0x18;
|
|
81 private final static int ERR_ENTER_NO_ALLOWED = 0x20;
|
|
82 private final static int ERR_MANDITORY_ENTER = 0x21;
|
|
83
|
|
84 private boolean guiInterface = false;
|
|
85 private boolean resetRequired = true;
|
|
86 private boolean backspaceError = true;
|
|
87 private boolean feError;
|
|
88
|
|
89 // vector of listeners for changes to the screen.
|
|
90 Vector<ScreenListener> listeners = null;
|
|
91
|
|
92 // Operator Information Area
|
|
93 private ScreenOIA oia;
|
|
94
|
|
95 // screen planes
|
|
96 protected ScreenPlanes planes;
|
|
97
|
|
98 //Added by Barry
|
|
99 private StringBuffer keybuf;
|
|
100
|
|
101 private TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass());
|
|
102
|
|
103 public Screen5250() {
|
|
104
|
|
105 //Added by Barry
|
|
106 this.keybuf = new StringBuffer();
|
|
107
|
|
108 try {
|
|
109 jbInit();
|
|
110 } catch (Exception ex) {
|
|
111 log.warn("In constructor: ", ex);
|
|
112 }
|
|
113 }
|
|
114
|
|
115 void jbInit() throws Exception {
|
|
116
|
|
117 lastAttr = 32;
|
|
118
|
|
119 // default number of rows and columns
|
|
120 numRows = 24;
|
|
121 numCols = 80;
|
|
122
|
|
123 setCursor(1, 1); // set initial cursor position
|
|
124
|
|
125 oia = new ScreenOIA(this);
|
|
126 oia.setKeyBoardLocked(true);
|
|
127
|
|
128 lenScreen = numRows * numCols;
|
|
129
|
|
130 planes = new ScreenPlanes(this,numRows);
|
|
131
|
|
132 screenFields = new ScreenFields(this);
|
|
133 strokenizer = new KeyStrokenizer();
|
|
134 }
|
|
135
|
|
136 protected ScreenPlanes getPlanes() {
|
|
137 return planes;
|
|
138 }
|
|
139
|
|
140 public final ScreenOIA getOIA() {
|
|
141 return oia;
|
|
142 }
|
|
143
|
|
144 protected final void setRowsCols(int rows, int cols) {
|
|
145
|
|
146 int oldRows = numRows;
|
|
147 int oldCols = numCols;
|
|
148
|
|
149 // default number of rows and columns
|
|
150 numRows = rows;
|
|
151 numCols = cols;
|
|
152
|
|
153 lenScreen = numRows * numCols;
|
|
154
|
|
155 planes.setSize(rows);
|
|
156
|
|
157 // If they are not the same then we need to inform the listeners that
|
|
158 // the size changed.
|
|
159 if (oldRows != numRows || oldCols != numCols)
|
|
160 fireScreenSizeChanged();
|
|
161
|
|
162 }
|
|
163
|
|
164
|
|
165 public boolean isCursorActive() {
|
|
166 return cursorActive;
|
|
167
|
|
168 }
|
|
169
|
|
170 public boolean isCursorShown() {
|
|
171 return cursorShown;
|
|
172 }
|
|
173
|
|
174 public void setUseGUIInterface(boolean gui) {
|
|
175 guiInterface = gui;
|
|
176 }
|
|
177
|
|
178 public void toggleGUIInterface() {
|
|
179 guiInterface = !guiInterface;
|
|
180 }
|
|
181
|
|
182 public void setResetRequired(boolean reset) {
|
|
183 resetRequired = reset;
|
|
184 }
|
|
185
|
|
186 public void setBackspaceError(boolean onError) {
|
|
187 backspaceError = onError;
|
|
188 }
|
|
189
|
|
190 /**
|
|
191 * Copy & Paste support
|
7
|
192 *
|
3
|
193 * @see {@link #pasteText(String, boolean)}
|
|
194 * @see {@link #copyTextField(int)}
|
|
195 */
|
|
196 public final String copyText(Rect area) {
|
|
197 StringBuilder sb = new StringBuilder();
|
|
198 Rect workR = new Rect();
|
|
199 workR.setBounds(area);
|
|
200 log.debug("Copying " + workR);
|
|
201
|
|
202 // loop through all the screen characters to send them to the clip board
|
|
203 int m = workR.x;
|
|
204 int i = 0;
|
|
205 int t = 0;
|
|
206
|
|
207 while (workR.height-- > 0) {
|
|
208 t = workR.width;
|
|
209 i = workR.y;
|
|
210 while (t-- > 0) {
|
|
211 // only copy printable characters (in this case >= ' ')
|
|
212 char c = planes.getChar(getPos(m - 1, i - 1));
|
|
213 if (c >= ' ' && (planes.screenExtended[getPos(m - 1, i - 1)] & EXTENDED_5250_NON_DSP)
|
|
214 == 0)
|
|
215 sb.append(c);
|
|
216 else
|
|
217 sb.append(' ');
|
|
218
|
|
219 i++;
|
|
220 }
|
|
221 sb.append('\n');
|
|
222 m++;
|
|
223 }
|
|
224 return sb.toString();
|
|
225 }
|
|
226
|
|
227 /**
|
|
228 * Copy & Paste support
|
7
|
229 *
|
3
|
230 * @param content
|
|
231 * @see {@link #copyText(Rectangle)}
|
|
232 */
|
|
233 public final void pasteText(String content, boolean special) {
|
|
234 if (log.isDebugEnabled()) {
|
|
235 log.debug("Pasting, special:"+special);
|
|
236 }
|
|
237 setCursorActive(false);
|
|
238
|
|
239 StringBuilder sb = new StringBuilder(content);
|
|
240 StringBuilder pd = new StringBuilder();
|
|
241
|
|
242 // character counters within the string to be pasted.
|
|
243 int nextChar = 0;
|
|
244 int nChars = sb.length();
|
|
245
|
|
246 int lr = getRow(lastPos);
|
|
247 int lc = getCol(lastPos);
|
|
248 resetDirty(lastPos);
|
|
249
|
|
250 int cpos = lastPos;
|
|
251 int length = getScreenLength();
|
|
252
|
|
253 char c = 0;
|
|
254 boolean setIt;
|
|
255
|
|
256 // save our current place within the FFT.
|
|
257 screenFields.saveCurrentField();
|
|
258
|
|
259 for (int x = nextChar; x < nChars; x++) {
|
|
260
|
|
261 c = sb.charAt(x);
|
|
262
|
|
263 if ((c == '\n') || (c == '\r')) {
|
|
264
|
|
265 log.info("pasted cr-lf>" + pd + "<");
|
|
266 pd.setLength(0);
|
|
267 // if we read in a cr lf in the data stream we need to go
|
|
268 // to the starting column of the next row and start from there
|
|
269 cpos = getPos(getRow(cpos)+1,lc);
|
|
270
|
|
271 // If we go paste the end of the screen then let's start over from
|
|
272 // the beginning of the screen space.
|
|
273 if (cpos > length)
|
|
274 cpos = 0;
|
|
275 }
|
|
276 else {
|
|
277
|
|
278 // we will default to set the character always.
|
|
279 setIt = true;
|
|
280
|
|
281 // If we are in a special paste scenario then we check for valid
|
|
282 // characters to paste.
|
|
283 if (special && (!Character.isLetter(c) && !Character.isDigit(c)))
|
|
284 setIt = false;
|
|
285
|
|
286 // we will only push a character to the screen space if we are in
|
|
287 // a field
|
|
288 if (isInField(cpos) && setIt) {
|
|
289 planes.setChar(cpos, c);
|
|
290 setDirty(cpos);
|
|
291 screenFields.setCurrentFieldMDT();
|
|
292 }
|
|
293 // If we placed a character then we go to the next position.
|
|
294 if (setIt)
|
|
295 cpos++;
|
|
296 // we will append the information to our debug buffer.
|
|
297 pd.append(c);
|
|
298 }
|
|
299 }
|
|
300
|
|
301 // if we have anything else not logged then log it out.
|
|
302 if (pd.length() > 0)
|
|
303 log.info("pasted >" + pd + "<");
|
|
304
|
|
305 // restore out position within the FFT.
|
|
306 screenFields.restoreCurrentField();
|
|
307 updateDirty();
|
|
308
|
|
309 // restore our cursor position.
|
|
310 setCursor(lr + 1, lc + 1);
|
|
311
|
|
312 setCursorActive(true);
|
|
313
|
|
314 }
|
|
315
|
|
316 /**
|
|
317 * Copy & Paste support
|
7
|
318 *
|
3
|
319 * @param position
|
|
320 * @return
|
|
321 * @see {@link #copyText(int)}
|
|
322 */
|
|
323 public final String copyTextField(int position) {
|
|
324 screenFields.saveCurrentField();
|
|
325 isInField(position);
|
|
326 String result = screenFields.getCurrentFieldText();
|
|
327 screenFields.restoreCurrentField();
|
|
328 return result;
|
|
329 }
|
|
330
|
|
331 /**
|
|
332 *
|
|
333 * Copy & Paste end code
|
|
334 *
|
|
335 */
|
|
336
|
|
337 /**
|
|
338 * Sum them
|
|
339 *
|
|
340 * @param which
|
|
341 * formatting option to use
|
|
342 * @return vector string of numberic values
|
|
343 */
|
|
344 public final Vector<Double> sumThem(boolean which, Rect area) {
|
|
345
|
|
346 StringBuilder sb = new StringBuilder();
|
|
347 Rect workR = new Rect();
|
|
348 workR.setBounds(area);
|
|
349
|
|
350 // gui.rubberband.reset();
|
|
351 // gui.repaint();
|
|
352
|
|
353 log.debug("Summing");
|
|
354
|
|
355 // obtain the decimal format for parsing
|
|
356 DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
|
|
357
|
|
358 DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
|
|
359
|
|
360 if (which) {
|
|
361 dfs.setDecimalSeparator('.');
|
|
362 dfs.setGroupingSeparator(',');
|
|
363 } else {
|
|
364 dfs.setDecimalSeparator(',');
|
|
365 dfs.setGroupingSeparator('.');
|
|
366 }
|
|
367
|
|
368 df.setDecimalFormatSymbols(dfs);
|
|
369
|
|
370 Vector<Double> sumVector = new Vector<Double>();
|
|
371
|
|
372 // loop through all the screen characters to send them to the clip board
|
|
373 int m = workR.x;
|
|
374 int i = 0;
|
|
375 int t = 0;
|
|
376
|
|
377 double sum = 0.0;
|
|
378
|
|
379 while (workR.height-- > 0) {
|
|
380 t = workR.width;
|
|
381 i = workR.y;
|
|
382 while (t-- > 0) {
|
|
383
|
|
384 // only copy printable numeric characters (in this case >= ' ')
|
|
385 // char c = screen[getPos(m - 1, i - 1)].getChar();
|
|
386 char c = planes.getChar(getPos(m - 1, i - 1));
|
|
387 // if (((c >= '0' && c <= '9') || c == '.' || c == ',' || c == '-')
|
|
388 // && !screen[getPos(m - 1, i - 1)].nonDisplay) {
|
|
389
|
|
390 // TODO: update me here to implement the nonDisplay check as well
|
|
391 if (((c >= '0' && c <= '9') || c == '.' || c == ',' || c == '-')) {
|
|
392 sb.append(c);
|
|
393 }
|
|
394 i++;
|
|
395 }
|
|
396
|
|
397 if (sb.length() > 0) {
|
|
398 if (sb.charAt(sb.length() - 1) == '-') {
|
|
399 sb.insert(0, '-');
|
|
400 sb.deleteCharAt(sb.length() - 1);
|
|
401 }
|
|
402 try {
|
|
403 Number n = df.parse(sb.toString());
|
|
404 // System.out.println(s + " " + n.doubleValue());
|
|
405
|
|
406 sumVector.add(new Double(n.doubleValue()));
|
|
407 sum += n.doubleValue();
|
|
408 } catch (ParseException pe) {
|
|
409 log.warn(pe.getMessage() + " at "
|
|
410 + pe.getErrorOffset());
|
|
411 }
|
|
412 }
|
|
413 sb.setLength(0);
|
|
414 m++;
|
|
415 }
|
|
416 log.debug("" + sum);
|
|
417 return sumVector;
|
|
418 }
|
|
419
|
|
420 /**
|
|
421 * This will move the screen cursor based on the mouse event.
|
|
422 *
|
|
423 * I do not think the checks here for the gui characters should be here but
|
|
424 * will leave them here for now until we work out the interaction. This
|
|
425 * should be up to the gui frontend in my opinion.
|
|
426 *
|
|
427 * @param pos
|
|
428 */
|
|
429 public boolean moveCursor(int pos) {
|
|
430
|
|
431 if (!oia.isKeyBoardLocked()) {
|
|
432
|
|
433 if (pos < 0)
|
|
434 return false;
|
|
435 // because getRowColFromPoint returns offset of 1,1 we need to
|
|
436 // translate to offset 0,0
|
|
437 // pos -= (numCols + 1);
|
|
438
|
|
439 int g = planes.getWhichGUI(pos);
|
|
440
|
|
441 // lets check for hot spots
|
|
442 if (g >= BUTTON_LEFT && g <= BUTTON_LAST) {
|
|
443 StringBuffer aid = new StringBuffer();
|
|
444 boolean aidFlag = true;
|
|
445 switch (g) {
|
|
446 case BUTTON_RIGHT:
|
|
447 case BUTTON_MIDDLE:
|
|
448 while (planes.getWhichGUI(--pos) != BUTTON_LEFT) {
|
|
449 }
|
|
450 case BUTTON_LEFT:
|
|
451 if (planes.getChar(pos) == 'F') {
|
|
452 pos++;
|
|
453 } else
|
|
454 aidFlag = false;
|
|
455
|
|
456 if (planes.getChar(pos + 1) != '='
|
|
457 && planes.getChar(pos + 1) != '.'
|
|
458 && planes.getChar(pos + 1) != '/') {
|
7
|
459 log.debug(" Hotspot clicked!!! we will send characters "
|
|
460 + planes.getChar(pos) + " " + planes.getChar(pos+1));
|
3
|
461 aid.append(planes.getChar(pos));
|
|
462 aid.append(planes.getChar(pos + 1));
|
|
463 } else {
|
|
464 log.debug(" Hotspot clicked!!! we will send character "
|
|
465 + planes.getChar(pos));
|
|
466 aid.append(planes.getChar(pos));
|
|
467 }
|
|
468 break;
|
|
469
|
|
470 }
|
|
471 if (aidFlag) {
|
|
472 switch (g) {
|
|
473
|
|
474 case BUTTON_LEFT_UP:
|
|
475 case BUTTON_MIDDLE_UP:
|
|
476 case BUTTON_RIGHT_UP:
|
|
477 case BUTTON_ONE_UP:
|
|
478 case BUTTON_SB_UP:
|
|
479 case BUTTON_SB_GUIDE:
|
|
480 sessionVT.sendAidKey(AID_ROLL_UP);
|
|
481 break;
|
|
482
|
|
483 case BUTTON_LEFT_DN:
|
|
484 case BUTTON_MIDDLE_DN:
|
|
485 case BUTTON_RIGHT_DN:
|
|
486 case BUTTON_ONE_DN:
|
|
487 case BUTTON_SB_DN:
|
|
488 case BUTTON_SB_THUMB:
|
|
489
|
|
490 sessionVT.sendAidKey(AID_ROLL_DOWN);
|
|
491 break;
|
|
492 case BUTTON_LEFT_EB:
|
|
493 case BUTTON_MIDDLE_EB:
|
|
494 case BUTTON_RIGHT_EB:
|
|
495 StringBuffer eb = new StringBuffer();
|
|
496 while (planes.getWhichGUI(pos--) != BUTTON_LEFT_EB)
|
|
497 ;
|
|
498 while (planes.getWhichGUI(pos++) != BUTTON_RIGHT_EB) {
|
|
499 eb.append(planes.getChar(pos));
|
|
500 }
|
10
|
501 sessionVT.showURL(eb.toString());
|
3
|
502 // take out the log statement when we are sure it is
|
|
503 // working
|
|
504 log.info("Send to external Browser: " + eb.toString());
|
|
505 break;
|
|
506
|
|
507 default:
|
|
508 int aidKey = Integer.parseInt(aid.toString());
|
|
509 if (aidKey >= 1 && aidKey <= 12)
|
|
510 sessionVT.sendAidKey(0x30 + aidKey);
|
|
511 if (aidKey >= 13 && aidKey <= 24)
|
|
512 sessionVT.sendAidKey(0xB0 + (aidKey - 12));
|
|
513 }
|
|
514 } else {
|
|
515 if (screenFields.getCurrentField() != null) {
|
|
516 int xPos = screenFields.getCurrentField().startPos();
|
|
517 for (int x = 0; x < aid.length(); x++) {
|
|
518 // System.out.println(sr + "," + (sc + x) + " " +
|
|
519 // aid.charAt(x));
|
|
520 planes.setChar(xPos + x , aid.charAt(x));
|
|
521 }
|
|
522 // System.out.println(aid);
|
|
523 screenFields.setCurrentFieldMDT();
|
|
524 sessionVT.sendAidKey(AID_ENTER);
|
|
525 }
|
|
526
|
|
527 }
|
|
528 // return back to the calling routine that the cursor was not moved
|
|
529 // but something else here was done like aid keys or the such
|
|
530 return false;
|
|
531 }
|
|
532 // this is a note to not execute this code here when we
|
|
533 // implement
|
|
534 // the remain after edit function option.
|
|
535 // if (gui.rubberband.isAreaSelected()) {
|
|
536 // gui.rubberband.reset();
|
|
537 // gui.repaint();
|
|
538 // } else {
|
|
539 goto_XY(pos);
|
|
540 isInField(lastPos);
|
|
541
|
|
542 // return back to the calling object that the cursor was indeed
|
|
543 // moved with in the screen object
|
|
544 return true;
|
|
545 // }
|
|
546 }
|
|
547 return false;
|
|
548 }
|
|
549
|
|
550 public void setVT(tnvt v) {
|
|
551
|
|
552 sessionVT = v;
|
|
553 }
|
|
554
|
|
555 /**
|
|
556 * Searches the mnemonicData array looking for the specified string. If it
|
|
557 * is found it will return the value associated from the mnemonicValue
|
|
558 *
|
|
559 * @see #sendKeys
|
|
560 * @param mnem
|
|
561 * string mnemonic value
|
|
562 * @return key value of Mnemonic
|
|
563 */
|
|
564 private int getMnemonicValue(String mnem) {
|
|
565
|
|
566 for (int x = 0; x < mnemonicData.length; x++) {
|
|
567
|
|
568 if (mnemonicData[x].equals(mnem))
|
|
569 return mnemonicValue[x];
|
|
570 }
|
|
571 return 0;
|
|
572
|
|
573 }
|
|
574
|
|
575 protected void setPrehelpState(boolean setErrorCode, boolean lockKeyboard,
|
|
576 boolean unlockIfLocked) {
|
|
577 if (oia.isKeyBoardLocked() && unlockIfLocked)
|
|
578 oia.setKeyBoardLocked(false);
|
|
579 else
|
|
580 oia.setKeyBoardLocked(lockKeyboard);
|
|
581 bufferedKeys = null;
|
|
582 oia.setKeysBuffered(false);
|
|
583
|
|
584
|
|
585 }
|
|
586
|
|
587 /**
|
|
588 * Activate the cursor on screen
|
|
589 *
|
|
590 * @param activate
|
|
591 */
|
|
592 public void setCursorActive(boolean activate) {
|
|
593
|
|
594 // System.out.println("cursor active " + updateCursorLoc + " " +
|
|
595 // cursorActive + " " + activate);
|
|
596 if (cursorActive && !activate) {
|
|
597 setCursorOff();
|
|
598 cursorActive = activate;
|
|
599 } else {
|
|
600 if (!cursorActive && activate) {
|
|
601 cursorActive = activate;
|
|
602 setCursorOn();
|
|
603 }
|
|
604 }
|
|
605 }
|
|
606
|
|
607 /**
|
|
608 * Set the cursor on
|
|
609 */
|
|
610 public void setCursorOn() {
|
|
611 cursorShown = true;
|
|
612 updateCursorLoc();
|
|
613 }
|
|
614
|
|
615 /**
|
|
616 * Set the cursor off
|
|
617 */
|
|
618 public void setCursorOff() {
|
|
619
|
|
620 cursorShown = false;
|
|
621 updateCursorLoc();
|
|
622 // System.out.println("cursor off " + updateCursorLoc + " " +
|
|
623 // cursorActive);
|
|
624
|
|
625 }
|
|
626
|
|
627 /**
|
|
628 *
|
|
629 */
|
|
630 private void updateCursorLoc() {
|
|
631
|
|
632 if (cursorActive) {
|
|
633
|
|
634 fireCursorChanged(3);
|
|
635
|
|
636 }
|
|
637 }
|
|
638
|
|
639 //Added by Barry
|
|
640 public String getKeys() {
|
|
641 String result = this.keybuf.toString();
|
|
642 this.keybuf = new StringBuffer();
|
|
643 return result;
|
|
644 }
|
|
645
|
|
646 /**
|
|
647 * The sendKeys method sends a string of keys to the virtual screen. This
|
|
648 * method acts as if keystrokes were being typed from the keyboard. The
|
|
649 * keystrokes will be sent to the location given. The string being passed
|
|
650 * can also contain mnemonic values such as [enter] enter key,[tab] tab key,
|
|
651 * [pf1] pf1 etc...
|
|
652 *
|
|
653 * These will be processed as if you had pressed these keys from the
|
|
654 * keyboard. All the valid special key values are contained in the MNEMONIC
|
|
655 * enumeration:
|
|
656 *
|
|
657 * <table BORDER COLS=2 WIDTH="50%" >
|
|
658 *
|
|
659 * <tr>
|
|
660 * <td>MNEMONIC_CLEAR</td>
|
|
661 * <td>[clear]</td>
|
|
662 * </tr>
|
|
663 * <tr>
|
|
664 * <td>MNEMONIC_ENTER</td>
|
|
665 * <td>[enter]</td>
|
|
666 * </tr>
|
|
667 * <tr>
|
|
668 * <td>MNEMONIC_HELP</td>
|
|
669 * <td>[help]</td>
|
|
670 * </tr>
|
|
671 * <tr>
|
|
672 * <td>MNEMONIC_PAGE_DOWN</td>
|
|
673 * <td>[pgdown]</td>
|
|
674 * </tr>
|
|
675 * <tr>
|
|
676 * <td>MNEMONIC_PAGE_UP</td>
|
|
677 * <td>[pgup]</td>
|
|
678 * </tr>
|
|
679 * <tr>
|
|
680 * <td>MNEMONIC_PRINT</td>
|
|
681 * <td>[print]</td>
|
|
682 * </tr>
|
|
683 * <tr>
|
|
684 * <td>MNEMONIC_PF1</td>
|
|
685 * <td>[pf1]</td>
|
|
686 * </tr>
|
|
687 * <tr>
|
|
688 * <td>MNEMONIC_PF2</td>
|
|
689 * <td>[pf2]</td>
|
|
690 * </tr>
|
|
691 * <tr>
|
|
692 * <td>MNEMONIC_PF3</td>
|
|
693 * <td>[pf3]</td>
|
|
694 * </tr>
|
|
695 * <tr>
|
|
696 * <td>MNEMONIC_PF4</td>
|
|
697 * <td>[pf4]</td>
|
|
698 * </tr>
|
|
699 * <tr>
|
|
700 * <td>MNEMONIC_PF5</td>
|
|
701 * <td>[pf5]</td>
|
|
702 * </tr>
|
|
703 * <tr>
|
|
704 * <td>MNEMONIC_PF6</td>
|
|
705 * <td>[pf6]</td>
|
|
706 * </tr>
|
|
707 * <tr>
|
|
708 * <td>MNEMONIC_PF7</td>
|
|
709 * <td>[pf7]</td>
|
|
710 * </tr>
|
|
711 * <tr>
|
|
712 * <td>MNEMONIC_PF8</td>
|
|
713 * <td>[pf8]</td>
|
|
714 * </tr>
|
|
715 * <tr>
|
|
716 * <td>MNEMONIC_PF9</td>
|
|
717 * <td>[pf9]</td>
|
|
718 * </tr>
|
|
719 * <tr>
|
|
720 * <td>MNEMONIC_PF10</td>
|
|
721 * <td>[pf10]</td>
|
|
722 * </tr>
|
|
723 * <tr>
|
|
724 * <td>MNEMONIC_PF11</td>
|
|
725 * <td>[pf11]</td>
|
|
726 * </tr>
|
|
727 * <tr>
|
|
728 * <td>MNEMONIC_PF12</td>
|
|
729 * <td>[pf12]</td>
|
|
730 * </tr>
|
|
731 * <tr>
|
|
732 * <td>MNEMONIC_PF13</td>
|
|
733 * <td>[pf13]</td>
|
|
734 * </tr>
|
|
735 * <tr>
|
|
736 * <td>MNEMONIC_PF14</td>
|
|
737 * <td>[pf14]</td>
|
|
738 * </tr>
|
|
739 * <tr>
|
|
740 * <td>MNEMONIC_PF15</td>
|
|
741 * <td>[pf15]</td>
|
|
742 * </tr>
|
|
743 * <tr>
|
|
744 * <td>MNEMONIC_PF16</td>
|
|
745 * <td>[pf16]</td>
|
|
746 * </tr>
|
|
747 * <tr>
|
|
748 * <td>MNEMONIC_PF17</td>
|
|
749 * <td>[pf17]</td>
|
|
750 * </tr>
|
|
751 * <tr>
|
|
752 * <td>MNEMONIC_PF18</td>
|
|
753 * <td>[pf18]</td>
|
|
754 * </tr>
|
|
755 * <tr>
|
|
756 * <td>MNEMONIC_PF19</td>
|
|
757 * <td>[pf19]</td>
|
|
758 * </tr>
|
|
759 * <tr>
|
|
760 * <td>MNEMONIC_PF20</td>
|
|
761 * <td>[pf20]</td>
|
|
762 * </tr>
|
|
763 * <tr>
|
|
764 * <td>MNEMONIC_PF21</td>
|
|
765 * <td>[pf21]</td>
|
|
766 * </tr>
|
|
767 * <tr>
|
|
768 * <td>MNEMONIC_PF22</td>
|
|
769 * <td>[pf22]</td>
|
|
770 * </tr>
|
|
771 * <tr>
|
|
772 * <td>MNEMONIC_PF23</td>
|
|
773 * <td>[pf23]</td>
|
|
774 * </tr>
|
|
775 * <tr>
|
|
776 * <td>MNEMONIC_PF24</td>
|
|
777 * <td>[pf24]</td>
|
|
778 * </tr>
|
|
779 * <tr>
|
|
780 * <td>MNEMONIC_BACK_SPACE</td>
|
|
781 * <td>[backspace]</td>
|
|
782 * </tr>
|
|
783 * <tr>
|
|
784 * <td>MNEMONIC_BACK_TAB</td>
|
|
785 * <td>[backtab]</td>
|
|
786 * </tr>
|
|
787 * <tr>
|
|
788 * <td>MNEMONIC_UP</td>
|
|
789 * <td>[up]</td>
|
|
790 * </tr>
|
|
791 * <tr>
|
|
792 * <td>MNEMONIC_DOWN</td>
|
|
793 * <td>[down]</td>
|
|
794 * </tr>
|
|
795 * <tr>
|
|
796 * <td>MNEMONIC_LEFT</td>
|
|
797 * <td>[left]</td>
|
|
798 * </tr>
|
|
799 * <tr>
|
|
800 * <td>MNEMONIC_RIGHT</td>
|
|
801 * <td>[right]</td>
|
|
802 * </tr>
|
|
803 * <tr>
|
|
804 * <td>MNEMONIC_DELETE</td>
|
|
805 * <td>[delete]</td>
|
|
806 * </tr>
|
|
807 * <tr>
|
|
808 * <td>MNEMONIC_TAB</td>
|
|
809 * <td>"[tab]</td>
|
|
810 * </tr>
|
|
811 * <tr>
|
|
812 * <td>MNEMONIC_END_OF_FIELD</td>
|
|
813 * <td>[eof]</td>
|
|
814 * </tr>
|
|
815 * <tr>
|
|
816 * <td>MNEMONIC_ERASE_EOF</td>
|
|
817 * <td>[eraseeof]</td>
|
|
818 * </tr>
|
|
819 * <tr>
|
|
820 * <td>MNEMONIC_ERASE_FIELD</td>
|
|
821 * <td>[erasefld]</td>
|
|
822 * </tr>
|
|
823 * <tr>
|
|
824 * <td>MNEMONIC_INSERT</td>
|
|
825 * <td>[insert]</td>
|
|
826 * </tr>
|
|
827 * <tr>
|
|
828 * <td>MNEMONIC_HOME</td>
|
|
829 * <td>[home]</td>
|
|
830 * </tr>
|
|
831 * <tr>
|
|
832 * <td>MNEMONIC_KEYPAD0</td>
|
|
833 * <td>[keypad0]</td>
|
|
834 * </tr>
|
|
835 * <tr>
|
|
836 * <td>MNEMONIC_KEYPAD1</td>
|
|
837 * <td>[keypad1]</td>
|
|
838 * </tr>
|
|
839 * <tr>
|
|
840 * <td>MNEMONIC_KEYPAD2</td>
|
|
841 * <td>[keypad2]</td>
|
|
842 * </tr>
|
|
843 * <tr>
|
|
844 * <td>MNEMONIC_KEYPAD3</td>
|
|
845 * <td>[keypad3]</td>
|
|
846 * </tr>
|
|
847 * <tr>
|
|
848 * <td>MNEMONIC_KEYPAD4</td>
|
|
849 * <td>[keypad4]</td>
|
|
850 * </tr>
|
|
851 * <tr>
|
|
852 * <td>MNEMONIC_KEYPAD5</td>
|
|
853 * <td>[keypad5]</td>
|
|
854 * </tr>
|
|
855 * <tr>
|
|
856 * <td>MNEMONIC_KEYPAD6</td>
|
|
857 * <td>[keypad6]</td>
|
|
858 * </tr>
|
|
859 * <tr>
|
|
860 * <td>MNEMONIC_KEYPAD7</td>
|
|
861 * <td>[keypad7]</td>
|
|
862 * </tr>
|
|
863 * <tr>
|
|
864 * <td>MNEMONIC_KEYPAD8</td>
|
|
865 * <td>[keypad8]</td>
|
|
866 * </tr>
|
|
867 * <tr>
|
|
868 * <td>MNEMONIC_KEYPAD9</td>
|
|
869 * <td>[keypad9]</td>
|
|
870 * </tr>
|
|
871 * <tr>
|
|
872 * <td>MNEMONIC_KEYPAD_PERIOD</td>
|
|
873 * <td>[keypad.]</td>
|
|
874 * </tr>
|
|
875 * <tr>
|
|
876 * <td>MNEMONIC_KEYPAD_COMMA</td>
|
|
877 * <td>[keypad,]</td>
|
|
878 * </tr>
|
|
879 * <tr>
|
|
880 * <td>MNEMONIC_KEYPAD_MINUS</td>
|
|
881 * <td>[keypad-]</td>
|
|
882 * </tr>
|
|
883 * <tr>
|
|
884 * <td>MNEMONIC_FIELD_EXIT</td>
|
|
885 * <td>[fldext]</td>
|
|
886 * </tr>
|
|
887 * <tr>
|
|
888 * <td>MNEMONIC_FIELD_PLUS</td>
|
|
889 * <td>[field+]</td>
|
|
890 * </tr>
|
|
891 * <tr>
|
|
892 * <td>MNEMONIC_FIELD_MINUS</td>
|
|
893 * <td>[field-]</td>
|
|
894 * </tr>
|
|
895 * <tr>
|
|
896 * <td>MNEMONIC_BEGIN_OF_FIELD</td>
|
|
897 * <td>[bof]</td>
|
|
898 * </tr>
|
|
899 * <tr>
|
|
900 * <td>MNEMONIC_PA1</td>
|
|
901 * <td>[pa1]</td>
|
|
902 * </tr>
|
|
903 * <tr>
|
|
904 * <td>MNEMONIC_PA2</td>
|
|
905 * <td>[pa2]</td>
|
|
906 * </tr>
|
|
907 * <tr>
|
|
908 * <td>MNEMONIC_PA3</td>
|
|
909 * <td>[pa3]</td>
|
|
910 * </tr>
|
|
911 * <tr>
|
|
912 * <td>MNEMONIC_SYSREQ</td>
|
|
913 * <td>[sysreq]</td>
|
|
914 * </tr>
|
|
915 * <tr>
|
|
916 * <td>MNEMONIC_RESET</td>
|
|
917 * <td>[reset]</td>
|
|
918 * </tr>
|
|
919 * <tr>
|
|
920 * <td>MNEMONIC_ATTN</td>
|
|
921 * <td>[attn]</td>
|
|
922 * </tr>
|
|
923 * <tr>
|
|
924 * <td>MNEMONIC_MARK_LEFT</td>
|
|
925 * <td>[markleft]</td>
|
|
926 * </tr>
|
|
927 * <tr>
|
|
928 * <td>MNEMONIC_MARK_RIGHT</td>
|
|
929 * <td>[markright]</td>
|
|
930 * </tr>
|
|
931 * <tr>
|
|
932 * <td>MNEMONIC_MARK_UP</td>
|
|
933 * <td>[markup]</td>
|
|
934 * </tr>
|
|
935 * <tr>
|
|
936 * <td>MNEMONIC_MARK_DOWN</td>
|
|
937 * <td>[markdown]</td>
|
|
938 * </tr>
|
|
939 *
|
|
940 * </table>
|
|
941 *
|
|
942 * @param text
|
|
943 * The string of characters to be sent
|
|
944 *
|
|
945 * @see #sendAid
|
|
946 *
|
|
947 * Added synchronized to fix a StringOutOfBounds error - Luc Gorren LDC
|
|
948 */
|
|
949 public synchronized void sendKeys(String text) {
|
|
950
|
|
951 // if (text == null) {
|
|
952 // return;
|
|
953 // }
|
|
954 this.keybuf.append(text);
|
|
955
|
|
956 if (isStatusErrorCode() && !resetRequired) {
|
|
957 setCursorActive(false);
|
|
958 simulateMnemonic(getMnemonicValue("[reset]"));
|
|
959 setCursorActive(true);
|
|
960 }
|
|
961
|
|
962 if (oia.isKeyBoardLocked()) {
|
|
963 if (text.equals("[reset]") || text.equals("[sysreq]")
|
|
964 || text.equals("[attn]")) {
|
|
965 setCursorActive(false);
|
|
966 simulateMnemonic(getMnemonicValue(text));
|
|
967 setCursorActive(true);
|
|
968
|
|
969 } else {
|
|
970 if (isStatusErrorCode()) {
|
|
971 sessionVT.signalBell();
|
|
972 return;
|
|
973 }
|
|
974
|
|
975 oia.setKeysBuffered(true);
|
|
976
|
|
977 if (bufferedKeys == null) {
|
|
978 bufferedKeys = text;
|
|
979 return;
|
|
980 }
|
|
981 bufferedKeys += text;
|
|
982 return;
|
|
983 }
|
|
984
|
|
985 } else {
|
|
986
|
|
987 if (oia.isKeysBuffered()) {
|
|
988 if (bufferedKeys != null) {
|
|
989 text = bufferedKeys + text;
|
|
990 }
|
|
991 // if (text.length() == 0) {
|
|
992 oia.setKeysBuffered(false);
|
|
993 // }
|
|
994 bufferedKeys = null;
|
|
995
|
|
996 }
|
|
997 // check to see if position is in a field and if it is then change
|
|
998 // current field to that field
|
|
999 isInField(lastPos, true);
|
|
1000 if (text.length() == 1 && !text.equals("[") && !text.equals("]")) {
|
|
1001 // setCursorOff2();
|
|
1002 setCursorActive(false);
|
|
1003 simulateKeyStroke(text.charAt(0));
|
|
1004 setCursorActive(true);
|
|
1005 // setCursorOn2();
|
|
1006 // System.out.println(" text one");
|
|
1007
|
|
1008 } else {
|
|
1009
|
|
1010 strokenizer.setKeyStrokes(text);
|
|
1011 String s;
|
|
1012 boolean done = false;
|
|
1013
|
|
1014 // setCursorOff2();
|
|
1015 setCursorActive(false);
|
|
1016 while (!done) {
|
|
1017 // while (strokenizer.hasMoreKeyStrokes() && !keyboardLocked
|
|
1018 // &&
|
|
1019 // !isStatusErrorCode() && !done) {
|
|
1020 if (strokenizer.hasMoreKeyStrokes()) {
|
|
1021
|
|
1022 // check to see if position is in a field and if it is
|
|
1023 // then change
|
|
1024 // current field to that field
|
|
1025 isInField(lastPos, true);
|
|
1026 s = strokenizer.nextKeyStroke();
|
|
1027 if (s.length() == 1) {
|
|
1028 // setCursorOn();
|
|
1029 // if (!keysBuffered) {
|
|
1030 // System.out.println(" s two" + s);
|
|
1031 // setCursorOn();
|
|
1032 // }
|
|
1033
|
|
1034 // try { new Thread().sleep(400);} catch
|
|
1035 // (InterruptedException ie) {}
|
|
1036 simulateKeyStroke(s.charAt(0));
|
|
1037 // System.out.println(" s two " + s + " " +
|
|
1038 // cursorActive);
|
|
1039 // if (cursorActive && !keysBuffered) {
|
|
1040 // System.out.println(" s two" + s);
|
|
1041 // setCursorOn();
|
|
1042 // }
|
|
1043 } else {
|
|
1044 simulateMnemonic(getMnemonicValue(s));
|
|
1045 // if (!cursorActive && !keysBuffered) {
|
|
1046 // System.out.println(" m one");
|
|
1047 // setCursorOn();
|
|
1048 // }
|
|
1049 }
|
|
1050
|
|
1051 if (oia.isKeyBoardLocked()) {
|
|
1052
|
|
1053 bufferedKeys = strokenizer
|
|
1054 .getUnprocessedKeyStroked();
|
|
1055 if (bufferedKeys != null) {
|
|
1056 oia.setKeysBuffered(true);
|
|
1057
|
|
1058 }
|
|
1059 done = true;
|
|
1060 }
|
|
1061
|
|
1062 }
|
|
1063
|
|
1064 else {
|
|
1065 // setCursorActive(true);
|
|
1066 // setCursorOn();
|
|
1067 done = true;
|
|
1068 }
|
|
1069 }
|
|
1070 setCursorActive(true);
|
|
1071 }
|
|
1072 }
|
|
1073 }
|
|
1074
|
|
1075 /**
|
|
1076 * The sendAid method sends an "aid" keystroke to the virtual screen. These
|
|
1077 * aid keys can be thought of as special keystrokes, like the Enter key,
|
|
1078 * PF1-24 keys or the Page Up key. All the valid special key values are
|
|
1079 * contained in the AID_ enumeration:
|
|
1080 *
|
|
1081 * @param aidKey
|
|
1082 * The aid key to be sent to the host
|
|
1083 *
|
|
1084 * @see #sendKeys
|
|
1085 * @see TN5250jConstants#AID_CLEAR
|
|
1086 * @see #AID_ENTER
|
|
1087 * @see #AID_HELP
|
|
1088 * @see #AID_ROLL_UP
|
|
1089 * @see #AID_ROLL_DOWN
|
|
1090 * @see #AID_ROLL_LEFT
|
|
1091 * @see #AID_ROLL_RIGHT
|
|
1092 * @see #AID_PRINT
|
|
1093 * @see #AID_PF1
|
|
1094 * @see #AID_PF2
|
|
1095 * @see #AID_PF3
|
|
1096 * @see #AID_PF4
|
|
1097 * @see #AID_PF5
|
|
1098 * @see #AID_PF6
|
|
1099 * @see #AID_PF7
|
|
1100 * @see #AID_PF8
|
|
1101 * @see #AID_PF9
|
|
1102 * @see #AID_PF10
|
|
1103 * @see #AID_PF11
|
|
1104 * @see #AID_PF12
|
|
1105 * @see #AID_PF13
|
|
1106 * @see #AID_PF14
|
|
1107 * @see #AID_PF15
|
|
1108 * @see #AID_PF16
|
|
1109 * @see #AID_PF17
|
|
1110 * @see #AID_PF18
|
|
1111 * @see #AID_PF19
|
|
1112 * @see #AID_PF20
|
|
1113 * @see #AID_PF21
|
|
1114 * @see #AID_PF22
|
|
1115 * @see #AID_PF23
|
|
1116 * @see #AID_PF24
|
|
1117 */
|
|
1118 public void sendAid(int aidKey) {
|
|
1119
|
|
1120 sessionVT.sendAidKey(aidKey);
|
|
1121 }
|
|
1122
|
|
1123 /**
|
|
1124 * Restores the error line and sets the error mode off.
|
|
1125 *
|
|
1126 */
|
|
1127 protected void resetError() {
|
|
1128
|
|
1129 restoreErrorLine();
|
|
1130 setStatus(STATUS_ERROR_CODE, STATUS_VALUE_OFF, "");
|
|
1131
|
|
1132 }
|
|
1133
|
|
1134 protected boolean simulateMnemonic(int mnem) {
|
|
1135
|
|
1136 boolean simulated = false;
|
|
1137
|
|
1138 switch (mnem) {
|
|
1139
|
|
1140 case AID_CLEAR:
|
|
1141 case AID_ENTER:
|
|
1142 case AID_PF1:
|
|
1143 case AID_PF2:
|
|
1144 case AID_PF3:
|
|
1145 case AID_PF4:
|
|
1146 case AID_PF5:
|
|
1147 case AID_PF6:
|
|
1148 case AID_PF7:
|
|
1149 case AID_PF8:
|
|
1150 case AID_PF9:
|
|
1151 case AID_PF10:
|
|
1152 case AID_PF11:
|
|
1153 case AID_PF12:
|
|
1154 case AID_PF13:
|
|
1155 case AID_PF14:
|
|
1156 case AID_PF15:
|
|
1157 case AID_PF16:
|
|
1158 case AID_PF17:
|
|
1159 case AID_PF18:
|
|
1160 case AID_PF19:
|
|
1161 case AID_PF20:
|
|
1162 case AID_PF21:
|
|
1163 case AID_PF22:
|
|
1164 case AID_PF23:
|
|
1165 case AID_PF24:
|
|
1166 case AID_ROLL_DOWN:
|
|
1167 case AID_ROLL_UP:
|
|
1168 case AID_ROLL_LEFT:
|
|
1169 case AID_ROLL_RIGHT:
|
|
1170
|
|
1171 if (!screenFields.isCanSendAid()) {
|
|
1172 displayError(ERR_ENTER_NO_ALLOWED);
|
|
1173 } else
|
|
1174 sendAid(mnem);
|
|
1175 simulated = true;
|
|
1176
|
|
1177 break;
|
|
1178 case AID_HELP:
|
|
1179 sessionVT.sendHelpRequest();
|
|
1180 simulated = true;
|
|
1181 break;
|
|
1182
|
|
1183 case AID_PRINT:
|
|
1184 sessionVT.hostPrint(1);
|
|
1185 simulated = true;
|
|
1186 break;
|
|
1187
|
|
1188 case BACK_SPACE:
|
|
1189 if (screenFields.getCurrentField() != null
|
|
1190 && screenFields.withinCurrentField(lastPos)
|
|
1191 && !screenFields.isCurrentFieldBypassField()) {
|
|
1192
|
|
1193 if (screenFields.getCurrentField().startPos() == lastPos) {
|
|
1194 if (backspaceError)
|
|
1195 displayError(ERR_CURSOR_PROTECTED);
|
|
1196 else {
|
|
1197 gotoFieldPrev();
|
|
1198 goto_XY(screenFields.getCurrentField().endPos());
|
|
1199 updateDirty();
|
|
1200 }
|
|
1201 }
|
|
1202 else {
|
|
1203 screenFields.getCurrentField().getKeyPos(lastPos);
|
|
1204 screenFields.getCurrentField().changePos(-1);
|
|
1205 resetDirty(screenFields.getCurrentField().getCurrentPos());
|
|
1206 shiftLeft(screenFields.getCurrentField().getCurrentPos());
|
|
1207 updateDirty();
|
|
1208 screenFields.setCurrentFieldMDT();
|
|
1209
|
|
1210 simulated = true;
|
|
1211 }
|
|
1212 } else {
|
|
1213 displayError(ERR_CURSOR_PROTECTED);
|
|
1214
|
|
1215 }
|
|
1216 break;
|
|
1217 case BACK_TAB:
|
|
1218
|
|
1219 if (screenFields.getCurrentField() != null
|
|
1220 && screenFields.isCurrentFieldHighlightedEntry()) {
|
|
1221 resetDirty(screenFields.getCurrentField().startPos);
|
|
1222 gotoFieldPrev();
|
|
1223 updateDirty();
|
|
1224 } else
|
|
1225 gotoFieldPrev();
|
|
1226
|
|
1227 if (screenFields.isCurrentFieldContinued()) {
|
|
1228 do {
|
|
1229 gotoFieldPrev();
|
|
1230 } while (screenFields.isCurrentFieldContinuedMiddle()
|
|
1231 || screenFields.isCurrentFieldContinuedLast());
|
|
1232 }
|
|
1233 isInField(lastPos);
|
|
1234 simulated = true;
|
|
1235 break;
|
|
1236 case UP:
|
|
1237 case MARK_UP:
|
|
1238 process_XY(lastPos - numCols);
|
|
1239 simulated = true;
|
|
1240 break;
|
|
1241 case DOWN:
|
|
1242 case MARK_DOWN:
|
|
1243 process_XY(lastPos + numCols);
|
|
1244 simulated = true;
|
|
1245 break;
|
|
1246 case LEFT:
|
|
1247 case MARK_LEFT:
|
|
1248 process_XY(lastPos - 1);
|
|
1249 simulated = true;
|
|
1250 break;
|
|
1251 case RIGHT:
|
|
1252 case MARK_RIGHT:
|
|
1253 process_XY(lastPos + 1);
|
|
1254 simulated = true;
|
|
1255 break;
|
|
1256 case NEXTWORD:
|
|
1257 gotoNextWord();
|
|
1258 simulated = true;
|
|
1259 break;
|
|
1260 case PREVWORD:
|
|
1261 gotoPrevWord();
|
|
1262 simulated = true;
|
|
1263 break;
|
|
1264 case DELETE:
|
|
1265 if (screenFields.getCurrentField() != null
|
|
1266 && screenFields.withinCurrentField(lastPos)
|
|
1267 && !screenFields.isCurrentFieldBypassField()) {
|
|
1268
|
|
1269 resetDirty(lastPos);
|
|
1270 screenFields.getCurrentField().getKeyPos(lastPos);
|
|
1271 shiftLeft(screenFields.getCurrentFieldPos());
|
|
1272 screenFields.setCurrentFieldMDT();
|
|
1273 updateDirty();
|
|
1274 simulated = true;
|
|
1275 } else {
|
|
1276 displayError(ERR_CURSOR_PROTECTED);
|
|
1277 }
|
|
1278
|
|
1279 break;
|
|
1280 case TAB:
|
|
1281
|
|
1282 if (screenFields.getCurrentField() != null
|
|
1283 && !screenFields.isCurrentFieldContinued()) {
|
|
1284 if (screenFields.isCurrentFieldHighlightedEntry()) {
|
|
1285 resetDirty(screenFields.getCurrentField().startPos);
|
|
1286 gotoFieldNext();
|
|
1287 updateDirty();
|
|
1288 } else
|
|
1289 gotoFieldNext();
|
|
1290 } else {
|
|
1291 do {
|
|
1292 gotoFieldNext();
|
|
1293 } while (screenFields.getCurrentField() != null
|
|
1294 && (screenFields.isCurrentFieldContinuedMiddle() || screenFields
|
|
1295 .isCurrentFieldContinuedLast()));
|
|
1296 }
|
|
1297
|
|
1298 isInField(lastPos);
|
|
1299 simulated = true;
|
|
1300
|
|
1301 break;
|
|
1302 case EOF:
|
|
1303 if (screenFields.getCurrentField() != null
|
|
1304 && screenFields.withinCurrentField(lastPos)
|
|
1305 && !screenFields.isCurrentFieldBypassField()) {
|
|
1306 int where = endOfField(screenFields.getCurrentField()
|
|
1307 .startPos(), true);
|
|
1308 if (where > 0) {
|
|
1309 setCursor((where / numCols) + 1, (where % numCols) + 1);
|
|
1310 }
|
|
1311 simulated = true;
|
|
1312 } else {
|
|
1313 displayError(ERR_CURSOR_PROTECTED);
|
|
1314 }
|
|
1315 resetDirty(lastPos);
|
|
1316
|
|
1317 break;
|
|
1318 case ERASE_EOF:
|
|
1319 if (screenFields.getCurrentField() != null
|
|
1320 && screenFields.withinCurrentField(lastPos)
|
|
1321 && !screenFields.isCurrentFieldBypassField()) {
|
|
1322
|
|
1323 int where = lastPos;
|
|
1324 resetDirty(lastPos);
|
|
1325 if (fieldExit()) {
|
|
1326 screenFields.setCurrentFieldMDT();
|
|
1327 if (!screenFields.isCurrentFieldContinued()) {
|
|
1328 gotoFieldNext();
|
|
1329 } else {
|
|
1330 do {
|
|
1331 gotoFieldNext();
|
|
1332 if (screenFields.isCurrentFieldContinued())
|
|
1333 fieldExit();
|
|
1334 } while (screenFields.isCurrentFieldContinuedMiddle()
|
|
1335 || screenFields.isCurrentFieldContinuedLast());
|
|
1336 }
|
|
1337 }
|
|
1338 updateDirty();
|
|
1339 goto_XY(where);
|
|
1340 simulated = true;
|
|
1341
|
|
1342 } else {
|
|
1343 displayError(ERR_CURSOR_PROTECTED);
|
|
1344 }
|
|
1345
|
|
1346 break;
|
|
1347 case ERASE_FIELD:
|
|
1348 if (screenFields.getCurrentField() != null
|
|
1349 && screenFields.withinCurrentField(lastPos)
|
|
1350 && !screenFields.isCurrentFieldBypassField()) {
|
|
1351
|
|
1352 int where = lastPos;
|
|
1353 lastPos = screenFields.getCurrentField().startPos();
|
|
1354 resetDirty(lastPos);
|
|
1355 if (fieldExit()) {
|
|
1356 screenFields.setCurrentFieldMDT();
|
|
1357 if (!screenFields.isCurrentFieldContinued()) {
|
|
1358 gotoFieldNext();
|
|
1359 } else {
|
|
1360 do {
|
|
1361 gotoFieldNext();
|
|
1362 if (screenFields.isCurrentFieldContinued())
|
|
1363 fieldExit();
|
|
1364 } while (screenFields.isCurrentFieldContinuedMiddle()
|
|
1365 || screenFields.isCurrentFieldContinuedLast());
|
|
1366 }
|
|
1367 }
|
|
1368 updateDirty();
|
|
1369 goto_XY(where);
|
|
1370 simulated = true;
|
|
1371
|
|
1372 } else {
|
|
1373 displayError(ERR_CURSOR_PROTECTED);
|
|
1374 }
|
|
1375
|
|
1376 break;
|
|
1377 case INSERT:
|
|
1378 // we toggle it
|
|
1379 oia.setInsertMode(oia.isInsertMode() ? false : true);
|
|
1380 break;
|
|
1381 case HOME:
|
|
1382 // position to the home position set
|
|
1383 if (lastPos + numCols + 1 != homePos) {
|
|
1384 goto_XY(homePos - numCols - 1);
|
|
1385 // now check if we are in a field
|
|
1386 isInField(lastPos);
|
|
1387 } else
|
|
1388 gotoField(1);
|
|
1389 break;
|
|
1390 case KEYPAD_0:
|
|
1391 simulated = simulateKeyStroke('0');
|
|
1392 break;
|
|
1393 case KEYPAD_1:
|
|
1394 simulated = simulateKeyStroke('1');
|
|
1395 break;
|
|
1396 case KEYPAD_2:
|
|
1397 simulated = simulateKeyStroke('2');
|
|
1398 break;
|
|
1399 case KEYPAD_3:
|
|
1400 simulated = simulateKeyStroke('3');
|
|
1401 break;
|
|
1402 case KEYPAD_4:
|
|
1403 simulated = simulateKeyStroke('4');
|
|
1404 break;
|
|
1405 case KEYPAD_5:
|
|
1406 simulated = simulateKeyStroke('5');
|
|
1407 break;
|
|
1408 case KEYPAD_6:
|
|
1409 simulated = simulateKeyStroke('6');
|
|
1410 break;
|
|
1411 case KEYPAD_7:
|
|
1412 simulated = simulateKeyStroke('7');
|
|
1413 break;
|
|
1414 case KEYPAD_8:
|
|
1415 simulated = simulateKeyStroke('8');
|
|
1416 break;
|
|
1417 case KEYPAD_9:
|
|
1418 simulated = simulateKeyStroke('9');
|
|
1419 break;
|
|
1420 case KEYPAD_PERIOD:
|
|
1421 simulated = simulateKeyStroke('.');
|
|
1422 break;
|
|
1423 case KEYPAD_COMMA:
|
|
1424 simulated = simulateKeyStroke(',');
|
|
1425 break;
|
|
1426 case KEYPAD_MINUS:
|
|
1427 if (screenFields.getCurrentField() != null
|
|
1428 && screenFields.withinCurrentField(lastPos)
|
|
1429 && !screenFields.isCurrentFieldBypassField()) {
|
|
1430
|
|
1431 int s = screenFields.getCurrentField().getFieldShift();
|
|
1432 if (s == 3 || s == 5 || s == 7) {
|
|
1433 planes.setChar(lastPos,'-');
|
|
1434
|
|
1435 resetDirty(lastPos);
|
|
1436 advancePos();
|
|
1437 if (fieldExit()) {
|
|
1438 screenFields.setCurrentFieldMDT();
|
|
1439 if (!screenFields.isCurrentFieldContinued()) {
|
|
1440 gotoFieldNext();
|
|
1441 } else {
|
|
1442 do {
|
|
1443 gotoFieldNext();
|
|
1444 } while (screenFields
|
|
1445 .isCurrentFieldContinuedMiddle()
|
|
1446 || screenFields
|
|
1447 .isCurrentFieldContinuedLast());
|
|
1448 }
|
|
1449 simulated = true;
|
|
1450 updateDirty();
|
|
1451 if (screenFields.isCurrentFieldAutoEnter())
|
|
1452 sendAid(AID_ENTER);
|
|
1453
|
|
1454 }
|
|
1455 } else {
|
|
1456 displayError(ERR_FIELD_MINUS);
|
|
1457
|
|
1458 }
|
|
1459 } else {
|
|
1460 displayError(ERR_CURSOR_PROTECTED);
|
|
1461 }
|
|
1462
|
|
1463 break;
|
|
1464 case FIELD_EXIT:
|
|
1465 if (screenFields.getCurrentField() != null
|
|
1466 && screenFields.withinCurrentField(lastPos)
|
|
1467 && !screenFields.isCurrentFieldBypassField()) {
|
|
1468
|
|
1469 resetDirty(lastPos);
|
|
1470
|
|
1471 boolean autoFE = screenFields.isCurrentFieldAutoEnter();
|
|
1472
|
|
1473 if (fieldExit()) {
|
|
1474 screenFields.setCurrentFieldMDT();
|
|
1475 if (!screenFields.isCurrentFieldContinued() &&
|
|
1476 !screenFields.isCurrentFieldAutoEnter()) {
|
|
1477 gotoFieldNext();
|
|
1478 } else {
|
|
1479 do {
|
|
1480 gotoFieldNext();
|
|
1481 if (screenFields.isCurrentFieldContinued())
|
|
1482 fieldExit();
|
|
1483 } while (screenFields.isCurrentFieldContinuedMiddle()
|
|
1484 || screenFields.isCurrentFieldContinuedLast());
|
|
1485 }
|
|
1486 }
|
|
1487
|
|
1488 updateDirty();
|
|
1489 simulated = true;
|
|
1490 if (autoFE)
|
|
1491 sendAid(AID_ENTER);
|
|
1492
|
|
1493 } else {
|
|
1494 displayError(ERR_CURSOR_PROTECTED);
|
|
1495 }
|
|
1496
|
|
1497 break;
|
|
1498 case FIELD_PLUS:
|
|
1499 if (screenFields.getCurrentField() != null
|
|
1500 && screenFields.withinCurrentField(lastPos)
|
|
1501 && !screenFields.isCurrentFieldBypassField()) {
|
|
1502
|
|
1503 resetDirty(lastPos);
|
|
1504
|
|
1505 boolean autoFE = screenFields.isCurrentFieldAutoEnter();
|
|
1506 if (fieldExit()) {
|
|
1507 screenFields.setCurrentFieldMDT();
|
|
1508 if (!screenFields.isCurrentFieldContinued() &&
|
|
1509 !screenFields.isCurrentFieldAutoEnter()) {
|
|
1510 gotoFieldNext();
|
|
1511 } else {
|
|
1512 do {
|
|
1513 gotoFieldNext();
|
|
1514 } while (screenFields.isCurrentFieldContinuedMiddle()
|
|
1515 || screenFields.isCurrentFieldContinuedLast());
|
|
1516 }
|
|
1517 }
|
|
1518 updateDirty();
|
|
1519 simulated = true;
|
|
1520
|
|
1521 if (autoFE)
|
|
1522 sendAid(AID_ENTER);
|
|
1523
|
|
1524 } else {
|
|
1525 displayError(ERR_CURSOR_PROTECTED);
|
|
1526 }
|
|
1527
|
|
1528 break;
|
|
1529 case FIELD_MINUS:
|
|
1530 if (screenFields.getCurrentField() != null
|
|
1531 && screenFields.withinCurrentField(lastPos)
|
|
1532 && !screenFields.isCurrentFieldBypassField()) {
|
|
1533
|
|
1534 int s = screenFields.getCurrentField().getFieldShift();
|
|
1535 if (s == 3 || s == 5 || s == 7) {
|
|
1536 planes.setChar(lastPos, '-');
|
|
1537
|
|
1538 resetDirty(lastPos);
|
|
1539 advancePos();
|
|
1540
|
|
1541 boolean autoFE = screenFields.isCurrentFieldAutoEnter();
|
|
1542
|
|
1543 if (fieldExit()) {
|
|
1544 screenFields.setCurrentFieldMDT();
|
|
1545 if (!screenFields.isCurrentFieldContinued()
|
|
1546 && !screenFields.isCurrentFieldAutoEnter()) {
|
|
1547 gotoFieldNext();
|
|
1548 }
|
|
1549 else {
|
|
1550 do {
|
|
1551 gotoFieldNext();
|
|
1552 }
|
|
1553 while (screenFields.isCurrentFieldContinuedMiddle()
|
|
1554 || screenFields.isCurrentFieldContinuedLast());
|
|
1555 }
|
|
1556 }
|
|
1557 updateDirty();
|
|
1558 simulated = true;
|
|
1559 if (autoFE)
|
|
1560 sendAid(AID_ENTER);
|
|
1561
|
|
1562 }
|
|
1563 else {
|
|
1564 displayError(ERR_FIELD_MINUS);
|
|
1565
|
|
1566 }
|
|
1567 }
|
|
1568 else {
|
|
1569 displayError(ERR_CURSOR_PROTECTED);
|
|
1570 }
|
|
1571
|
|
1572 break;
|
|
1573 case BOF:
|
|
1574 if (screenFields.getCurrentField() != null
|
|
1575 && screenFields.withinCurrentField(lastPos)
|
|
1576 && !screenFields.isCurrentFieldBypassField()) {
|
|
1577 int where = screenFields.getCurrentField().startPos();
|
|
1578 if (where > 0) {
|
|
1579 goto_XY(where);
|
|
1580 }
|
|
1581 simulated = true;
|
|
1582 } else {
|
|
1583 displayError(ERR_CURSOR_PROTECTED);
|
|
1584 }
|
|
1585 resetDirty(lastPos);
|
|
1586
|
|
1587 break;
|
|
1588 case SYSREQ:
|
|
1589 sessionVT.systemRequest();
|
|
1590 simulated = true;
|
|
1591 break;
|
|
1592 case RESET:
|
|
1593 if (isStatusErrorCode()) {
|
|
1594 resetError();
|
|
1595 isInField(lastPos);
|
|
1596 updateDirty();
|
|
1597 } else {
|
|
1598 setPrehelpState(false, oia.isKeyBoardLocked(), false);
|
|
1599 }
|
|
1600 simulated = true;
|
|
1601 break;
|
|
1602 case ATTN:
|
|
1603 sessionVT.sendAttentionKey();
|
|
1604 simulated = true;
|
|
1605 break;
|
|
1606 case DUP_FIELD:
|
|
1607 if (screenFields.getCurrentField() != null
|
|
1608 && screenFields.withinCurrentField(lastPos)
|
|
1609 && !screenFields.isCurrentFieldBypassField()) {
|
|
1610
|
|
1611 if (screenFields.isCurrentFieldDupEnabled()) {
|
|
1612 resetDirty(lastPos);
|
|
1613 screenFields.getCurrentField().setFieldChar(lastPos,
|
|
1614 (char) 0x1C);
|
|
1615 screenFields.setCurrentFieldMDT();
|
|
1616 gotoFieldNext();
|
|
1617 updateDirty();
|
|
1618 simulated = true;
|
|
1619 } else {
|
|
1620 displayError(ERR_DUP_KEY_NOT_ALLOWED);
|
|
1621 }
|
|
1622 } else {
|
|
1623 displayError(ERR_CURSOR_PROTECTED);
|
|
1624 }
|
|
1625
|
|
1626 break;
|
|
1627 case NEW_LINE:
|
|
1628 if (screenFields.getSize() > 0) {
|
|
1629 int startRow = getRow(lastPos) + 1;
|
|
1630 int startPos = lastPos;
|
|
1631
|
|
1632 if (startRow == getRows())
|
|
1633 startRow = 0;
|
|
1634
|
|
1635 setCursor(++startRow, 1);
|
|
1636
|
|
1637 if (!isInField() && screenFields.getCurrentField() != null
|
|
1638 && !screenFields.isCurrentFieldBypassField()) {
|
|
1639 while (!isInField()
|
|
1640 && screenFields.getCurrentField() != null
|
|
1641 && !screenFields.isCurrentFieldBypassField()) {
|
|
1642
|
|
1643 // lets keep going
|
|
1644 advancePos();
|
|
1645
|
|
1646 // Have we looped the screen?
|
|
1647 if (lastPos == startPos) {
|
|
1648 // if so then go back to starting point
|
|
1649 goto_XY(startPos);
|
|
1650 break;
|
|
1651 }
|
|
1652 }
|
|
1653 }
|
|
1654 }
|
|
1655 simulated = true;
|
|
1656 break;
|
|
1657 case FAST_CURSOR_DOWN:
|
|
1658 int rowNow = (getCurrentRow()-1) + 3;
|
|
1659 if (rowNow > getRows()-1)
|
|
1660 rowNow = rowNow - getRows();
|
|
1661 this.goto_XY(getPos(rowNow,getCurrentCol()-1));
|
|
1662 simulated = true;
|
|
1663 break;
|
|
1664 case FAST_CURSOR_UP:
|
|
1665 rowNow = (getCurrentRow()-1) - 3;
|
|
1666 if (rowNow < 0)
|
|
1667 rowNow = (getRows()) + rowNow;
|
|
1668 this.goto_XY(getPos(rowNow,getCurrentCol()-1));
|
|
1669 simulated = true;
|
|
1670 break;
|
|
1671 case FAST_CURSOR_LEFT:
|
|
1672 int colNow = (getCurrentCol()-1) - 3;
|
|
1673 rowNow = getCurrentRow()-1;
|
|
1674 if (colNow <= 0) {
|
|
1675 colNow = getColumns() + colNow;
|
|
1676 rowNow--;
|
|
1677 }
|
|
1678 if (rowNow < 0)
|
|
1679 rowNow = getRows() - 1;
|
|
1680
|
|
1681 process_XY(getPos(rowNow,colNow));
|
|
1682 simulated = true;
|
|
1683 break;
|
|
1684 case FAST_CURSOR_RIGHT:
|
|
1685 colNow = (getCurrentCol()-1) + 3;
|
|
1686 rowNow = getCurrentRow()-1;
|
|
1687 if (colNow >= getColumns()) {
|
|
1688 colNow = colNow - getColumns();
|
|
1689 rowNow++;
|
|
1690 }
|
|
1691 if (rowNow > getRows() - 1)
|
|
1692 rowNow = getRows() - rowNow;
|
|
1693
|
|
1694 process_XY(getPos(rowNow,colNow));
|
|
1695 simulated = true;
|
|
1696 break;
|
|
1697 default:
|
|
1698 log.info(" Mnemonic not supported " + mnem);
|
|
1699 break;
|
|
1700
|
|
1701 }
|
|
1702
|
|
1703 return simulated;
|
|
1704 }
|
|
1705
|
|
1706 protected boolean simulateKeyStroke(char c) {
|
|
1707
|
|
1708 if (isStatusErrorCode() && !Character.isISOControl(c) && !keyProcessed) {
|
|
1709 if (resetRequired) return false;
|
|
1710 resetError();
|
|
1711 }
|
|
1712
|
|
1713 boolean updateField = false;
|
|
1714 boolean numericError = false;
|
|
1715 boolean updatePos = false;
|
|
1716 boolean autoEnter = false;
|
|
1717
|
|
1718 if (!Character.isISOControl(c)) {
|
|
1719
|
|
1720 if (screenFields.getCurrentField() != null
|
|
1721 && screenFields.withinCurrentField(lastPos)
|
|
1722 && !screenFields.isCurrentFieldBypassField()) {
|
|
1723
|
|
1724 if (screenFields.isCurrentFieldFER()
|
|
1725 && !screenFields.withinCurrentField(screenFields
|
|
1726 .getCurrentFieldPos())
|
|
1727 && lastPos == screenFields.getCurrentField().endPos()
|
|
1728 && screenFields.getCurrentFieldPos() > screenFields
|
|
1729 .getCurrentField().endPos()) {
|
|
1730
|
|
1731 displayError(ERR_FIELD_EXIT_INVALID);
|
|
1732 feError = true;
|
|
1733 return false;
|
|
1734 }
|
|
1735
|
|
1736 switch (screenFields.getCurrentFieldShift()) {
|
|
1737 case 0: // Alpha shift
|
|
1738 case 2: // Numeric Shift
|
|
1739 case 4: // Kakana Shift
|
|
1740 updateField = true;
|
|
1741 break;
|
|
1742 case 1: // Alpha Only
|
|
1743 if (Character.isLetter(c) || c == ',' || c == '-'
|
|
1744 || c == '.' || c == ' ')
|
|
1745 updateField = true;
|
|
1746 break;
|
|
1747 case 3: // Numeric only
|
|
1748 if (Character.isDigit(c) || c == '+' || c == ','
|
|
1749 || c == '-' || c == '.' || c == ' ')
|
|
1750 updateField = true;
|
|
1751 else
|
|
1752 numericError = true;
|
|
1753 break;
|
|
1754 case 5: // Digits only
|
|
1755 if (Character.isDigit(c))
|
|
1756 updateField = true;
|
|
1757 else
|
|
1758 displayError(ERR_NUMERIC_09);
|
|
1759 break;
|
|
1760 case 7: // Signed numeric
|
|
1761 if (Character.isDigit(c) || c == '+' || c == '-')
|
|
1762 if (lastPos == screenFields.getCurrentField().endPos()
|
|
1763 && (c != '+' && c != '-'))
|
|
1764 displayError(ERR_INVALID_SIGN);
|
|
1765 else
|
|
1766 updateField = true;
|
|
1767 else
|
|
1768 displayError(ERR_NUMERIC_09);
|
|
1769 break;
|
|
1770 }
|
|
1771
|
|
1772 if (updateField) {
|
|
1773 if (screenFields.isCurrentFieldToUpper())
|
|
1774 c = Character.toUpperCase(c);
|
|
1775
|
|
1776 updatePos = true;
|
|
1777 resetDirty(lastPos);
|
|
1778
|
|
1779 if (oia.isInsertMode()) {
|
|
1780 if (endOfField(false) != screenFields.getCurrentField()
|
|
1781 .endPos())
|
|
1782 shiftRight(lastPos);
|
|
1783 else {
|
|
1784
|
|
1785 displayError(ERR_NO_ROOM_INSERT);
|
|
1786 updatePos = false;
|
|
1787 }
|
|
1788
|
|
1789 }
|
|
1790
|
|
1791 if (updatePos) {
|
|
1792 screenFields.getCurrentField().getKeyPos(
|
|
1793 getRow(lastPos), getCol(lastPos));
|
|
1794 screenFields.getCurrentField().changePos(1);
|
|
1795
|
|
1796 planes.setChar(lastPos,c);
|
|
1797
|
|
1798 screenFields.setCurrentFieldMDT();
|
|
1799
|
|
1800 // if we have gone passed the end of the field then goto
|
|
1801 // the next field
|
|
1802 if (!screenFields.withinCurrentField(screenFields
|
|
1803 .getCurrentFieldPos())) {
|
|
1804 if (screenFields.isCurrentFieldAutoEnter()) {
|
|
1805 autoEnter = true;
|
|
1806 } else if (!screenFields.isCurrentFieldFER())
|
|
1807 gotoFieldNext();
|
|
1808 else {
|
|
1809 // screenFields.getCurrentField().changePos(1);
|
|
1810 //
|
|
1811 // if (screenFields.
|
|
1812 // cursorPos == endPos)
|
|
1813 // System.out.println("end of field");
|
|
1814 //
|
|
1815 // feError != feError;
|
|
1816 // if (feError)
|
|
1817 // displayError(ERR_FIELD_EXIT_INVALID);
|
|
1818 }
|
|
1819
|
|
1820 } else
|
|
1821 setCursor(screenFields.getCurrentField()
|
|
1822 .getCursorRow() + 1, screenFields
|
|
1823 .getCurrentField().getCursorCol() + 1);
|
|
1824
|
|
1825 }
|
|
1826
|
|
1827 fireScreenChanged(1);
|
|
1828
|
|
1829 if (autoEnter)
|
|
1830 sendAid(AID_ENTER);
|
|
1831 } else {
|
|
1832 if (numericError) {
|
|
1833 displayError(ERR_NUMERIC_ONLY);
|
|
1834 }
|
|
1835 }
|
|
1836 } else {
|
|
1837 displayError(ERR_CURSOR_PROTECTED);
|
|
1838 }
|
|
1839
|
|
1840 }
|
|
1841 return updatePos;
|
|
1842 }
|
|
1843
|
|
1844 /**
|
|
1845 * Method: endOfField
|
|
1846 * <p>
|
|
1847 *
|
|
1848 * convenience method that call endOfField with lastRow lastCol and passes
|
|
1849 * the posSpace to that method
|
|
1850 *
|
|
1851 * @param posSpace
|
|
1852 * value of type boolean - specifying to return the position of
|
|
1853 * the the last space or not
|
|
1854 * @return a value of type int - the screen postion (row * columns) + col
|
|
1855 *
|
|
1856 */
|
|
1857 private int endOfField(boolean posSpace) {
|
|
1858 return endOfField(lastPos, posSpace);
|
|
1859 }
|
|
1860
|
|
1861 /**
|
|
1862 * Method: endOfField
|
|
1863 * <p>
|
|
1864 *
|
|
1865 * gets the position of the last character of the current field posSpace
|
|
1866 * parameter tells the routine whether to return the position of the last
|
|
1867 * space ( <= ' ') or the last non space posSpace == true last occurrence of
|
|
1868 * char <= ' ' posSpace == false last occurrence of char > ' '
|
|
1869 *
|
|
1870 * @param pos
|
|
1871 * value of type int - position to start from
|
|
1872 * @param posSpace
|
|
1873 * value of type boolean - specifying to return the position of
|
|
1874 * the the last space or not
|
|
1875 * @return a value of type int - the screen postion (row * columns) + col
|
|
1876 *
|
|
1877 */
|
|
1878 private int endOfField(int pos, boolean posSpace) {
|
|
1879
|
|
1880 int endPos = screenFields.getCurrentField().endPos();
|
|
1881 int fePos = endPos;
|
|
1882 // get the number of characters to the right
|
|
1883 int count = endPos - pos;
|
|
1884
|
|
1885 // first lets get the real ending point without spaces and the such
|
|
1886 while (planes.getChar(endPos) <= ' ' && count-- > 0) {
|
|
1887
|
|
1888 endPos--;
|
|
1889 }
|
|
1890
|
|
1891 if (endPos == fePos) {
|
|
1892
|
|
1893 return endPos;
|
|
1894
|
7
|
1895 }
|
3
|
1896 screenFields.getCurrentField().getKeyPos(endPos);
|
|
1897 if (posSpace) screenFields.getCurrentField().changePos(+1);
|
|
1898 return screenFields.getCurrentFieldPos();
|
|
1899
|
|
1900 }
|
|
1901
|
|
1902 private boolean fieldExit() {
|
|
1903
|
|
1904 int pos = lastPos;
|
|
1905 boolean mdt = false;
|
|
1906 int end = endOfField(false); // get the ending position of the first
|
|
1907 // non blank character in field
|
|
1908
|
|
1909 ScreenField sf = screenFields.getCurrentField();
|
|
1910
|
|
1911 if (sf.isMandatoryEnter() && end == sf.startPos()) {
|
|
1912 displayError(ERR_MANDITORY_ENTER);
|
|
1913 return false;
|
|
1914 }
|
|
1915
|
|
1916 // save off the current pos of the field for checking field exit required
|
|
1917 // positioning. the getKeyPos resets this information so it is useless
|
|
1918 // for comparing if we are positioned passed the end of field.
|
|
1919 // Maybe this should be changed to not update the current cursor position
|
|
1920 // of the field.
|
|
1921 int currentPos = sf.getCurrentPos();
|
|
1922
|
|
1923 // get the number of characters to the right
|
|
1924 int count = (end - sf.startPos()) - sf.getKeyPos(pos);
|
|
1925
|
|
1926 if (count == 0 && sf.isFER()) {
|
|
1927 if (currentPos > sf.endPos()) {
|
|
1928 mdt = true;
|
|
1929 return mdt;
|
|
1930 }
|
|
1931 }
|
|
1932
|
|
1933 for (; count >= 0; count--) {
|
|
1934 planes.setChar(pos, initChar);
|
|
1935 setDirty(pos);
|
|
1936 pos++;
|
|
1937 mdt = true;
|
|
1938 }
|
|
1939
|
|
1940 // This checks for a field minus because a field minus places
|
|
1941 // a negative sign and then advances a position. If it is the
|
|
1942 // end of the field where the minus is placed then this offset will
|
|
1943 // place the count as -1.
|
|
1944 if (count == -1) {
|
|
1945 int s = sf.getFieldShift();
|
|
1946 if (s == 3 || s == 5 || s == 7) {
|
|
1947 mdt = true;
|
|
1948 }
|
|
1949 }
|
|
1950
|
|
1951 int adj = sf.getAdjustment();
|
|
1952
|
|
1953 if (adj != 0) {
|
|
1954
|
|
1955 switch (adj) {
|
|
1956
|
|
1957 case 5:
|
|
1958 rightAdjustField('0');
|
|
1959 sf.setRightAdjusted();
|
|
1960 break;
|
|
1961 case 6:
|
|
1962 rightAdjustField(' ');
|
|
1963 sf.setRightAdjusted();
|
|
1964
|
|
1965 break;
|
|
1966 case 7:
|
|
1967 sf.setManditoryEntered();
|
|
1968 break;
|
|
1969
|
|
1970 }
|
|
1971 }
|
|
1972 else {
|
|
1973
|
|
1974 // we need to right adjust signed numeric fields as well.
|
|
1975 if (sf.isSignedNumeric()) {
|
|
1976 rightAdjustField(' ');
|
|
1977 }
|
|
1978 }
|
|
1979
|
|
1980 return mdt;
|
|
1981 }
|
|
1982
|
|
1983 private void rightAdjustField(char fill) {
|
|
1984
|
|
1985 int end = endOfField(false); // get the ending position of the first
|
|
1986 // non blank character in field
|
|
1987
|
|
1988 // get the number of characters to the right
|
|
1989 int count = screenFields.getCurrentField().endPos() - end;
|
|
1990
|
|
1991 // subtract 1 from count for signed numeric - note for later
|
|
1992 if (screenFields.getCurrentField().isSignedNumeric()) {
|
|
1993 if (planes.getChar(end -1) != '-')
|
|
1994 count--;
|
|
1995 }
|
|
1996
|
|
1997 int pos = screenFields.getCurrentField().startPos();
|
|
1998
|
|
1999 while (count-- >= 0) {
|
|
2000
|
|
2001 shiftRight(pos);
|
|
2002 planes.setChar(pos,fill);
|
|
2003
|
|
2004 setDirty(pos);
|
|
2005
|
|
2006 }
|
|
2007
|
|
2008 }
|
|
2009
|
|
2010 private void shiftLeft(int sPos) {
|
|
2011
|
|
2012 int endPos = 0;
|
|
2013
|
|
2014 int pos = sPos;
|
|
2015 int pPos = sPos;
|
|
2016
|
|
2017 ScreenField sf = screenFields.getCurrentField();
|
|
2018 int end;
|
|
2019 int count;
|
|
2020 do {
|
|
2021 end = endOfField(pPos, false); // get the ending position of the
|
|
2022 // first
|
|
2023 // non blank character in field
|
|
2024
|
|
2025 count = (end - screenFields.getCurrentField().startPos())
|
|
2026 - screenFields.getCurrentField().getKeyPos(pPos);
|
|
2027
|
|
2028 // now we loop through and shift the remaining characters to the
|
|
2029 // left
|
|
2030 while (count-- > 0) {
|
|
2031 pos++;
|
|
2032 planes.setChar(pPos,planes.getChar(pos));
|
|
2033 setDirty(pPos);
|
|
2034 pPos = pos;
|
|
2035
|
|
2036 }
|
|
2037
|
|
2038 if (screenFields.isCurrentFieldContinued()) {
|
|
2039 gotoFieldNext();
|
|
2040 if (screenFields.getCurrentField().isContinuedFirst())
|
|
2041 break;
|
|
2042
|
|
2043 pos = screenFields.getCurrentField().startPos();
|
|
2044 planes.setChar(pPos,planes.getChar(pos));
|
|
2045 setDirty(pPos);
|
|
2046
|
|
2047 pPos = pos;
|
|
2048
|
|
2049 }
|
|
2050 } while (screenFields.isCurrentFieldContinued()
|
|
2051 && !screenFields.getCurrentField().isContinuedFirst());
|
|
2052
|
|
2053 if (end >= 0 && count >= -1) {
|
|
2054
|
|
2055 endPos = end;
|
|
2056 } else {
|
|
2057 endPos = sPos;
|
|
2058
|
|
2059 }
|
|
2060
|
|
2061 screenFields.setCurrentField(sf);
|
|
2062 planes.setChar(endPos,initChar);
|
|
2063 setDirty(endPos);
|
|
2064 goto_XY(screenFields.getCurrentFieldPos());
|
|
2065 sf = null;
|
|
2066
|
|
2067 }
|
|
2068
|
|
2069 private void shiftRight(int sPos) {
|
|
2070
|
|
2071 int end = endOfField(true); // get the ending position of the first
|
|
2072 // non blank character in field
|
|
2073 int pos = end;
|
|
2074 int pPos = end;
|
|
2075
|
|
2076 int count = end - sPos;
|
|
2077
|
|
2078 // now we loop through and shift the remaining characters to the right
|
|
2079 while (count-- > 0) {
|
|
2080
|
|
2081 pos--;
|
|
2082 planes.setChar(pPos, planes.getChar(pos));
|
|
2083 setDirty(pPos);
|
|
2084
|
|
2085 pPos = pos;
|
|
2086 }
|
|
2087 }
|
|
2088
|
|
2089 public int getRow(int pos) {
|
|
2090
|
|
2091 // if (pos == 0)
|
|
2092 // return 1;
|
|
2093
|
|
2094 int row = pos / numCols;
|
|
2095
|
|
2096 if (row < 0) {
|
|
2097
|
|
2098 row = lastPos / numCols;
|
|
2099 }
|
|
2100 if (row > (lenScreen / numCols) - 1)
|
|
2101 row = (lenScreen / numCols) - 1;
|
|
2102
|
|
2103 return row;
|
|
2104
|
|
2105 }
|
|
2106
|
|
2107 public int getCol(int pos) {
|
|
2108 int col = pos % (getColumns());
|
|
2109 if (col > 0) return col;
|
|
2110 return 0;
|
|
2111 }
|
|
2112
|
|
2113 /**
|
|
2114 * This routine is 0 based offset. So to get row 20,1 then pass row 19,0
|
|
2115 *
|
|
2116 * @param row
|
|
2117 * @param col
|
|
2118 * @return
|
|
2119 */
|
|
2120 public int getPos(int row, int col) {
|
|
2121
|
|
2122 return (row * numCols) + col;
|
|
2123 }
|
|
2124
|
|
2125 /**
|
|
2126 * Current position is based on offsets of 1,1 not 0,0 of the current
|
|
2127 * position of the screen
|
|
2128 *
|
|
2129 * @return int
|
|
2130 */
|
|
2131 public int getCurrentPos() {
|
|
2132
|
|
2133 // return lastPos + numCols + 1;
|
|
2134 return lastPos + 1;
|
|
2135
|
|
2136 }
|
|
2137
|
|
2138 /**
|
|
2139 * I got this information from a tcp trace of each error. I could not find
|
|
2140 * any documenation for this. Maybe there is but I could not find it. If
|
|
2141 * anybody finds this documention could you please send me a copy. Please
|
|
2142 * note that I did not look that hard either.
|
|
2143 * <p>
|
|
2144 * 0000: 00 50 73 1D 89 81 00 50 DA 44 C8 45 08 00 45 00 .Ps....P.D.E..E.
|
|
2145 * </p>
|
|
2146 * <p>
|
|
2147 * 0010: 00 36 E9 1C 40 00 80 06 9B F9 C1 A8 33 58 C0 A8 .6..@...k....3X..
|
|
2148 * </p>
|
|
2149 * <p>
|
|
2150 * 0020: C0 02 06 0E 00 17 00 52 6E 88 73 40 DE CB 50 18 .......Rn.s@..P.
|
|
2151 * </p>
|
|
2152 * <p>
|
|
2153 * 0030: 20 12 3C 53 00 00 00 0C 12 A0 00 00 04 01 00 00 . <S............
|
|
2154 * </p>
|
|
2155 * <p>
|
|
2156 * 0040: 00 05 FF EF .... ----------|| The 00 XX is the code to be sent. I
|
|
2157 * found the following <table BORDER COLS=2 WIDTH="50%" >
|
|
2158 * <tr>
|
|
2159 * <td>ERR_CURSOR_PROTECTED</td>
|
|
2160 * <td>0x05</td>
|
|
2161 * </tr>
|
|
2162 * <tr>
|
|
2163 * <td>ERR_INVALID_SIGN</td>
|
|
2164 * <td>0x11</td>
|
|
2165 * </tr>
|
|
2166 * <tr>
|
|
2167 * <td>ERR_NO_ROOM_INSERT</td>
|
|
2168 * <td>0x12</td>
|
|
2169 * </tr>
|
|
2170 * <tr>
|
|
2171 * <td>ERR_NUMERIC_ONLY</td>
|
|
2172 * <td>0x09</td>
|
|
2173 * </tr>
|
|
2174 * <tr>
|
|
2175 * <td>ERR_NUMERIC_09</td>
|
|
2176 * <td>0x10</td>
|
|
2177 * </tr>
|
|
2178 * <tr>
|
|
2179 * <td>ERR_FIELD_MINUS</td>
|
|
2180 * <td>0x16</td>
|
|
2181 * </tr>
|
|
2182 * <tr>
|
|
2183 * <td>ERR_ENTER_NOT_ALLOWED</td>
|
|
2184 * <td>0x20</td>
|
|
2185 * </tr>
|
|
2186 * <tr>
|
|
2187 * <td>ERR_MANDITORY_ENTER</td>
|
|
2188 * <td>0x21</td>
|
|
2189 * </tr>
|
|
2190 * <tr>
|
|
2191 * <td>ERR_ENTER_NOT_ALLOWED</td>
|
|
2192 * <td>0x20</td>
|
|
2193 * </tr>
|
|
2194 * </table> I am tired of typing and they should be self explanitory. Finding
|
|
2195 * them in the first place was the pain.
|
|
2196 * </p>
|
|
2197 *
|
|
2198 * @param ec error code
|
|
2199 */
|
|
2200 private void displayError(int ec) {
|
|
2201 saveHomePos = homePos;
|
|
2202 homePos = lastPos + numCols + 1;
|
|
2203 pendingInsert = true;
|
|
2204 sessionVT.sendNegResponse2(ec);
|
|
2205
|
|
2206 }
|
|
2207
|
|
2208 private void process_XY(int pos) {
|
|
2209
|
|
2210 if (pos < 0)
|
|
2211 pos = lenScreen + pos;
|
|
2212 if (pos > lenScreen - 1)
|
|
2213 pos = pos - lenScreen;
|
|
2214
|
|
2215 // if there was a field exit error then we need to treat the movement
|
|
2216 // of the cursor in a special way that equals that of Client Access.
|
|
2217 // If the cursor is moved from the field then we need to reset the
|
|
2218 // position within the field so that the last character can be typed
|
|
2219 // over again instead of sending the field exit error again.
|
|
2220 // We also need to reset the field exit error flag.
|
|
2221 //
|
|
2222 // How we know we have a field exit error is when the field position is
|
|
2223 // set beyond the end of the field and a character is then typed we can
|
|
2224 // not position that character. To reset this we need to set the next
|
|
2225 // position of the field to not be beyond the end of field but to the
|
|
2226 // last character.
|
|
2227 //
|
|
2228 // Now to make it work like Client Access if the cursor is a back space
|
|
2229 // then do not move the cursor but place it on the last field. All
|
|
2230 // other keys will reset the field position so that entering over the
|
|
2231 // last character will not cause an error but replace that character or
|
|
2232 // just plain move the cursor if the key was to do that.
|
|
2233
|
|
2234 ScreenField sf = screenFields.getCurrentField();
|
|
2235 if (feError) {
|
|
2236 feError = false;
|
|
2237 sf.changePos(-1);
|
|
2238 } else {
|
|
2239 if (sf != null&& sf.isFER()){
|
|
2240 if ((sf.getCurrentPos()
|
|
2241 > sf.endPos())) {
|
|
2242 if (sf.withinField(pos)) {
|
|
2243 sf.getKeyPos(pos);
|
|
2244 return;
|
|
2245 }
|
|
2246 sf.getKeyPos(sf.endPos());
|
|
2247 }
|
|
2248 }
|
|
2249
|
|
2250 goto_XY(pos);
|
|
2251 }
|
|
2252 }
|
|
2253
|
|
2254 public boolean isUsingGuiInterface() {
|
|
2255
|
|
2256 return guiInterface;
|
|
2257 }
|
|
2258
|
|
2259 /**
|
|
2260 * Convinience class to return if the cursor is in a field or not.
|
|
2261 *
|
|
2262 * @return true or false
|
|
2263 */
|
|
2264
|
|
2265 protected boolean isInField() {
|
|
2266
|
|
2267 return isInField(lastPos, true);
|
|
2268 }
|
|
2269
|
|
2270 /**
|
|
2271 *
|
|
2272 * Convinience class to return if the position that is passed is in a field
|
|
2273 * or not. If it is then the chgToField parameter will change the current
|
|
2274 * field to this field where the position indicates
|
|
2275 *
|
|
2276 * @param pos
|
|
2277 * @param chgToField
|
|
2278 * @return true or false
|
|
2279 */
|
|
2280 public boolean isInField(int pos, boolean chgToField) {
|
|
2281
|
|
2282 return screenFields.isInField(pos, chgToField);
|
|
2283 }
|
|
2284
|
|
2285 /**
|
|
2286 *
|
|
2287 * Convinience class to return if the position that is passed is in a field
|
|
2288 * or not. If it is then the field at this position becomes the current
|
|
2289 * working field
|
|
2290 *
|
|
2291 * @param pos
|
|
2292 * @return true or false
|
|
2293 */
|
|
2294 public boolean isInField(int pos) {
|
|
2295
|
|
2296 return screenFields.isInField(pos, true);
|
|
2297 }
|
|
2298
|
|
2299 /**
|
|
2300 * Convinience class to return if the position at row and column that is
|
|
2301 * passed is in a field or not. If it is then the field at this position
|
|
2302 * becomes the current working field.
|
|
2303 *
|
|
2304 * @param row
|
|
2305 * @param col
|
|
2306 * @return true or false
|
|
2307 */
|
|
2308 public boolean isInField(int row, int col) {
|
|
2309
|
|
2310 return isInField(row, col, true);
|
|
2311 }
|
|
2312
|
|
2313 /**
|
|
2314 *
|
|
2315 * Convinience class to return if the position at row and column that is
|
|
2316 * passed is in a field or not. If it is then the chgToField parameter will
|
|
2317 * change the current field to this field where the row and column
|
|
2318 * indicates.
|
|
2319 *
|
|
2320 * @param row
|
|
2321 * @param col
|
|
2322 * @param chgToField
|
|
2323 * @return true or false
|
|
2324 */
|
|
2325 public boolean isInField(int row, int col, boolean chgToField) {
|
|
2326 return screenFields.isInField((row * numCols) + col, chgToField);
|
|
2327 }
|
|
2328
|
|
2329 /**
|
|
2330 * Gets the length of the screen - number of rows times number of columns
|
|
2331 *
|
|
2332 * @return int value of screen length
|
|
2333 */
|
|
2334 public int getScreenLength() {
|
|
2335
|
|
2336 return lenScreen;
|
|
2337 }
|
|
2338
|
|
2339 /**
|
|
2340 * Get the number or rows available.
|
|
2341 *
|
|
2342 * @return number of rows
|
|
2343 */
|
|
2344 public int getRows() {
|
|
2345
|
|
2346 return numRows;
|
|
2347
|
|
2348 }
|
|
2349
|
|
2350 /**
|
|
2351 * Get the number of columns available.
|
|
2352 *
|
|
2353 * @return number of columns
|
|
2354 */
|
|
2355 public int getColumns() {
|
|
2356
|
|
2357 return numCols;
|
|
2358
|
|
2359 }
|
|
2360
|
|
2361 /**
|
|
2362 * Get the current row where the cursor is
|
|
2363 *
|
|
2364 * @return the cursor current row position 1,1 based
|
|
2365 */
|
|
2366 public int getCurrentRow() {
|
|
2367
|
|
2368 return (lastPos / numCols) + 1;
|
|
2369
|
|
2370 }
|
|
2371
|
|
2372 /**
|
|
2373 * Get the current column where the cursor is
|
|
2374 *
|
|
2375 * @return the cursor current column position 1,1 based
|
|
2376 */
|
|
2377 public int getCurrentCol() {
|
|
2378
|
|
2379 return (lastPos % numCols) + 1;
|
|
2380
|
|
2381 }
|
|
2382
|
|
2383 /**
|
|
2384 * The last position of the cursor on the screen - Note - position is based
|
|
2385 * 0,0
|
|
2386 *
|
|
2387 * @return last position
|
|
2388 */
|
|
2389 protected int getLastPos() {
|
|
2390
|
|
2391 return lastPos;
|
|
2392
|
|
2393 }
|
|
2394
|
|
2395 /**
|
|
2396 * Hotspot More... string
|
|
2397 *
|
|
2398 * @return string literal of More...
|
|
2399 */
|
|
2400 public StringBuffer getHSMore() {
|
|
2401 return hsMore;
|
|
2402 }
|
|
2403
|
|
2404 /**
|
|
2405 * Hotspot Bottom string
|
|
2406 *
|
|
2407 * @return string literal of Bottom
|
|
2408 */
|
|
2409 public StringBuffer getHSBottom() {
|
|
2410 return hsBottom;
|
|
2411 }
|
|
2412
|
|
2413 /**
|
|
2414 * Return the whole screen represented as a character array
|
|
2415 *
|
|
2416 * @return character array containing the text
|
|
2417 *
|
|
2418 * Added by Luc - LDC
|
|
2419 *
|
|
2420 * Note to KJP - Have to ask what the difference is between this method and
|
|
2421 * the other
|
|
2422 */
|
|
2423 public char[] getScreenAsAllChars() {
|
|
2424 char[] sac = new char[lenScreen];
|
|
2425 char c;
|
|
2426
|
|
2427 for (int x = 0; x < lenScreen; x++) {
|
|
2428 c = planes.getChar(x);
|
|
2429 // only draw printable characters (in this case >= ' ')
|
|
2430 if ((c >= ' ') && (!planes.isAttributePlace(x))) {
|
|
2431 sac[x] = c;
|
|
2432 // TODO: implement the underline check here
|
|
2433 // if (screen[x].underLine && c <= ' ')
|
|
2434 // sac[x] = '_';
|
|
2435 } else
|
|
2436 sac[x] = ' ';
|
|
2437 }
|
|
2438
|
|
2439 return sac;
|
|
2440 }
|
|
2441
|
|
2442 /**
|
|
2443 *
|
|
2444 * Return the screen represented as a character array
|
|
2445 *
|
|
2446 * @return character array containing the text
|
|
2447 */
|
|
2448 public char[] getScreenAsChars() {
|
|
2449 char[] sac = new char[lenScreen];
|
|
2450 char c;
|
|
2451
|
|
2452 for (int x = 0; x < lenScreen; x++) {
|
|
2453 c = planes.getChar(x);
|
|
2454 // only draw printable characters (in this case >= ' ')
|
|
2455 if ((c >= ' ') && (!planes.isAttributePlace(x))) {
|
|
2456 sac[x] = c;
|
|
2457 // TODO: implement the underline check here
|
|
2458 // if (screen[x].underLine && c <= ' ')
|
|
2459 // sac[x] = '_';
|
|
2460 } else
|
|
2461 sac[x] = ' ';
|
|
2462 }
|
|
2463
|
|
2464 return sac;
|
|
2465 }
|
|
2466
|
|
2467 public char[] getData(int startRow, int startCol, int endRow, int endCol, int plane) {
|
|
2468 try {
|
|
2469 int from = getPos(startRow,startCol);
|
|
2470 int to = getPos(endRow,endCol);
|
|
2471 if (from > to) {
|
|
2472
|
|
2473 int f = from;
|
|
2474 to = f;
|
|
2475 from = f;
|
|
2476 }
|
|
2477 return planes.getPlaneData(from,to,plane);
|
|
2478 }
|
|
2479 catch (Exception oe) {
|
|
2480 return null;
|
|
2481 }
|
|
2482
|
|
2483 }
|
|
2484
|
|
2485 /**
|
|
2486 * <p>
|
|
2487 * GetScreen retrieves the various planes associated with the presentation
|
|
2488 * space. The data is returned as a linear array of character values in the
|
|
2489 * array provided. The array is not terminated by a null character except
|
|
2490 * when data is retrieved from the text plane, in which case a single null
|
|
2491 * character is appended.
|
|
2492 * </p>
|
|
2493 * <p>
|
|
2494 * The application must supply a buffer for the returned data and the length
|
|
2495 * of the buffer. Data is returned starting from the beginning of the
|
|
2496 * presentation space and continuing until the buffer is full or the entire
|
|
2497 * plane has been copied. For text plane data, the buffer must include one
|
|
2498 * extra position for the terminating null character.
|
|
2499 * <p>
|
|
2500 *
|
|
2501 * @param buffer
|
|
2502 * @param bufferLength
|
|
2503 * @param plane
|
|
2504 * @return The number of characters copied to the buffer
|
|
2505 * @throws OhioException
|
|
2506 */
|
|
2507 public synchronized int GetScreen(char buffer[], int bufferLength, int plane)
|
|
2508 // throws OhioException {
|
|
2509 {
|
|
2510 return GetScreen(buffer,bufferLength,0,lenScreen,plane);
|
|
2511
|
|
2512 }
|
|
2513
|
|
2514 /**
|
|
2515 * <p>
|
|
2516 * GetScreen retrieves the various planes associated with the presentation
|
|
2517 * space. The data is returned as a linear array of character values in the
|
|
2518 * array provided. The array is not terminated by a null character except
|
|
2519 * when data is retrieved from the text plane, in which case a single null
|
|
2520 * character is appended.
|
|
2521 * </p>
|
|
2522 * <p>
|
|
2523 * The application must supply a buffer for the returned data and the length
|
|
2524 * of the buffer. Data is returned starting from the given position and
|
|
2525 * continuing until the specified number of characters have been copied, the
|
|
2526 * buffer is full or the entire plane has been copied. For text plane data,
|
|
2527 * the buffer must include one extra position for the terminating null character.
|
|
2528 * </p>
|
|
2529 *
|
|
2530 * @param buffer
|
|
2531 * @param bufferLength
|
|
2532 * @param from
|
|
2533 * @param length
|
|
2534 * @param plane
|
|
2535 * @return The number of characters copied to the buffer
|
|
2536 * @throws OhioException
|
|
2537 */
|
|
2538 public synchronized int GetScreen(char buffer[], int bufferLength, int from,
|
|
2539 int length, int plane)
|
|
2540 // throws OhioException {
|
|
2541 {
|
|
2542
|
|
2543 return planes.GetScreen(buffer,bufferLength, from, length, plane);
|
|
2544 }
|
|
2545
|
|
2546 /**
|
|
2547 * <p>
|
|
2548 * GetScreen retrieves the various planes associated with the presentation
|
|
2549 * space. The data is returned as a linear array of character values in the
|
|
2550 * array provided. The array is not terminated by a null character except
|
|
2551 * when data is retrieved from the text plane, in which case a single null
|
|
2552 * character is appended.
|
|
2553 * </p>
|
|
2554 * <p>
|
|
2555 * The application must supply a buffer for the returned data and the length
|
|
2556 * of the buffer. Data is returned starting from the given coordinates and
|
|
2557 * continuing until the specified number of characters have been copied,
|
|
2558 * the buffer is full, or the entire plane has been copied. For text plane
|
|
2559 * data, the buffer must include one extra position for the terminating null
|
|
2560 * character.
|
|
2561 * </p>
|
|
2562 *
|
|
2563 * @param buffer
|
|
2564 * @param bufferLength
|
|
2565 * @param row
|
|
2566 * @param col
|
|
2567 * @param length
|
|
2568 * @param plane
|
|
2569 * @return The number of characters copied to the buffer.
|
|
2570 * @throws OhioException
|
|
2571 */
|
|
2572 public synchronized int GetScreen(char buffer[], int bufferLength, int row,
|
|
2573 int col, int length, int plane)
|
|
2574 // throws OhioException {
|
|
2575 {
|
|
2576 // Call GetScreen function after converting row and column to
|
|
2577 // a position.
|
|
2578 return planes.GetScreen(buffer,bufferLength, row, col, length, plane);
|
|
2579 }
|
|
2580
|
|
2581 /**
|
|
2582 * <p>
|
|
2583 * GetScreenRect retrieves data from the various planes associated with the
|
|
2584 * presentation space. The data is returned as a linear array of character
|
|
2585 * values in the buffer provided.
|
|
2586 * </p>
|
|
2587 *
|
|
2588 * <p>
|
|
2589 * The application supplies two positions that represent opposing corners of
|
|
2590 * a rectangle within the presentation space. The starting and ending
|
|
2591 * positions can have any spatial relationship to each other. The data
|
|
2592 * returned starts from the row containing the upper-most point to the row
|
|
2593 * containing the lower-most point, and from the left-most column to the
|
|
2594 * right-most column.
|
|
2595 * </p>
|
|
2596 * <p>
|
|
2597 * The specified buffer must be at least large enough to contain the number
|
|
2598 * of characters in the rectangle. If the buffer is too small, no data is
|
|
2599 * copied and zero is returned by the method. Otherwise, the method returns
|
|
2600 * the number of characters copied.
|
|
2601 * </p>
|
|
2602 *
|
|
2603 * @param buffer
|
|
2604 * @param bufferLength
|
|
2605 * @param startPos
|
|
2606 * @param endPos
|
|
2607 * @param plane
|
|
2608 * @return The number of characters copied to the buffer
|
|
2609 * @throws OhioException
|
|
2610 */
|
|
2611 public synchronized int GetScreenRect(char buffer[], int bufferLength,
|
|
2612 int startPos, int endPos, int plane)
|
|
2613 // throws OhioException {
|
|
2614 {
|
|
2615 return planes.GetScreenRect(buffer, bufferLength, startPos, endPos, plane);
|
|
2616
|
|
2617 }
|
|
2618
|
|
2619 /**
|
|
2620 * <p>
|
|
2621 * GetScreenRect retrieves data from the various planes associated with the
|
|
2622 * presentation space. The data is returned as a linear array of character
|
|
2623 * values in the buffer provided. The buffer is not terminated by a null
|
|
2624 * character.
|
|
2625 * </p>
|
|
2626 * <p>
|
|
2627 * The application supplies two coordinates that represent opposing corners
|
|
2628 * of a rectangle within the presentation space. The starting and ending
|
|
2629 * coordinates can have any spatial relationship to each other. The data
|
|
2630 * returned starts from the row containing the upper-most point to the row
|
|
2631 * containing the lower-most point, and from the left-most column to the
|
|
2632 * right-most column.
|
|
2633 * </p>
|
|
2634 * <p>
|
|
2635 * The specified buffer must be at least large enough to contain the number
|
|
2636 * of characters in the rectangle. If the buffer is too small, no data is
|
|
2637 * copied and zero is returned by the method. Otherwise, the method returns
|
|
2638 * the number of characters copied.
|
|
2639 * </p>
|
|
2640 *
|
|
2641 * @param buffer
|
|
2642 * @param bufferLength
|
|
2643 * @param startRow
|
|
2644 * @param startCol
|
|
2645 * @param endRow
|
|
2646 * @param endCol
|
|
2647 * @param plane
|
|
2648 * @return The number characters copied to the buffer
|
|
2649 * @throws OhioException
|
|
2650 */
|
|
2651 public synchronized int GetScreenRect(char buffer[], int bufferLength,
|
|
2652 int startRow, int startCol,
|
|
2653 int endRow, int endCol, int plane)
|
|
2654 // throws OhioException {
|
|
2655 {
|
|
2656
|
|
2657 return planes.GetScreenRect(buffer, bufferLength, startRow, startCol, endRow,
|
|
2658 endCol, plane);
|
|
2659 }
|
|
2660
|
|
2661 public synchronized boolean[] getActiveAidKeys() {
|
|
2662 return sessionVT.getActiveAidKeys();
|
|
2663 }
|
|
2664
|
|
2665 protected synchronized void setScreenData(String text, int location) {
|
|
2666 // throws OhioException {
|
|
2667
|
|
2668 if (location < 0 || location > lenScreen) {
|
|
2669 return;
|
|
2670 // throw new OhioException(sessionVT.getSessionConfiguration(),
|
|
2671 // OhioScreen5250.class.getName(), "osohio.screen.ohio00300", 1);
|
|
2672 }
|
|
2673
|
|
2674 int pos = location;
|
|
2675
|
|
2676 int l = text.length();
|
|
2677 boolean updated = false;
|
|
2678 boolean flag = false;
|
|
2679 int x =0;
|
|
2680 for (; x < l; x++) {
|
|
2681 if (isInField(pos + x,true)) {
|
|
2682 if (!screenFields.getCurrentField().isBypassField()) {
|
|
2683 if (!flag) {
|
|
2684 screenFields.getCurrentField().setMDT();
|
|
2685 updated = true;
|
|
2686 resetDirty(pos + x);
|
|
2687 screenFields.setMasterMDT();
|
|
2688 flag = true;
|
|
2689 }
|
|
2690
|
|
2691 planes.screen[pos + x] = text.charAt(x);
|
|
2692 setDirty(pos + x);
|
|
2693 }
|
|
2694 }
|
|
2695
|
|
2696 }
|
|
2697 lastPos = pos + x;
|
|
2698 if (updated) {
|
|
2699 fireScreenChanged(1);
|
|
2700 }
|
|
2701
|
|
2702 }
|
|
2703
|
|
2704 /**
|
|
2705 * This routine is based on offset 1,1 not 0,0 it will translate to offset
|
|
2706 * 0,0 and call the goto_XY(int pos) it is mostly used from external classes
|
|
2707 * that use the 1,1 offset
|
|
2708 *
|
|
2709 * @param row
|
|
2710 * @param col
|
|
2711 */
|
|
2712 public void setCursor(int row, int col) {
|
|
2713 goto_XY(((row - 1) * numCols) + (col - 1));
|
|
2714 }
|
|
2715
|
|
2716 // this routine is based on offset 0,0 not 1,1
|
|
2717 protected void goto_XY(int pos) {
|
|
2718 // setCursorOff();
|
|
2719 updateCursorLoc();
|
|
2720 lastPos = pos;
|
|
2721 // setCursorOn();
|
|
2722 updateCursorLoc();
|
|
2723 }
|
|
2724
|
|
2725 /**
|
|
2726 * Set the current working field to the field number specified.
|
|
2727 *
|
|
2728 * @param f -
|
|
2729 * numeric field number on the screen
|
|
2730 * @return true or false whether it was sucessful
|
|
2731 */
|
|
2732 public boolean gotoField(int f) {
|
|
2733
|
|
2734 int sizeFields = screenFields.getSize();
|
|
2735
|
|
2736 if (f > sizeFields || f <= 0)
|
|
2737 return false;
|
|
2738
|
|
2739 screenFields.setCurrentField(screenFields.getField(f - 1));
|
|
2740
|
|
2741 while (screenFields.isCurrentFieldBypassField() && f < sizeFields) {
|
|
2742
|
|
2743 screenFields.setCurrentField(screenFields.getField(f++));
|
|
2744
|
|
2745 }
|
|
2746 return gotoField(screenFields.getCurrentField());
|
|
2747 }
|
|
2748
|
|
2749 /**
|
|
2750 * Convenience method to set the field object passed as the currect working
|
|
2751 * screen field
|
|
2752 *
|
|
2753 * @param f
|
|
2754 * @return true or false whether it was sucessful
|
|
2755 * @see org.tn5250j.ScreenField
|
|
2756 */
|
|
2757 protected boolean gotoField(ScreenField f) {
|
|
2758 if (f != null) {
|
|
2759 goto_XY(f.startPos());
|
|
2760 return true;
|
|
2761 }
|
|
2762 return false;
|
|
2763 }
|
|
2764
|
|
2765 /**
|
|
2766 * Convenience class to position the cursor to the next word on the screen
|
|
2767 *
|
|
2768 */
|
|
2769 private void gotoNextWord() {
|
|
2770
|
|
2771 int pos = lastPos;
|
|
2772
|
|
2773 if (planes.getChar(lastPos) > ' ') {
|
|
2774 advancePos();
|
|
2775 // get the next space character
|
|
2776 while (planes.getChar(lastPos) > ' ' && pos != lastPos) {
|
|
2777 advancePos();
|
|
2778 }
|
|
2779 } else
|
|
2780 advancePos();
|
|
2781
|
|
2782 // now that we are positioned on the next space character get the
|
|
2783 // next none space character
|
|
2784 while (planes.getChar(lastPos) <= ' ' && pos != lastPos) {
|
|
2785 advancePos();
|
|
2786 }
|
|
2787
|
|
2788 }
|
|
2789
|
|
2790 /**
|
|
2791 * Convenience class to position the cursor to the previous word on the
|
|
2792 * screen
|
|
2793 *
|
|
2794 */
|
|
2795 private void gotoPrevWord() {
|
|
2796
|
|
2797 int pos = lastPos;
|
|
2798
|
|
2799 changePos(-1);
|
|
2800
|
|
2801 // position previous white space character
|
|
2802 while (planes.getChar(lastPos) <= ' ') {
|
|
2803 changePos(-1);
|
|
2804 if (pos == lastPos)
|
|
2805 break;
|
|
2806 }
|
|
2807
|
|
2808 changePos(-1);
|
|
2809 // get the previous space character
|
|
2810 while (planes.getChar(lastPos) > ' ' && pos != lastPos) {
|
|
2811 changePos(-1);
|
|
2812 }
|
|
2813
|
|
2814 // and position one position more should give us the beginning of word
|
|
2815 advancePos();
|
|
2816
|
|
2817 }
|
|
2818
|
|
2819 /**
|
|
2820 * Convinience class to position to the next field on the screen.
|
|
2821 *
|
|
2822 * @see org.tn5250j.ScreenFields
|
|
2823 */
|
|
2824 private void gotoFieldNext() {
|
|
2825
|
|
2826 if (screenFields.isCurrentFieldHighlightedEntry())
|
|
2827 unsetFieldHighlighted(screenFields.getCurrentField());
|
|
2828
|
|
2829 screenFields.gotoFieldNext();
|
|
2830
|
|
2831 if (screenFields.isCurrentFieldHighlightedEntry())
|
|
2832 setFieldHighlighted(screenFields.getCurrentField());
|
|
2833 }
|
|
2834
|
|
2835 /**
|
|
2836 * Convinience class to position to the previous field on the screen.
|
|
2837 *
|
|
2838 * @see org.tn5250j.ScreenFields
|
|
2839 */
|
|
2840 private void gotoFieldPrev() {
|
|
2841
|
|
2842 if (screenFields.isCurrentFieldHighlightedEntry())
|
|
2843 unsetFieldHighlighted(screenFields.getCurrentField());
|
|
2844
|
|
2845 screenFields.gotoFieldPrev();
|
|
2846
|
|
2847 if (screenFields.isCurrentFieldHighlightedEntry())
|
|
2848 setFieldHighlighted(screenFields.getCurrentField());
|
|
2849
|
|
2850 }
|
|
2851
|
|
2852 /* *** NEVER USED LOCALLY ************************************************** */
|
|
2853 // /**
|
|
2854 // * Used to restrict the cursor to a particular position on the screen. Used
|
|
2855 // * in combination with windows to restrict the cursor to the active window
|
|
2856 // * show on the screen.
|
|
2857 // *
|
|
2858 // * Not supported yet. Please implement me :-(
|
|
2859 // *
|
|
2860 // * @param depth
|
|
2861 // * @param width
|
|
2862 // */
|
|
2863 // protected void setRestrictCursor(int depth, int width) {
|
|
2864 //
|
|
2865 // restrictCursor = true;
|
|
2866 // // restriction
|
|
2867 //
|
|
2868 // }
|
|
2869
|
|
2870 /**
|
|
2871 * Creates a window on the screen
|
|
2872 *
|
|
2873 * @param depth
|
|
2874 * @param width
|
|
2875 * @param type
|
|
2876 * @param gui
|
|
2877 * @param monoAttr
|
|
2878 * @param colorAttr
|
|
2879 * @param ul
|
|
2880 * @param upper
|
|
2881 * @param ur
|
|
2882 * @param left
|
|
2883 * @param right
|
|
2884 * @param ll
|
|
2885 * @param bottom
|
|
2886 * @param lr
|
|
2887 */
|
|
2888 protected void createWindow(int depth, int width, int type, boolean gui,
|
|
2889 int monoAttr, int colorAttr, int ul, int upper, int ur, int left,
|
|
2890 int right, int ll, int bottom, int lr) {
|
|
2891
|
|
2892 int c = getCol(lastPos);
|
|
2893 int w = 0;
|
|
2894 width++;
|
|
2895
|
|
2896 w = width;
|
|
2897 // set leading attribute byte
|
|
2898 // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
|
|
2899 planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true);
|
|
2900 setDirty(lastPos);
|
|
2901
|
|
2902 advancePos();
|
|
2903 // set upper left
|
|
2904 // screen[lastPos].setCharAndAttr((char) ul, colorAttr, false);
|
|
2905 planes.setScreenCharAndAttr(lastPos, (char) ul, colorAttr, false);
|
|
2906 if (gui) {
|
|
2907 // screen[lastPos].setUseGUI(UPPER_LEFT);
|
|
2908 planes.setUseGUI(lastPos, UPPER_LEFT);
|
|
2909 }
|
|
2910 setDirty(lastPos);
|
|
2911
|
|
2912 advancePos();
|
|
2913
|
|
2914 // draw top row
|
|
2915
|
|
2916 while (w-- >= 0) {
|
|
2917 // screen[lastPos].setCharAndAttr((char) upper, colorAttr, false);
|
|
2918 planes.setScreenCharAndAttr(lastPos, (char) upper, colorAttr, false);
|
|
2919 if (gui) {
|
|
2920 // screen[lastPos].setUseGUI(UPPER);
|
|
2921 planes.setUseGUI(lastPos,UPPER);
|
|
2922 }
|
|
2923 setDirty(lastPos);
|
|
2924 advancePos();
|
|
2925 }
|
|
2926
|
|
2927 // set upper right
|
|
2928 // screen[lastPos].setCharAndAttr((char) ur, colorAttr, false);
|
|
2929 planes.setScreenCharAndAttr(lastPos,(char) ur, colorAttr, false);
|
|
2930
|
|
2931 if (gui) {
|
|
2932 // screen[lastPos].setUseGUI(UPPER_RIGHT);
|
|
2933 planes.setUseGUI(lastPos, UPPER_RIGHT);
|
|
2934 }
|
|
2935 setDirty(lastPos);
|
|
2936 advancePos();
|
|
2937
|
|
2938 // set ending attribute byte
|
|
2939 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
2940
|
|
2941 setDirty(lastPos);
|
|
2942
|
|
2943 lastPos = ((getRow(lastPos) + 1) * numCols) + c;
|
|
2944
|
|
2945 // now handle body of window
|
|
2946 while (depth-- > 0) {
|
|
2947
|
|
2948 // set leading attribute byte
|
|
2949 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
2950 setDirty(lastPos);
|
|
2951 advancePos();
|
|
2952
|
|
2953 // set left
|
|
2954 planes.setScreenCharAndAttr(lastPos, (char) left, colorAttr, false);
|
|
2955
|
|
2956 if (gui) {
|
|
2957 planes.setUseGUI(lastPos,GUI_LEFT);
|
|
2958 }
|
|
2959 setDirty(lastPos);
|
|
2960 advancePos();
|
|
2961
|
|
2962 w = width;
|
|
2963 // fill it in
|
|
2964 while (w-- >= 0) {
|
|
2965 // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
|
|
2966 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
2967 // screen[lastPos].setUseGUI(NO_GUI);
|
|
2968 planes.setUseGUI(lastPos,NO_GUI);
|
|
2969 setDirty(lastPos);
|
|
2970 advancePos();
|
|
2971 }
|
|
2972
|
|
2973 // set right
|
|
2974 // screen[lastPos].setCharAndAttr((char) right, colorAttr, false);
|
|
2975 planes.setScreenCharAndAttr(lastPos,(char) right, colorAttr, false);
|
|
2976 if (gui) {
|
|
2977 // screen[lastPos].setUseGUI(RIGHT);
|
|
2978 planes.setUseGUI(lastPos,GUI_RIGHT);
|
|
2979 }
|
|
2980
|
|
2981 setDirty(lastPos);
|
|
2982 advancePos();
|
|
2983
|
|
2984 // set ending attribute byte
|
|
2985 // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
|
|
2986 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
2987 setDirty(lastPos);
|
|
2988
|
|
2989 lastPos = ((getRow(lastPos) + 1) * numCols) + c;
|
|
2990 }
|
|
2991
|
|
2992 // set leading attribute byte
|
|
2993 // screen[lastPos].setCharAndAttr(initChar, initAttr, true);
|
|
2994 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
2995 setDirty(lastPos);
|
|
2996 advancePos();
|
|
2997
|
|
2998 // set lower left
|
|
2999 // screen[lastPos].setCharAndAttr((char) ll, colorAttr, false);
|
|
3000 planes.setScreenCharAndAttr(lastPos,(char) ll, colorAttr, false);
|
|
3001 if (gui) {
|
|
3002 // screen[lastPos].setUseGUI(LOWER_LEFT);
|
|
3003 planes.setUseGUI(lastPos,LOWER_LEFT);
|
|
3004 }
|
|
3005 setDirty(lastPos);
|
|
3006 advancePos();
|
|
3007
|
|
3008 w = width;
|
|
3009
|
|
3010 // draw bottom row
|
|
3011 while (w-- >= 0) {
|
|
3012 planes.setScreenCharAndAttr(lastPos,(char) bottom, colorAttr, false);
|
|
3013 if (gui) {
|
|
3014 planes.setUseGUI(lastPos,BOTTOM);
|
|
3015 }
|
|
3016 setDirty(lastPos);
|
|
3017 advancePos();
|
|
3018 }
|
|
3019
|
|
3020 // set lower right
|
|
3021 planes.setScreenCharAndAttr(lastPos, (char) lr, colorAttr, false);
|
|
3022 if (gui) {
|
|
3023 planes.setUseGUI(lastPos,LOWER_RIGHT);
|
|
3024 }
|
|
3025
|
|
3026 setDirty(lastPos);
|
|
3027 advancePos();
|
|
3028
|
|
3029 // set ending attribute byte
|
|
3030 planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true);
|
|
3031 setDirty(lastPos);
|
|
3032
|
|
3033 }
|
|
3034
|
|
3035 /**
|
|
3036 * Creates a scroll bar on the screen using the parameters provided.
|
|
3037 * ** we only support vertical scroll bars at the time.
|
|
3038 *
|
|
3039 * @param flag -
|
|
3040 * type to draw - vertical or horizontal
|
|
3041 * @param totalRowScrollable
|
|
3042 * @param totalColScrollable
|
|
3043 * @param sliderRowPos
|
|
3044 * @param sliderColPos
|
|
3045 * @param sbSize
|
|
3046 */
|
|
3047 protected void createScrollBar(int flag, int totalRowScrollable,
|
|
3048 int totalColScrollable, int sliderRowPos, int sliderColPos,
|
|
3049 int sbSize) {
|
|
3050
|
|
3051 // System.out.println("Scrollbar flag: " + flag +
|
|
3052 // " scrollable Rows: " + totalRowScrollable +
|
|
3053 // " scrollable Cols: " + totalColScrollable +
|
|
3054 // " thumb Row: " + sliderRowPos +
|
|
3055 // " thumb Col: " + sliderColPos +
|
|
3056 // " size: " + sbSize +
|
|
3057 // " row: " + getRow(lastPos) +
|
|
3058 // " col: " + getCol(lastPos));
|
|
3059
|
|
3060 int sp = lastPos;
|
|
3061 int size = sbSize - 2;
|
|
3062
|
|
3063 int thumbPos = (int) (size * ((float) sliderColPos / (float) totalColScrollable));
|
|
3064 // System.out.println(thumbPos);
|
|
3065 planes.setScreenCharAndAttr(sp,' ', 32, false);
|
|
3066 planes.setUseGUI(sp,BUTTON_SB_UP);
|
|
3067
|
|
3068 int ctr = 0;
|
|
3069 while (ctr < size) {
|
|
3070 sp += numCols;
|
|
3071 planes.setScreenCharAndAttr(sp,' ', 32, false);
|
|
3072 if (ctr == thumbPos)
|
|
3073 planes.setUseGUI(sp,BUTTON_SB_THUMB);
|
|
3074 else
|
|
3075 planes.setUseGUI(sp, BUTTON_SB_GUIDE);
|
|
3076 ctr++;
|
|
3077 }
|
|
3078 sp += numCols;
|
|
3079
|
|
3080
|
|
3081 planes.setScreenCharAndAttr(sp, ' ', 32, false);
|
|
3082 planes.setUseGUI(sp, BUTTON_SB_DN);
|
|
3083 }
|
|
3084
|
|
3085 /**
|
|
3086 * Write the title of the window that is on the screen
|
|
3087 *
|
|
3088 * @param pos
|
|
3089 * @param depth
|
|
3090 * @param width
|
|
3091 * @param orientation
|
|
3092 * @param monoAttr
|
|
3093 * @param colorAttr
|
|
3094 * @param title
|
|
3095 */
|
|
3096 protected void writeWindowTitle(int pos, int depth, int width,
|
|
3097 byte orientation, int monoAttr, int colorAttr, StringBuffer title) {
|
|
3098
|
|
3099 int len = title.length();
|
|
3100
|
|
3101 // get bit 0 and 1 for interrogation
|
|
3102 switch (orientation & 0xc0) {
|
|
3103 case 0x40: // right
|
|
3104 pos += (4 + width - len);
|
|
3105 break;
|
|
3106 case 0x80: // left
|
|
3107 pos += 2;
|
|
3108 break;
|
|
3109 default: // center
|
|
3110 // this is to place the position to the first text position of the
|
|
3111 // window
|
|
3112 // the position passed in is the first attribute position, the next
|
|
3113 // is the border character and then there is another attribute after
|
|
3114 // that.
|
|
3115 pos += (3 + ((width / 2) - (len / 2)));
|
|
3116 break;
|
|
3117
|
|
3118 }
|
|
3119
|
|
3120 // if bit 2 is on then this is a footer
|
|
3121 if ((orientation & 0x20) == 0x20)
|
|
3122 pos += ((depth + 1) * numCols);
|
|
3123
|
|
3124 // System.out.println(pos + "," + width + "," + len+ "," + getRow(pos)
|
|
3125 // + "," + getCol(pos) + "," + ((orientation >> 6) & 0xf0));
|
|
3126
|
|
3127 for (int x = 0; x < len; x++) {
|
|
3128 planes.setChar(pos, title.charAt(x));
|
|
3129 planes.setUseGUI(pos++, NO_GUI);
|
|
3130
|
|
3131 }
|
|
3132 }
|
|
3133
|
|
3134 /**
|
|
3135 * Roll the screen up or down.
|
|
3136 *
|
|
3137 * Byte 1: Bit 0 0 = Roll up 1 = Roll down Bits 1-2 Reserved Bits 3-7 Number
|
|
3138 * of lines that the designated area is to be rolled Byte 2: Bits 0-7 Line
|
|
3139 * number defining the top line of the area that will participate in the
|
|
3140 * roll. Byte 3: Bits 0-7 Line number defining the bottom line of the area
|
|
3141 * that will participate in the roll.
|
|
3142 *
|
|
3143 * @param direction
|
|
3144 * @param topLine
|
|
3145 * @param bottomLine
|
|
3146 */
|
|
3147 protected void rollScreen(int direction, int topLine, int bottomLine) {
|
|
3148
|
|
3149 // get the number of lines which are the last 5 bits
|
|
3150 /* int lines = direction & 0x7F; */
|
|
3151 // get the direction of the roll which is the first bit
|
|
3152 // 0 - up
|
|
3153 // 1 - down
|
|
3154 int updown = direction & 0x80;
|
7
|
3155 final int lines = direction & 0x7F;
|
3
|
3156
|
|
3157 // calculate the reference points for the move.
|
|
3158 int start = this.getPos(topLine - 1, 0);
|
|
3159 int end = this.getPos(bottomLine - 1, numCols - 1);
|
|
3160 int len = end - start;
|
|
3161
|
|
3162 // System.out.println(" starting roll");
|
|
3163 // dumpScreen();
|
|
3164 switch (updown) {
|
|
3165 case 0:
|
|
3166 // Now round em up and head em UP.
|
|
3167 for (int x = start; x < end + numCols; x++) {
|
|
3168 if (x + lines * numCols >= lenScreen) {
|
|
3169 //Clear at the end
|
|
3170 planes.setChar(x, ' ');
|
|
3171 } else {
|
|
3172 planes.setChar(x, planes.getChar(x + lines * numCols ));
|
|
3173 }
|
|
3174 }
|
|
3175 break;
|
|
3176 case 1:
|
|
3177 // Now round em up and head em DOWN.
|
|
3178 for (int x = end + numCols; x > 0; x--) {
|
|
3179 if ((x - lines * numCols ) < 0 ) {
|
|
3180 //Do nothing ... tooo small!!!
|
|
3181 } else {
|
|
3182 planes.setChar(x - lines * numCols, planes.getChar(x));
|
7
|
3183 //and clear
|
3
|
3184 planes.setChar(x, ' ');
|
|
3185 }
|
|
3186 }
|
|
3187 break;
|
|
3188 default:
|
|
3189 log.warn(" Invalid roll parameter - please report this");
|
|
3190 }
|
|
3191 // System.out.println(" end roll");
|
|
3192 // dumpScreen();
|
|
3193
|
|
3194 }
|
|
3195
|
|
3196 public void dumpScreen() {
|
|
3197
|
|
3198 StringBuffer sb = new StringBuffer();
|
|
3199 char[] s = getScreenAsChars();
|
|
3200 int c = getColumns();
|
|
3201 int l = getRows() * c;
|
|
3202 int col = 0;
|
|
3203 for (int x = 0; x < l; x++, col++) {
|
|
3204 sb.append(s[x]);
|
|
3205 if (col == c) {
|
|
3206 sb.append('\n');
|
|
3207 col = 0;
|
|
3208 }
|
|
3209 }
|
|
3210 log.info(sb.toString());
|
|
3211
|
|
3212 }
|
|
3213
|
|
3214 /**
|
|
3215 * Add a field to the field format table.
|
|
3216 *
|
|
3217 * @param attr - Field attribute
|
|
3218 * @param len - length of field
|
|
3219 * @param ffw1 - Field format word 1
|
|
3220 * @param ffw2 - Field format word 2
|
|
3221 * @param fcw1 - Field control word 1
|
|
3222 * @param fcw2 - Field control word 2
|
|
3223 */
|
|
3224 protected void addField(int attr, int len, int ffw1, int ffw2, int fcw1,
|
|
3225 int fcw2) {
|
|
3226
|
|
3227 lastAttr = attr;
|
|
3228
|
|
3229 planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true);
|
|
3230
|
|
3231 setDirty(lastPos);
|
|
3232
|
|
3233 advancePos();
|
|
3234
|
|
3235 ScreenField sf = null;
|
|
3236
|
|
3237 // from 14.6.12 for Start of Field Order 5940 function manual
|
|
3238 // examine the format table for an entry that begins at the current
|
|
3239 // starting address plus 1.
|
|
3240 if (screenFields.existsAtPos(lastPos)) {
|
|
3241 screenFields.setCurrentFieldFFWs(ffw1, ffw2);
|
|
3242 } else {
|
|
3243 sf = screenFields.setField(attr, getRow(lastPos), getCol(lastPos),
|
|
3244 len, ffw1, ffw2, fcw1, fcw2);
|
|
3245 lastPos = sf.startPos();
|
|
3246 int x = len;
|
|
3247
|
|
3248 boolean gui = guiInterface;
|
|
3249 if (sf.isBypassField())
|
|
3250 gui = false;
|
|
3251
|
|
3252 while (x-- > 0) {
|
|
3253
|
|
3254 if (planes.getChar(lastPos) == 0)
|
|
3255 planes.setScreenCharAndAttr(lastPos, ' ', lastAttr, false);
|
|
3256 else
|
|
3257 planes.setScreenAttr(lastPos,lastAttr);
|
|
3258
|
|
3259 if (gui) {
|
|
3260 planes.setUseGUI(lastPos,FIELD_MIDDLE);
|
|
3261 }
|
|
3262
|
|
3263 // now we set the field plane attributes
|
|
3264 planes.setScreenFieldAttr(lastPos,ffw1);
|
|
3265
|
|
3266 advancePos();
|
|
3267
|
|
3268 }
|
|
3269
|
|
3270 if (gui)
|
|
3271 if (len > 1) {
|
|
3272 planes.setUseGUI(sf.startPos(), FIELD_LEFT);
|
|
3273
|
|
3274 if (lastPos > 0)
|
|
3275 planes.setUseGUI(lastPos - 1, FIELD_RIGHT);
|
|
3276 else
|
|
3277 planes.setUseGUI(lastPos,FIELD_RIGHT);
|
|
3278
|
|
3279 }
|
|
3280 else {
|
|
3281 planes.setUseGUI(lastPos - 1,FIELD_ONE);
|
|
3282 }
|
|
3283
|
|
3284 // screen[lastPos].setCharAndAttr(initChar,initAttr,true);
|
|
3285 setEndingAttr(initAttr);
|
|
3286
|
|
3287 lastPos = sf.startPos();
|
|
3288 }
|
|
3289
|
|
3290 // if (fcw1 != 0 || fcw2 != 0) {
|
|
3291
|
|
3292 // System.out.println("lr = " + lastRow + " lc = " + lastCol + " " +
|
|
3293 // sf.toString());
|
|
3294 // }
|
|
3295 sf = null;
|
|
3296
|
|
3297 }
|
|
3298
|
|
3299
|
|
3300 // public void addChoiceField(int attr, int len, int ffw1, int ffw2, int
|
|
3301 // fcw1, int fcw2) {
|
|
3302 //
|
|
3303 // lastAttr = attr;
|
|
3304 //
|
|
3305 // screen[lastPos].setCharAndAttr(initChar,lastAttr,true);
|
|
3306 // setDirty(lastPos);
|
|
3307 //
|
|
3308 // advancePos();
|
|
3309 //
|
|
3310 // boolean found = false;
|
|
3311 // ScreenField sf = null;
|
|
3312 //
|
|
3313 // // from 14.6.12 for Start of Field Order 5940 function manual
|
|
3314 // // examine the format table for an entry that begins at the current
|
|
3315 // // starting address plus 1.
|
|
3316 // for (int x = 0;x < sizeFields; x++) {
|
|
3317 // sf = screenFields[x];
|
|
3318 //
|
|
3319 // if (lastPos == sf.startPos()) {
|
|
3320 // screenFields.getCurrentField() = sf;
|
|
3321 // screenFields.getCurrentField().setFFWs(ffw1,ffw2);
|
|
3322 // found = true;
|
|
3323 // }
|
|
3324 //
|
|
3325 // }
|
|
3326 //
|
|
3327 // if (!found) {
|
|
3328 // sf =
|
|
3329 // setField(attr,getRow(lastPos),getCol(lastPos),len,ffw1,ffw2,fcw1,fcw2);
|
|
3330 //
|
|
3331 // lastPos = sf.startPos();
|
|
3332 // int x = len;
|
|
3333 //
|
|
3334 // boolean gui = guiInterface;
|
|
3335 // if (sf.isBypassField())
|
|
3336 // gui = false;
|
|
3337 //
|
|
3338 // while (x-- > 0) {
|
|
3339 //
|
|
3340 // if (screen[lastPos].getChar() == 0)
|
|
3341 // screen[lastPos].setCharAndAttr(' ',lastAttr,false);
|
|
3342 // else
|
|
3343 // screen[lastPos].setAttribute(lastAttr);
|
|
3344 //
|
|
3345 // if (gui)
|
|
3346 // screen[lastPos].setUseGUI(FIELD_MIDDLE);
|
|
3347 //
|
|
3348 // advancePos();
|
|
3349 //
|
|
3350 // }
|
|
3351 //
|
|
3352 // if (gui)
|
|
3353 // if (len > 1) {
|
|
3354 // screen[sf.startPos()].setUseGUI(FIELD_LEFT);
|
|
3355 // if (lastPos > 0)
|
|
3356 // screen[lastPos-1].setUseGUI(FIELD_RIGHT);
|
|
3357 // else
|
|
3358 // screen[lastPos].setUseGUI(FIELD_RIGHT);
|
|
3359 //
|
|
3360 // }
|
|
3361 // else
|
|
3362 // screen[lastPos-1].setUseGUI(FIELD_ONE);
|
|
3363 //
|
|
3364 // setEndingAttr(initAttr);
|
|
3365 //
|
|
3366 // lastPos = sf.startPos();
|
|
3367 // }
|
|
3368 //
|
|
3369 // // if (fcw1 != 0 || fcw2 != 0) {
|
|
3370 // //
|
|
3371 // // System.out.println("lr = " + lastRow + " lc = " + lastCol + " " +
|
|
3372 // sf.toString());
|
|
3373 // // }
|
|
3374 // sf = null;
|
|
3375 //
|
|
3376 // }
|
|
3377
|
|
3378 /**
|
|
3379 * Return the fields that are contained in the Field Format Table
|
|
3380 *
|
|
3381 * @return ScreenFields object
|
|
3382 * @see org.tn5250j.ScreenFields
|
|
3383 */
|
|
3384 public ScreenFields getScreenFields() {
|
|
3385 return screenFields;
|
|
3386 }
|
|
3387
|
|
3388 /**
|
|
3389 * Redraw the fields on the screen. Used for gui enhancement to redraw the
|
|
3390 * fields when toggling
|
|
3391 *
|
|
3392 */
|
|
3393 protected void drawFields() {
|
|
3394
|
|
3395 ScreenField sf;
|
|
3396
|
|
3397 int sizeFields = screenFields.getSize();
|
|
3398 for (int x = 0; x < sizeFields; x++) {
|
|
3399
|
|
3400 sf = screenFields.getField(x);
|
|
3401
|
|
3402 if (!sf.isBypassField()) {
|
|
3403 int pos = sf.startPos();
|
|
3404
|
|
3405 int l = sf.length;
|
|
3406
|
|
3407 boolean f = true;
|
|
3408
|
|
3409 if (l >= lenScreen)
|
|
3410 l = lenScreen - 1;
|
|
3411
|
|
3412 if (l > 1) {
|
|
3413 while (l-- > 0) {
|
|
3414
|
|
3415 if (guiInterface && f) {
|
|
3416 planes.setUseGUI(pos,FIELD_LEFT);
|
|
3417 f = false;
|
|
3418 } else {
|
|
3419
|
|
3420 planes.setUseGUI(pos,FIELD_MIDDLE);
|
|
3421
|
|
3422 }
|
|
3423
|
|
3424 if (guiInterface && l == 0) {
|
|
3425 planes.setUseGUI(pos,FIELD_RIGHT);
|
|
3426 }
|
|
3427
|
|
3428 setDirty(pos++);
|
|
3429 }
|
|
3430 } else {
|
|
3431 planes.setUseGUI(pos,FIELD_ONE);
|
|
3432 }
|
|
3433 }
|
|
3434 }
|
|
3435
|
|
3436 //updateDirty();
|
|
3437 }
|
|
3438
|
|
3439 /**
|
|
3440 * Draws the field on the screen. Used to redraw or change the attributes of
|
|
3441 * the field.
|
|
3442 *
|
|
3443 * @param sf -
|
|
3444 * Field to be redrawn
|
|
3445 * @see org.tn5250j.ScreenField.java
|
|
3446 */
|
|
3447 protected void drawField(ScreenField sf) {
|
|
3448
|
|
3449 int pos = sf.startPos();
|
|
3450
|
|
3451 int x = sf.length;
|
|
3452
|
|
3453 while (x-- > 0) {
|
|
3454 setDirty(pos++);
|
|
3455 }
|
|
3456
|
|
3457 updateDirty();
|
|
3458
|
|
3459 }
|
|
3460
|
|
3461 /**
|
|
3462 * Set the field to be displayed as highlighted.
|
|
3463 *
|
|
3464 * @param sf -
|
|
3465 * Field to be highlighted
|
|
3466 */
|
|
3467 protected void setFieldHighlighted(ScreenField sf) {
|
|
3468
|
|
3469 int pos = sf.startPos();
|
|
3470
|
|
3471 int x = sf.length;
|
|
3472 int na = sf.getHighlightedAttr();
|
|
3473
|
|
3474 while (x-- > 0) {
|
|
3475 planes.setScreenAttr(pos,na);
|
|
3476 setDirty(pos++);
|
|
3477 }
|
|
3478 fireScreenChanged(1);
|
|
3479
|
|
3480 }
|
|
3481
|
|
3482 /**
|
|
3483 * Draw the field as un higlighted. This is used to reset the field
|
|
3484 * presentation on the screen after the field is exited.
|
|
3485 *
|
|
3486 * @param sf -
|
|
3487 * Field to be unhighlighted
|
|
3488 */
|
|
3489 protected void unsetFieldHighlighted(ScreenField sf) {
|
|
3490
|
|
3491 int pos = sf.startPos();
|
|
3492
|
|
3493 int x = sf.length;
|
|
3494 int na = sf.getAttr();
|
|
3495
|
|
3496 while (x-- > 0) {
|
|
3497 planes.setScreenAttr(pos,na);
|
|
3498 setDirty(pos++);
|
|
3499 }
|
|
3500 fireScreenChanged(1);
|
|
3501
|
|
3502 }
|
|
3503
|
|
3504 protected void setChar(int cByte) {
|
|
3505 if (lastPos > 0) {
|
|
3506 lastAttr = planes.getCharAttr(lastPos - 1);
|
|
3507 }
|
|
3508 if (cByte > 0 && (char)cByte < ' ') {
|
|
3509 planes.setScreenCharAndAttr(lastPos, (char) 0x00, 33, false);
|
|
3510 setDirty(lastPos);
|
|
3511 advancePos();
|
|
3512 } else {
|
|
3513 planes.setScreenCharAndAttr(lastPos, (char) cByte, lastAttr, false);
|
|
3514 setDirty(lastPos);
|
|
3515 if (guiInterface && !isInField(lastPos, false)) {
|
|
3516 planes.setUseGUI(lastPos, NO_GUI);
|
|
3517 }
|
|
3518 advancePos();
|
|
3519 }
|
|
3520 }
|
|
3521
|
|
3522 protected void setEndingAttr(int cByte) {
|
|
3523 int attr = lastAttr;
|
|
3524 setAttr(cByte);
|
|
3525 lastAttr = attr;
|
|
3526 }
|
|
3527
|
|
3528 protected void setAttr(int cByte) {
|
|
3529 lastAttr = cByte;
|
|
3530
|
|
3531 // int sattr = screen[lastPos].getCharAttr();
|
|
3532 // System.out.println("changing from " + sattr + " to attr " + lastAttr
|
|
3533 // +
|
|
3534 // " at " + (this.getRow(lastPos) + 1) + "," + (this.getCol(lastPos) +
|
|
3535 // 1));
|
|
3536 planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true);
|
|
3537 setDirty(lastPos);
|
|
3538
|
|
3539 advancePos();
|
|
3540 int pos = lastPos;
|
|
3541
|
|
3542 int times = 0;
|
|
3543 // sattr = screen[lastPos].getCharAttr();
|
|
3544 // System.out.println(" next position after change " + sattr + " last
|
|
3545 // attr " + lastAttr +
|
|
3546 // " at " + (this.getRow(lastPos) + 1) + "," + (this.getCol(lastPos) +
|
|
3547 // 1) +
|
|
3548 // " attr place " + screen[lastPos].isAttributePlace());
|
|
3549
|
|
3550 while (planes.getCharAttr(lastPos) != lastAttr
|
|
3551 && !planes.isAttributePlace(lastPos)) {
|
|
3552
|
|
3553 planes.setScreenAttr(lastPos, lastAttr);
|
|
3554 if (guiInterface && !isInField(lastPos, false)) {
|
|
3555 int g = planes.getWhichGUI(lastPos);
|
|
3556 if (g >= FIELD_LEFT && g <= FIELD_ONE)
|
|
3557 planes.setUseGUI(lastPos,NO_GUI);
|
|
3558 }
|
|
3559 setDirty(lastPos);
|
|
3560
|
|
3561 times++;
|
|
3562 advancePos();
|
|
3563 }
|
|
3564
|
|
3565 // sanity check for right now
|
|
3566 // if (times > 200)
|
|
3567 // System.out.println(" setAttr = " + times + " start = " + (sr + 1) +
|
|
3568 // "," + (sc + 1));
|
|
3569
|
|
3570 lastPos = pos;
|
|
3571 }
|
|
3572
|
|
3573 protected void setScreenCharAndAttr(char right, int colorAttr, boolean isAttr) {
|
|
3574
|
|
3575 planes.setScreenCharAndAttr(lastPos,right, colorAttr, isAttr);
|
|
3576 setDirty(lastPos);
|
|
3577 advancePos();
|
|
3578
|
|
3579 }
|
|
3580
|
|
3581 protected void setScreenCharAndAttr(char right, int colorAttr,
|
|
3582 int whichGui, boolean isAttr) {
|
|
3583
|
|
3584 planes.setScreenCharAndAttr(lastPos,right, colorAttr, isAttr);
|
|
3585 planes.setUseGUI(lastPos,whichGui);
|
|
3586
|
|
3587 setDirty(lastPos);
|
|
3588 advancePos();
|
|
3589
|
|
3590 }
|
|
3591
|
|
3592 /**
|
|
3593 * Draw or redraw the dirty parts of the screen and display them.
|
|
3594 *
|
|
3595 * Rectangle dirty holds the dirty area of the screen to be updated.
|
|
3596 *
|
|
3597 * If you want to change the screen in anyway you need to set the screen
|
|
3598 * attributes before calling this routine.
|
|
3599 */
|
|
3600 protected void updateDirty() {
|
|
3601
|
|
3602 fireScreenChanged(1);
|
|
3603
|
|
3604 }
|
|
3605
|
|
3606 protected void setDirty(int pos) {
|
|
3607
|
|
3608 int minr = Math.min(getRow(pos),getRow(dirtyScreen.x));
|
|
3609 int minc = Math.min(getCol(pos),getCol(dirtyScreen.x));
|
|
3610
|
|
3611 int maxr = Math.max(getRow(pos),getRow(dirtyScreen.y));
|
|
3612 int maxc = Math.max(getCol(pos),getCol(dirtyScreen.y));
|
|
3613
|
|
3614 int x1 = getPos(minr,minc);
|
|
3615 int x2 = getPos(maxr,maxc);
|
|
3616
|
|
3617 dirtyScreen.setBounds(x1,x2,0,0);
|
|
3618
|
|
3619 }
|
|
3620
|
|
3621 /* *** NEVER USED LOCALLY ************************************************** */
|
|
3622 // private void setDirty(int row, int col) {
|
|
3623 //
|
|
3624 // setDirty(getPos(row, col));
|
|
3625 //
|
|
3626 // }
|
|
3627
|
|
3628 private void resetDirty(int pos) {
|
|
3629
|
|
3630 dirtyScreen.setBounds(pos,pos,0,0);
|
|
3631
|
|
3632 }
|
|
3633
|
|
3634 /**
|
|
3635 * Change the screen position by one column
|
|
3636 */
|
|
3637 protected void advancePos() {
|
|
3638 changePos(1);
|
|
3639 }
|
|
3640
|
|
3641 /**
|
|
3642 * Change position of the screen by the increment of parameter passed.
|
|
3643 *
|
|
3644 * If the position change is under the minimum of the first screen position
|
|
3645 * then the position is moved to the last row and column of the screen.
|
|
3646 *
|
|
3647 * If the position change is over the last row and column of the screen then
|
|
3648 * cursor is moved to first position of the screen.
|
|
3649 *
|
|
3650 * @param i
|
|
3651 */
|
|
3652 protected void changePos(int i) {
|
|
3653
|
|
3654 lastPos += i;
|
|
3655 if (lastPos < 0)
|
|
3656 lastPos = lenScreen + lastPos;
|
|
3657 if (lastPos > lenScreen - 1)
|
|
3658 lastPos = lastPos - lenScreen;
|
|
3659
|
|
3660 // System.out.println(lastRow + "," + ((lastPos) / numCols) + "," +
|
|
3661 // lastCol + "," + ((lastPos) % numCols) + "," +
|
|
3662 // ((lastRow * numCols) + lastCol) + "," +
|
|
3663 // (lastPos));
|
|
3664
|
|
3665 }
|
|
3666
|
|
3667 protected void goHome() {
|
|
3668
|
|
3669 // now we try to move to first input field according to
|
|
3670 // 14.6 WRITE TO DISPLAY Command
|
|
3671 // ? If the WTD command is valid, after the command is processed,
|
|
3672 // the cursor moves to one of three locations:
|
|
3673 // - The location set by an insert cursor order (unless control
|
|
3674 // character byte 1, bit 1 is equal to B'1'.)
|
|
3675 // - The start of the first non-bypass input field defined in the
|
|
3676 // format table
|
|
3677 // - A default starting address of row 1 column 1.
|
|
3678
|
|
3679 if (pendingInsert && homePos > 0) {
|
|
3680 setCursor(getRow(homePos), getCol(homePos));
|
|
3681 isInField(); // we now check if we are in a field
|
|
3682 } else {
|
|
3683 if (!gotoField(1)) {
|
|
3684 homePos = getPos(1, 1);
|
|
3685 setCursor(1, 1);
|
|
3686 isInField(0, 0); // we now check if we are in a field
|
|
3687 } else {
|
|
3688 homePos = getPos(getCurrentRow(), getCurrentCol());
|
|
3689 }
|
|
3690 }
|
|
3691 }
|
|
3692
|
|
3693 protected void setPendingInsert(boolean flag, int icX, int icY) {
|
|
3694 pendingInsert = flag;
|
|
3695 if (pendingInsert) {
|
|
3696 homePos = getPos(icX, icY);
|
|
3697 }
|
|
3698
|
|
3699 if (!isStatusErrorCode()) {
|
|
3700 setCursor(icX, icY);
|
|
3701 }
|
|
3702 }
|
|
3703
|
|
3704 protected void setPendingInsert(boolean flag) {
|
|
3705 if (homePos != -1)
|
|
3706 pendingInsert = flag;
|
|
3707 }
|
|
3708
|
|
3709 /**
|
|
3710 * Set the error line number to that of number passed.
|
|
3711 *
|
|
3712 * @param line
|
|
3713 */
|
|
3714 protected void setErrorLine(int line) {
|
|
3715
|
|
3716 planes.setErrorLine(line);
|
|
3717 }
|
|
3718
|
|
3719 /**
|
|
3720 * Returns the current error line number
|
|
3721 *
|
|
3722 * @return current error line number
|
|
3723 */
|
|
3724 protected int getErrorLine() {
|
|
3725 return planes.getErrorLine();
|
|
3726 }
|
|
3727
|
|
3728 /**
|
|
3729 * Saves off the current error line characters to be used later.
|
|
3730 *
|
|
3731 */
|
|
3732 protected void saveErrorLine() {
|
|
3733 planes.saveErrorLine();
|
|
3734 }
|
|
3735
|
|
3736 /**
|
|
3737 * Restores the error line characters from the save buffer.
|
|
3738 *
|
|
3739 * @see #saveErrorLine()
|
|
3740 */
|
|
3741 protected void restoreErrorLine() {
|
|
3742
|
|
3743 if (planes.isErrorLineSaved()) {
|
|
3744 planes.restoreErrorLine();
|
|
3745 fireScreenChanged(1,planes.getErrorLine()-1,0,planes.getErrorLine()-1,numCols - 1);
|
|
3746 }
|
|
3747 }
|
|
3748
|
|
3749 protected void setStatus(byte attr, byte value, String s) {
|
|
3750
|
|
3751 // set the status area
|
|
3752 switch (attr) {
|
|
3753
|
|
3754 case STATUS_SYSTEM:
|
|
3755 if (value == STATUS_VALUE_ON) {
|
|
3756 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, s);
|
|
3757 }
|
|
3758 else {
|
|
3759 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED,ScreenOIA.OIA_LEVEL_NOT_INHIBITED,s);
|
|
3760 }
|
|
3761 break;
|
|
3762
|
|
3763 case STATUS_ERROR_CODE:
|
|
3764 if (value == STATUS_VALUE_ON) {
|
|
3765 setPrehelpState(true, true, false);
|
|
3766 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
|
|
3767 ScreenOIA.OIA_LEVEL_INPUT_ERROR,s);
|
|
3768
|
|
3769 sessionVT.signalBell();
|
|
3770 } else {
|
|
3771 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED,
|
|
3772 ScreenOIA.OIA_LEVEL_NOT_INHIBITED);
|
|
3773 setPrehelpState(false, true, true);
|
|
3774 homePos = saveHomePos;
|
|
3775 saveHomePos = 0;
|
|
3776 pendingInsert = false;
|
|
3777 }
|
|
3778 break;
|
|
3779
|
|
3780 }
|
|
3781 }
|
|
3782
|
|
3783 protected boolean isStatusErrorCode() {
|
|
3784
|
|
3785 return oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_ERROR;
|
|
3786
|
|
3787 }
|
|
3788
|
|
3789 /**
|
|
3790 * This routine clears the screen, resets row and column to 0, resets the
|
|
3791 * last attribute to 32, clears the fields, turns insert mode off,
|
|
3792 * clears/initializes the screen character array.
|
|
3793 */
|
|
3794 protected void clearAll() {
|
|
3795
|
|
3796 lastAttr = 32;
|
|
3797 lastPos = 0;
|
|
3798
|
|
3799 clearTable();
|
|
3800 clearScreen();
|
|
3801 planes.setScreenAttr(0, initAttr);
|
|
3802 oia.setInsertMode(false);
|
|
3803 }
|
|
3804
|
|
3805 /**
|
|
3806 * Clear the fields table
|
|
3807 */
|
|
3808 protected void clearTable() {
|
|
3809
|
|
3810 oia.setKeyBoardLocked(true);
|
|
3811 screenFields.clearFFT();
|
|
3812 planes.initalizeFieldPlanes();
|
|
3813 pendingInsert = false;
|
|
3814 homePos = -1;
|
|
3815 }
|
|
3816
|
|
3817 /**
|
|
3818 * Clear the gui constructs
|
|
3819 *
|
|
3820 */
|
|
3821 protected void clearGuiStuff() {
|
|
3822
|
|
3823 for (int x = 0; x < lenScreen; x++) {
|
|
3824 planes.setUseGUI(x,NO_GUI);
|
|
3825 }
|
|
3826 dirtyScreen.setBounds(0,lenScreen - 1,0,0);
|
|
3827 }
|
|
3828
|
|
3829 /**
|
|
3830 * Clear the screen by setting the initial character and initial attribute
|
|
3831 * to all the positions on the screen
|
|
3832 */
|
|
3833 protected void clearScreen() {
|
|
3834
|
|
3835 planes.initalizePlanes();
|
|
3836
|
|
3837 dirtyScreen.setBounds(0,lenScreen - 1,0,0);
|
|
3838
|
|
3839 oia.clearScreen();
|
|
3840
|
|
3841 }
|
|
3842
|
|
3843 protected void restoreScreen() {
|
|
3844
|
|
3845 lastAttr = 32;
|
|
3846 dirtyScreen.setBounds(0,lenScreen - 1,0,0);
|
|
3847 updateDirty();
|
|
3848 }
|
|
3849
|
|
3850 /**
|
|
3851 * Notify all registered listeners of the onScreenChanged event.
|
|
3852 *
|
|
3853 */
|
|
3854 private void fireScreenChanged(int which, int startRow, int startCol,
|
|
3855 int endRow, int endCol) {
|
|
3856 if (listeners != null) {
|
|
3857 // Patch below contributed by Mitch Blevins
|
|
3858 //int size = listeners.size();
|
|
3859 Vector<ScreenListener> lc = new Vector<ScreenListener>(listeners);
|
|
3860 int size = lc.size();
|
|
3861 for (int i = 0; i < size; i++) {
|
|
3862 //ScreenListener target =
|
|
3863 // (ScreenListener)listeners.elementAt(i);
|
|
3864 ScreenListener target = lc.elementAt(i);
|
|
3865 target.onScreenChanged(1,startRow,startCol,endRow,endCol);
|
|
3866 }
|
|
3867 }
|
|
3868 dirtyScreen.setBounds(lenScreen,0,0,0);
|
|
3869 }
|
|
3870
|
|
3871 /**
|
|
3872 * Notify all registered listeners of the onScreenChanged event.
|
|
3873 *
|
|
3874 */
|
|
3875 private synchronized void fireScreenChanged(int update) {
|
|
3876 if (dirtyScreen.x > dirtyScreen.y) {
|
|
3877 // log.info(" x < y " + dirtyScreen);
|
|
3878 return;
|
|
3879 }
|
|
3880
|
|
3881 fireScreenChanged(update, getRow(dirtyScreen.x), getCol(dirtyScreen.x),
|
|
3882 getRow(dirtyScreen.y), getCol(dirtyScreen.y));
|
|
3883
|
|
3884 }
|
|
3885
|
|
3886 /**
|
|
3887 * Notify all registered listeners of the onScreenChanged event.
|
|
3888 *
|
|
3889 */
|
|
3890 private synchronized void fireCursorChanged(int update) {
|
|
3891 int startRow = getRow(lastPos);
|
|
3892 int startCol = getCol(lastPos);
|
|
3893
|
|
3894 if (listeners != null) {
|
|
3895 Vector<ScreenListener> lc = new Vector<ScreenListener>(listeners);
|
|
3896 //int size = listeners.size();
|
|
3897 int size = lc.size();
|
|
3898 for (int i = 0; i < size; i++) {
|
|
3899 ScreenListener target =
|
|
3900 lc.elementAt(i);
|
|
3901 target.onScreenChanged(update,startRow,startCol,startRow,startCol);
|
|
3902 }
|
|
3903 }
|
|
3904 }
|
|
3905
|
|
3906 /**
|
|
3907 * Notify all registered listeners of the onScreenSizeChanged event.
|
|
3908 *
|
|
3909 */
|
|
3910 private void fireScreenSizeChanged() {
|
|
3911
|
|
3912 if (listeners != null) {
|
|
3913 Vector<ScreenListener> lc = new Vector<ScreenListener>(listeners);
|
|
3914 //int size = listeners.size();
|
|
3915 int size = lc.size();
|
|
3916 for (int i = 0; i < size; i++) {
|
|
3917 ScreenListener target =
|
|
3918 lc.elementAt(i);
|
|
3919 target.onScreenSizeChanged(numRows,numCols);
|
|
3920 }
|
|
3921 }
|
|
3922 }
|
|
3923
|
|
3924 /**
|
|
3925 * This method does a complete refresh of the screen.
|
|
3926 */
|
|
3927 public final void updateScreen() {
|
|
3928 repaintScreen();
|
|
3929 setCursorActive(false);
|
|
3930 setCursorActive(true);
|
|
3931 }
|
|
3932
|
|
3933 /**
|
|
3934 * Add a ScreenListener to the listener list.
|
|
3935 *
|
|
3936 * @param listener The ScreenListener to be added
|
|
3937 */
|
|
3938 public void addScreenListener(ScreenListener listener) {
|
|
3939
|
|
3940 if (listeners == null) {
|
|
3941 listeners = new java.util.Vector<ScreenListener>(3);
|
|
3942 }
|
|
3943 listeners.addElement(listener);
|
|
3944
|
|
3945 }
|
|
3946
|
|
3947 /**
|
|
3948 * Remove a ScreenListener from the listener list.
|
|
3949 *
|
|
3950 * @param listener The ScreenListener to be removed
|
|
3951 */
|
|
3952 public void removeScreenListener(ScreenListener listener) {
|
|
3953
|
|
3954 if (listeners == null) {
|
|
3955 return;
|
|
3956 }
|
|
3957 listeners.removeElement(listener);
|
|
3958 }
|
|
3959
|
|
3960 /**
|
|
3961 * Utility method to share the repaint behaviour between setBounds() and
|
|
3962 * updateScreen.
|
|
3963 */
|
|
3964 public void repaintScreen() {
|
|
3965
|
|
3966 setCursorOff();
|
|
3967 dirtyScreen.setBounds(0,lenScreen - 1,0,0);
|
|
3968 updateDirty();
|
|
3969 // restore statuses that were on the screen before resize
|
|
3970 if (oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_ERROR) {
|
|
3971 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
|
|
3972 ScreenOIA.OIA_LEVEL_INPUT_ERROR);
|
|
3973 }
|
|
3974
|
|
3975 if (oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_INHIBITED) {
|
|
3976 oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,
|
|
3977 ScreenOIA.OIA_LEVEL_INPUT_INHIBITED);
|
|
3978 }
|
|
3979
|
|
3980 if (oia.isMessageWait())
|
|
3981 oia.setMessageLightOn();
|
|
3982 setCursorOn();
|
|
3983 }
|
|
3984
|
|
3985 // ADDED BY BARRY - changed by Kenneth to use the character plane
|
|
3986 // This should be replaced with the getPlane methods when they are implemented
|
|
3987 public char[] getCharacters() {
|
|
3988 return planes.screen;
|
|
3989 }
|
|
3990
|
|
3991 }
|