changeset 348:29076621bab0

merge tn5250j r1227; fix spelling
author Carl Byington <carl@five-ten-sg.com>
date Fri, 01 Aug 2014 10:25:44 -0700
parents bb7d8a7babbe
children 205ee2873330
files TODO src/org/tn5250j/TN5250jConstants.java src/org/tn5250j/framework/tn5250/Screen5250.java src/org/tn5250j/framework/tn5250/ScreenField.java src/org/tn5250j/framework/tn5250/tnvt.java
diffstat 5 files changed, 39 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Thu Jul 31 18:57:57 2014 -0700
+++ b/TODO	Fri Aug 01 10:25:44 2014 -0700
@@ -35,6 +35,7 @@
 
 merge tn5250j
 svn checkout svn://svn.code.sf.net/p/tn5250j/code/branches/new-tabs-jse1.6 tn5250j
+r1221
 
 ==================================
 
@@ -43,6 +44,13 @@
 rev 161
 
 ==================================
+
+merge tn5250j updates
+svn checkout svn://svn.code.sf.net/p/tn5250j/code/branches/new-tabs-jse1.6 tn5250j
+r1227
+
+==================================
+
 TODO:
 
 possible merge of irssi?
--- a/src/org/tn5250j/TN5250jConstants.java	Thu Jul 31 18:57:57 2014 -0700
+++ b/src/org/tn5250j/TN5250jConstants.java	Fri Aug 01 10:25:44 2014 -0700
@@ -27,7 +27,7 @@
     // Version information
     public static final String tn5250jRelease = "0";
     public static final String tn5250jVersion = ".7";
-    public static final String tn5250jSubVer = ".3";
+    public static final String tn5250jSubVer = ".4";
 
     public static final String VERSION_INFO = tn5250jRelease + tn5250jVersion + tn5250jSubVer;
 
--- a/src/org/tn5250j/framework/tn5250/Screen5250.java	Thu Jul 31 18:57:57 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/Screen5250.java	Fri Aug 01 10:25:44 2014 -0700
@@ -83,7 +83,7 @@
     private final static int ERR_FIELD_MINUS = 0x16;
     private final static int ERR_FIELD_EXIT_INVALID = 0x18;
     private final static int ERR_ENTER_NO_ALLOWED = 0x20;
-    private final static int ERR_MANDITORY_ENTER = 0x21;
+    private final static int ERR_MANDATORY_ENTER = 0x21;
 
     private boolean guiInterface = false;
     private boolean resetRequired = false;
@@ -1908,7 +1908,7 @@
         ScreenField sf = screenFields.getCurrentField();
 
         if (sf.isMandatoryEnter() && end == sf.startPos()) {
-            displayError(ERR_MANDITORY_ENTER);
+            displayError(ERR_MANDATORY_ENTER);
             return false;
         }
 
@@ -1962,7 +1962,7 @@
                     break;
 
                 case 7:
-                    sf.setManditoryEntered();
+                    sf.setMandatoryEntered();
                     break;
             }
         }
@@ -2160,7 +2160,7 @@
      * <td>0x20</td>
      * </tr>
      * <tr>
-     * <td>ERR_MANDITORY_ENTER</td>
+     * <td>ERR_MANDATORY_ENTER</td>
      * <td>0x21</td>
      * </tr>
      * <tr>
--- a/src/org/tn5250j/framework/tn5250/ScreenField.java	Thu Jul 31 18:57:57 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/ScreenField.java	Fri Aug 01 10:25:44 2014 -0700
@@ -87,7 +87,7 @@
                     break;
 
                 case 7:
-                    manditoried = false;
+                    mandatory = false;
                     break;
             }
         }
@@ -268,8 +268,8 @@
         rightAdjd = true;
     }
 
-    protected void setManditoryEntered() {
-        manditoried = true;
+    protected void setMandatoryEntered() {
+        mandatory = true;
     }
 
     protected void resetMDT() {
@@ -306,7 +306,7 @@
         return (ffw2 & 0x40) == 0x40;
     }
 
-    // is field manditory enter
+    // is field mandatory enter
     public boolean isMandatoryEnter() {
         return (ffw2 & 0x8) == 0x8;
     }
@@ -383,7 +383,7 @@
                     return rightAdjd;
 
                 case 7:
-                    return manditoried;
+                    return mandatory;
 
                 default:
                     return true;
@@ -465,27 +465,23 @@
      * @param text - The text to be placed in the field's text plane.
      */
     public void setString(String text) {
-        int y = length;
-        cursorPos = startPos;
-        int len = text.length();
-        char[] c = text.toCharArray();
-        char tc = ' ';
+		cursorPos = startPos;
 
-        for (int x = 0; x < y; x++) {
-            tc = ' ';
+		if (isRightToLeft()) {
+			text = new StringBuilder(text).reverse().toString();
+		}
 
-            if (x < len) {
-                tc = c[x];
-            }
-
-            s.getPlanes().setChar(cursorPos, tc);
-            changePos(1);
-        }
-
-        setMDT();
-        s.getScreenFields().setMasterMDT();
+		final ScreenPlanes planes = s.getPlanes();
+		for (int x = 0,len = text.length(); x < length; x++) {
+			char tc = (x < len) ? text.charAt(x) : ' ';
+			planes.setChar(cursorPos, tc);
+			changePos(1);
+		}
+		setMDT();
+		s.getScreenFields().setMasterMDT();
     }
 
+	@Override
     public String toString() {
         int fcw = (fcw1 & 0xff) << 8 | fcw2 & 0xff;
         return "startRow = " + startRow() + " startCol = " + startCol() +
@@ -497,7 +493,7 @@
                ") fcw hex = (0x" + Integer.toHexString(fcw) +
                ") is bypass field = " + isBypassField() +
                ") is autoenter = " + isAutoEnter() +
-               ") is manditoryenter = " + isMandatoryEnter() +
+               ") is mandatoryenter = " + isMandatoryEnter() +
                ") is field exit required = " + isFER() +
                ") is Numeric = " + isNumeric() +
                ") is Signed Numeric = " + isSignedNumeric() +
@@ -520,7 +516,7 @@
     boolean mdt = false;
     protected boolean checkCanSend;
     protected boolean rightAdjd;
-    protected boolean manditoried;
+    protected boolean mandatory;
     boolean canSend = true;
     int attr = 0;
     int length = 0;
--- a/src/org/tn5250j/framework/tn5250/tnvt.java	Thu Jul 31 18:57:57 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/tnvt.java	Fri Aug 01 10:25:44 2014 -0700
@@ -23,6 +23,8 @@
  */
 package org.tn5250j.framework.tn5250;
 
+import static java.lang.Math.max;
+import static java.lang.Math.min;
 import static org.tn5250j.TN5250jConstants.AID_HELP;
 import static org.tn5250j.TN5250jConstants.AID_PRINT;
 import static org.tn5250j.TN5250jConstants.CMD_CLEAR_FORMAT_TABLE;
@@ -1145,7 +1147,7 @@
             else {
                 if (planes.getCharAttr(y) != la) {
                     la = planes.getCharAttr(y);
-                    sac--;
+                    sac = max(sac--, 0);
                     sa[sac++] = (byte) la;
                 }
 
@@ -1160,7 +1162,7 @@
                 if (isDataUnicode(ch))
                     byteCh = codePage.uni2ebcdic(ch);
 
-                sa[sac++] = byteCh;
+                sa[min(sac++, len - 1)] = byteCh;
             }
         }
     }
@@ -1203,7 +1205,7 @@
                 else {
                     if (planes.getCharAttr(y) != la) {
                         la = planes.getCharAttr(y);
-                        sac--;
+                        sac = max(sac--, 0);
                         sa[sac++] = (byte) la;
                     }
 
@@ -1218,7 +1220,7 @@
                     if (isDataUnicode(ch))
                         byteCh = codePage.uni2ebcdic(ch);
 
-                    sa[sac++] = byteCh;
+                    sa[min(sac++, len - 1)] = byteCh;
                 }
             }
         }