Mercurial > 510Connectbot
comparison src/org/tn5250j/framework/tn5250/Screen5250.java @ 25:5949eb469a79 tn5250
adding tn5250 files, native android logging
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 03 Jun 2014 12:10:21 -0700 |
parents | e773d0952613 |
children | 9ae1c889a64c |
comparison
equal
deleted
inserted
replaced
24:d1c549560aff | 25:5949eb469a79 |
---|---|
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; | 37 import org.tn5250j.event.ScreenListener; |
38 import org.tn5250j.tools.logging.TN5250jLogFactory; | 38 import android.util.Log; |
39 import org.tn5250j.tools.logging.TN5250jLogger; | 39 |
40 | 40 |
41 public class Screen5250 { | 41 public class Screen5250 { |
42 | 42 |
43 private ScreenFields screenFields; | 43 private ScreenFields screenFields; |
44 private int lastAttr; | 44 private int lastAttr; |
96 protected ScreenPlanes planes; | 96 protected ScreenPlanes planes; |
97 | 97 |
98 //Added by Barry | 98 //Added by Barry |
99 private StringBuffer keybuf; | 99 private StringBuffer keybuf; |
100 | 100 |
101 private TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass()); | 101 |
102 | 102 |
103 public Screen5250() { | 103 public Screen5250() { |
104 | 104 |
105 //Added by Barry | 105 //Added by Barry |
106 this.keybuf = new StringBuffer(); | 106 this.keybuf = new StringBuffer(); |
107 | 107 |
108 try { | 108 try { |
109 jbInit(); | 109 jbInit(); |
110 } catch (Exception ex) { | 110 } catch (Exception ex) { |
111 log.warn("In constructor: ", ex); | 111 Log.w(TAG,"In constructor: ", ex); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 void jbInit() throws Exception { | 115 void jbInit() throws Exception { |
116 | 116 |
195 */ | 195 */ |
196 public final String copyText(Rect area) { | 196 public final String copyText(Rect area) { |
197 StringBuilder sb = new StringBuilder(); | 197 StringBuilder sb = new StringBuilder(); |
198 Rect workR = new Rect(); | 198 Rect workR = new Rect(); |
199 workR.setBounds(area); | 199 workR.setBounds(area); |
200 log.debug("Copying " + workR); | 200 Log.d(TAG,"Copying " + workR); |
201 | 201 |
202 // loop through all the screen characters to send them to the clip board | 202 // loop through all the screen characters to send them to the clip board |
203 int m = workR.x; | 203 int m = workR.x; |
204 int i = 0; | 204 int i = 0; |
205 int t = 0; | 205 int t = 0; |
229 * | 229 * |
230 * @param content | 230 * @param content |
231 * @see {@link #copyText(Rectangle)} | 231 * @see {@link #copyText(Rectangle)} |
232 */ | 232 */ |
233 public final void pasteText(String content, boolean special) { | 233 public final void pasteText(String content, boolean special) { |
234 if (log.isDebugEnabled()) { | 234 Log.d(TAG,"Pasting, special:"+special); |
235 log.debug("Pasting, special:"+special); | |
236 } | |
237 setCursorActive(false); | 235 setCursorActive(false); |
238 | 236 |
239 StringBuilder sb = new StringBuilder(content); | 237 StringBuilder sb = new StringBuilder(content); |
240 StringBuilder pd = new StringBuilder(); | 238 StringBuilder pd = new StringBuilder(); |
241 | 239 |
260 | 258 |
261 c = sb.charAt(x); | 259 c = sb.charAt(x); |
262 | 260 |
263 if ((c == '\n') || (c == '\r')) { | 261 if ((c == '\n') || (c == '\r')) { |
264 | 262 |
265 log.info("pasted cr-lf>" + pd + "<"); | 263 Log.i(TAG,"pasted cr-lf>" + pd + "<"); |
266 pd.setLength(0); | 264 pd.setLength(0); |
267 // if we read in a cr lf in the data stream we need to go | 265 // if we read in a cr lf in the data stream we need to go |
268 // to the starting column of the next row and start from there | 266 // to the starting column of the next row and start from there |
269 cpos = getPos(getRow(cpos)+1,lc); | 267 cpos = getPos(getRow(cpos)+1,lc); |
270 | 268 |
298 } | 296 } |
299 } | 297 } |
300 | 298 |
301 // if we have anything else not logged then log it out. | 299 // if we have anything else not logged then log it out. |
302 if (pd.length() > 0) | 300 if (pd.length() > 0) |
303 log.info("pasted >" + pd + "<"); | 301 Log.i(TAG,"pasted >" + pd + "<"); |
304 | 302 |
305 // restore out position within the FFT. | 303 // restore out position within the FFT. |
306 screenFields.restoreCurrentField(); | 304 screenFields.restoreCurrentField(); |
307 updateDirty(); | 305 updateDirty(); |
308 | 306 |
348 workR.setBounds(area); | 346 workR.setBounds(area); |
349 | 347 |
350 // gui.rubberband.reset(); | 348 // gui.rubberband.reset(); |
351 // gui.repaint(); | 349 // gui.repaint(); |
352 | 350 |
353 log.debug("Summing"); | 351 Log.d(TAG,"Summing"); |
354 | 352 |
355 // obtain the decimal format for parsing | 353 // obtain the decimal format for parsing |
356 DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(); | 354 DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(); |
357 | 355 |
358 DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); | 356 DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); |
404 // System.out.println(s + " " + n.doubleValue()); | 402 // System.out.println(s + " " + n.doubleValue()); |
405 | 403 |
406 sumVector.add(new Double(n.doubleValue())); | 404 sumVector.add(new Double(n.doubleValue())); |
407 sum += n.doubleValue(); | 405 sum += n.doubleValue(); |
408 } catch (ParseException pe) { | 406 } catch (ParseException pe) { |
409 log.warn(pe.getMessage() + " at " | 407 Log.w(TAG,pe.getMessage() + " at " |
410 + pe.getErrorOffset()); | 408 + pe.getErrorOffset()); |
411 } | 409 } |
412 } | 410 } |
413 sb.setLength(0); | 411 sb.setLength(0); |
414 m++; | 412 m++; |
415 } | 413 } |
416 log.debug("" + sum); | 414 Log.d(TAG,"" + sum); |
417 return sumVector; | 415 return sumVector; |
418 } | 416 } |
419 | 417 |
420 /** | 418 /** |
421 * This will move the screen cursor based on the mouse event. | 419 * This will move the screen cursor based on the mouse event. |
454 aidFlag = false; | 452 aidFlag = false; |
455 | 453 |
456 if (planes.getChar(pos + 1) != '=' | 454 if (planes.getChar(pos + 1) != '=' |
457 && planes.getChar(pos + 1) != '.' | 455 && planes.getChar(pos + 1) != '.' |
458 && planes.getChar(pos + 1) != '/') { | 456 && planes.getChar(pos + 1) != '/') { |
459 log.debug(" Hotspot clicked!!! we will send characters " | 457 Log.d(TAG," Hotspot clicked!!! we will send characters " |
460 + planes.getChar(pos) + " " + planes.getChar(pos+1)); | 458 + planes.getChar(pos) + " " + planes.getChar(pos+1)); |
461 aid.append(planes.getChar(pos)); | 459 aid.append(planes.getChar(pos)); |
462 aid.append(planes.getChar(pos + 1)); | 460 aid.append(planes.getChar(pos + 1)); |
463 } else { | 461 } else { |
464 log.debug(" Hotspot clicked!!! we will send character " | 462 Log.d(TAG," Hotspot clicked!!! we will send character " |
465 + planes.getChar(pos)); | 463 + planes.getChar(pos)); |
466 aid.append(planes.getChar(pos)); | 464 aid.append(planes.getChar(pos)); |
467 } | 465 } |
468 break; | 466 break; |
469 | 467 |
499 eb.append(planes.getChar(pos)); | 497 eb.append(planes.getChar(pos)); |
500 } | 498 } |
501 sessionVT.showURL(eb.toString()); | 499 sessionVT.showURL(eb.toString()); |
502 // take out the log statement when we are sure it is | 500 // take out the log statement when we are sure it is |
503 // working | 501 // working |
504 log.info("Send to external Browser: " + eb.toString()); | 502 Log.i(TAG,"Send to external Browser: " + eb.toString()); |
505 break; | 503 break; |
506 | 504 |
507 default: | 505 default: |
508 int aidKey = Integer.parseInt(aid.toString()); | 506 int aidKey = Integer.parseInt(aid.toString()); |
509 if (aidKey >= 1 && aidKey <= 12) | 507 if (aidKey >= 1 && aidKey <= 12) |
1693 | 1691 |
1694 process_XY(getPos(rowNow,colNow)); | 1692 process_XY(getPos(rowNow,colNow)); |
1695 simulated = true; | 1693 simulated = true; |
1696 break; | 1694 break; |
1697 default: | 1695 default: |
1698 log.info(" Mnemonic not supported " + mnem); | 1696 Log.i(TAG," Mnemonic not supported " + mnem); |
1699 break; | 1697 break; |
1700 | 1698 |
1701 } | 1699 } |
1702 | 1700 |
1703 return simulated; | 1701 return simulated; |
3184 planes.setChar(x, ' '); | 3182 planes.setChar(x, ' '); |
3185 } | 3183 } |
3186 } | 3184 } |
3187 break; | 3185 break; |
3188 default: | 3186 default: |
3189 log.warn(" Invalid roll parameter - please report this"); | 3187 Log.w(TAG," Invalid roll parameter - please report this"); |
3190 } | 3188 } |
3191 // System.out.println(" end roll"); | 3189 // System.out.println(" end roll"); |
3192 // dumpScreen(); | 3190 // dumpScreen(); |
3193 | 3191 |
3194 } | 3192 } |
3205 if (col == c) { | 3203 if (col == c) { |
3206 sb.append('\n'); | 3204 sb.append('\n'); |
3207 col = 0; | 3205 col = 0; |
3208 } | 3206 } |
3209 } | 3207 } |
3210 log.info(sb.toString()); | 3208 Log.i(TAG,sb.toString()); |
3211 | 3209 |
3212 } | 3210 } |
3213 | 3211 |
3214 /** | 3212 /** |
3215 * Add a field to the field format table. | 3213 * Add a field to the field format table. |
3872 * Notify all registered listeners of the onScreenChanged event. | 3870 * Notify all registered listeners of the onScreenChanged event. |
3873 * | 3871 * |
3874 */ | 3872 */ |
3875 private synchronized void fireScreenChanged(int update) { | 3873 private synchronized void fireScreenChanged(int update) { |
3876 if (dirtyScreen.x > dirtyScreen.y) { | 3874 if (dirtyScreen.x > dirtyScreen.y) { |
3877 // log.info(" x < y " + dirtyScreen); | 3875 // Log.i(TAG," x < y " + dirtyScreen); |
3878 return; | 3876 return; |
3879 } | 3877 } |
3880 | 3878 |
3881 fireScreenChanged(update, getRow(dirtyScreen.x), getCol(dirtyScreen.x), | 3879 fireScreenChanged(update, getRow(dirtyScreen.x), getCol(dirtyScreen.x), |
3882 getRow(dirtyScreen.y), getCol(dirtyScreen.y)); | 3880 getRow(dirtyScreen.y), getCol(dirtyScreen.y)); |