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