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