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