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