changeset 123:446dbcf606eb

add more 5250 config items; ignore drawing outside the screen
author Carl Byington <carl@five-ten-sg.com>
date Thu, 19 Jun 2014 08:28:23 -0700
parents 52b1d0ee27b1
children c29fd84dff5f
files res/xml/host_prefs.xml src/com/five_ten_sg/connectbot/HostEditorActivity.java src/com/five_ten_sg/connectbot/bean/HostBean.java src/com/five_ten_sg/connectbot/util/HostDatabase.java src/de/mud/terminal/VDUBuffer.java src/org/tn5250j/framework/tn5250/ScreenPlanes.java
diffstat 6 files changed, 61 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/res/xml/host_prefs.xml	Wed Jun 18 19:00:34 2014 -0700
+++ b/res/xml/host_prefs.xml	Thu Jun 19 08:28:23 2014 -0700
@@ -140,6 +140,12 @@
             android:summary="@string/hostpref_emulation_summary"
             android:singleLine="true"
             />
+    </PreferenceCategory>
+
+
+    <PreferenceCategory
+        android:key="5250"
+        android:title="@string/hostpref_5250_settings">
 
         <ListPreference
             android:key="encryption5250"
@@ -147,10 +153,29 @@
 			android:entries="@array/list_5250_encryption_modes"
 			android:entryValues="@array/list_5250_encryption_modes"
             />
+
+        <EditTextPreference
+            android:key="library5250"
+            android:title="@string/hostpref_5250_library_title"
+            android:singleLine="true"
+            />
+
+        <EditTextPreference
+            android:key="menu5250"
+            android:title="@string/hostpref_5250_menu_title"
+            android:singleLine="true"
+            />
+
+        <EditTextPreference
+            android:key="program5250"
+            android:title="@string/hostpref_5250_program_title"
+            android:singleLine="true"
+            />
     </PreferenceCategory>
 
 
     <PreferenceCategory
+        android:key="x11"
         android:title="@string/hostpref_x11_forwarding">
 
         <CheckBoxPreference
--- a/src/com/five_ten_sg/connectbot/HostEditorActivity.java	Wed Jun 18 19:00:34 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/HostEditorActivity.java	Thu Jun 19 08:28:23 2014 -0700
@@ -268,10 +268,11 @@
         findPreference(HostDatabase.FIELD_HOST_COMPRESSION).setEnabled(enableSSHFeatures);
         findPreference(HostDatabase.FIELD_HOST_HTTPPROXY).setEnabled(enableAsyncFeatures);
         findPreference(HostDatabase.FIELD_HOST_WANTSESSION).setEnabled(enableSSHFeatures);
-        findPreference(HostDatabase.FIELD_HOST_USERNAME).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.FIELD_HOST_USERNAME).setEnabled(enableSSHFeatures || enable5250Features);
         findPreference(HostDatabase.FIELD_HOST_EMULATION).setEnabled(!enable5250Features);
+        findPreference(HostDatabase.CATEGORY_5250).setEnabled(enable5250Features);
         findPreference(HostDatabase.FIELD_HOST_ENCRYPTION5250).setEnabled(enable5250Features);
-        findPreference(HostDatabase.FIELD_HOST_WANTX11FORWARD).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.CATEGORY_X11).setEnabled(enableSSHFeatures);
         findPreference(HostDatabase.FIELD_HOST_X11HOST).setEnabled(enableSSHFeatures);
         findPreference(HostDatabase.FIELD_HOST_X11PORT).setEnabled(enableSSHFeatures);
         // add all existing pubkeys to our listpreference for user to choose from
@@ -338,7 +339,6 @@
         for (String key : this.pref.values.keySet()) {
              if (key.equals(HostDatabase.FIELD_HOST_POSTLOGIN)) continue;
              if (key.equals(HostDatabase.FIELD_HOST_EMULATION)) continue;
-             if (key.equals(HostDatabase.FIELD_HOST_MONITOR)) continue;
 
             Preference pref = this.findPreference(key);
 
--- a/src/com/five_ten_sg/connectbot/bean/HostBean.java	Wed Jun 18 19:00:34 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/bean/HostBean.java	Thu Jun 19 08:28:23 2014 -0700
@@ -56,7 +56,6 @@
     private String  monitor = null;
     private String  hostemulation = null;
     private String  encryption5250 = null;
-    private String  password = null;
     private String  library = null;
     private String  initialMenu = null;
     private String  program = null;
@@ -290,14 +289,6 @@
         this.encryption5250 = encryption5250;
     }
 
-    public String getPassword() {
-        return this.password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
     public String getLibrary() {
         return this.library;
     }
@@ -351,6 +342,9 @@
         values.put(HostDatabase.FIELD_HOST_MONITOR, monitor);
         values.put(HostDatabase.FIELD_HOST_EMULATION, hostemulation);
         values.put(HostDatabase.FIELD_HOST_ENCRYPTION5250, encryption5250);
+        values.put(HostDatabase.FIELD_HOST_LIBRARY5250, library);
+        values.put(HostDatabase.FIELD_HOST_MENU5250, initialMenu);
+        values.put(HostDatabase.FIELD_HOST_PROGRAM5250, program);
         return values;
     }
 
--- a/src/com/five_ten_sg/connectbot/util/HostDatabase.java	Wed Jun 18 19:00:34 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/util/HostDatabase.java	Thu Jun 19 08:28:23 2014 -0700
@@ -46,7 +46,7 @@
     public final static String TAG = "ConnectBot.HostDatabase";
 
     public final static String DB_NAME = "hosts";
-    public final static int DB_VERSION = 26;
+    public final static int DB_VERSION = 27;
 
     public final static String TABLE_HOSTS = "hosts";
     public final static String FIELD_HOST_NICKNAME = "nickname";
@@ -75,6 +75,11 @@
     public final static String FIELD_HOST_MONITOR = "monitor";
     public final static String FIELD_HOST_EMULATION = "emulation";
     public final static String FIELD_HOST_ENCRYPTION5250 = "encryption5250";
+    public final static String FIELD_HOST_LIBRARY5250 = "library5250";
+    public final static String FIELD_HOST_MENU5250 = "menu5250";
+    public final static String FIELD_HOST_PROGRAM5250 = "program5250";
+    public final static String CATEGORY_5250 = "5250";
+    public final static String CATEGORY_X11 = "x11";
 
     public final static String TABLE_PORTFORWARDS = "portforwards";
     public final static String FIELD_PORTFORWARD_HOSTID = "hostid";
@@ -183,7 +188,10 @@
                    + FIELD_HOST_X11PORT + " INTEGER DEFAULT " + X11PORT_DEFAULT + ", "
                    + FIELD_HOST_MONITOR + " TEXT, "
                    + FIELD_HOST_EMULATION + " TEXT, "
-                   + FIELD_HOST_ENCRYPTION5250 + " TEXT)");
+                   + FIELD_HOST_ENCRYPTION5250 + " TEXT, "
+                   + FIELD_HOST_LIBRARY5250 + " TEXT, "
+                   + FIELD_HOST_MENU5250 + " TEXT, "
+                   + FIELD_HOST_PROGRAM5250 + " TEXT)");
         db.execSQL("CREATE TABLE " + TABLE_PORTFORWARDS
                    + " (_id INTEGER PRIMARY KEY, "
                    + FIELD_PORTFORWARD_HOSTID + " INTEGER, "
@@ -300,6 +308,14 @@
                            + " ADD COLUMN " + FIELD_HOST_EMULATION + " TEXT");
                 db.execSQL("ALTER TABLE " + TABLE_HOSTS
                            + " ADD COLUMN " + FIELD_HOST_ENCRYPTION5250 + " TEXT");
+
+            case 26:
+                db.execSQL("ALTER TABLE " + TABLE_HOSTS
+                           + " ADD COLUMN " + FIELD_HOST_LIBRARY5250 + " TEXT");
+                db.execSQL("ALTER TABLE " + TABLE_HOSTS
+                           + " ADD COLUMN " + FIELD_HOST_MENU5250 + " TEXT");
+                db.execSQL("ALTER TABLE " + TABLE_HOSTS
+                           + " ADD COLUMN " + FIELD_HOST_PROGRAM5250 + " TEXT");
         }
     }
 
@@ -416,6 +432,9 @@
                   COL_MONITOR = c.getColumnIndexOrThrow(FIELD_HOST_MONITOR),
                   COL_EMULATION = c.getColumnIndexOrThrow(FIELD_HOST_EMULATION),
                   COL_ENCRYPTION5250 = c.getColumnIndexOrThrow(FIELD_HOST_ENCRYPTION5250);
+                  COL_LIBRARY5250 = c.getColumnIndexOrThrow(FIELD_HOST_LIBRARY5250);
+                  COL_MENU5250 = c.getColumnIndexOrThrow(FIELD_HOST_MENU5250);
+                  COL_PROGRAM5250 = c.getColumnIndexOrThrow(FIELD_HOST_PROGRAM5250);
 
         while (c.moveToNext()) {
             HostBean host = new HostBean();
@@ -444,6 +463,9 @@
             host.setMonitor(c.getString(COL_MONITOR));
             host.setHostEmulation(c.getString(COL_EMULATION));
             host.setEncryption5250(c.getString(COL_ENCRYPTION5250));
+            host.setLibrary(c.getString(COL_LIBRARY5250));
+            host.setInitialMenu(c.getString(COL_MENU5250));
+            host.setProgram(c.getString(COL_PROGRAM5250));
             hosts.add(host);
         }
 
--- a/src/de/mud/terminal/VDUBuffer.java	Wed Jun 18 19:00:34 2014 -0700
+++ b/src/de/mud/terminal/VDUBuffer.java	Thu Jun 19 08:28:23 2014 -0700
@@ -158,8 +158,10 @@
      */
 
     public void putChar(int c, int l, char ch, int attributes) {
-        charArray[screenBase + l][c] = ch;
-        charAttributes[screenBase + l][c] = attributes;
+        int ll = screenBase + l;
+        if ((ll >= bufSize) || (c >= width)) return;    // ignore characters outside our buffer
+        charArray[ll][c] = ch;
+        charAttributes[ll][c] = attributes;
 
         if (l < height)
             update[l + 1] = true;
@@ -586,8 +588,8 @@
      * @param l line
      */
     public void setCursorPosition(int c, int l) {
-        cursorX = c;
-        cursorY = l;
+        cursorX = min(width-1, c);
+        cursorY = min(height-1, l);
     }
 
     /**
--- a/src/org/tn5250j/framework/tn5250/ScreenPlanes.java	Wed Jun 18 19:00:34 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/ScreenPlanes.java	Thu Jun 19 08:28:23 2014 -0700
@@ -27,8 +27,6 @@
 
 import static org.tn5250j.TN5250jConstants.*;
 
-import java.util.Properties;
-
 public class ScreenPlanes {
 
     private final Screen5250 scr;