changeset 45:80dcebe51af2 tn5250

start tn5250 integration
author Carl Byington <carl@five-ten-sg.com>
date Wed, 11 Jun 2014 09:54:18 -0700
parents 959ebe0247b5
children 34ce32c4e807
files src/com/five_ten_sg/connectbot/service/TerminalBridge.java src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java src/com/five_ten_sg/connectbot/transport/AbsTransport.java src/com/five_ten_sg/connectbot/transport/TN5250.java src/de/mud/terminal/vt320.java
diffstat 5 files changed, 45 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java	Wed Jun 11 09:30:50 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java	Wed Jun 11 09:54:18 2014 -0700
@@ -258,7 +258,7 @@
      */
     public Charset getCharset() {
         if (relay != null) return relay.getCharset();
-
+        return keyListener.getCharset();
     }
 
     /**
@@ -268,7 +268,6 @@
      */
     public void setCharset(String encoding) {
         if (relay != null) relay.setCharset(encoding);
-
         keyListener.setCharset(encoding);
     }
 
--- a/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java	Wed Jun 11 09:30:50 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java	Wed Jun 11 09:54:18 2014 -0700
@@ -902,7 +902,9 @@
         this.encoding = encoding;
     }
 
-
+    public String getCharset() {
+        return encoding;
+    }
 
     private void ctrlKeySpecial() {
         if (selectingForCopy) {
--- a/src/com/five_ten_sg/connectbot/transport/AbsTransport.java	Wed Jun 11 09:30:50 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/AbsTransport.java	Wed Jun 11 09:54:18 2014 -0700
@@ -40,7 +40,7 @@
     protected TerminalManager manager;
     protected TerminalBridge  bridge;
     protected HostBean        host;
-    protected vt320           buffer;
+    protected vt320           buffer = null;
     protected String          emulation;
 
     class vt320Default extends vt320 {
@@ -238,7 +238,7 @@
     }
 
     public vt320 getTransportBuffer() {
-        buffer = vt320Default();
+        if (buffer == null) buffer = new vt320Default();
         int scrollback = (host.getWantSession()) ?  manager.getScrollback() : 0;
         buffer.setBufferSize(scrollback);
         buffer.setDisplay(bridge);
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java	Wed Jun 11 09:30:50 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java	Wed Jun 11 09:54:18 2014 -0700
@@ -63,8 +63,39 @@
         hostmask = Pattern.compile("^([0-9a-z.-]+)(:(\\d+))?$", Pattern.CASE_INSENSITIVE);
     }
 
+
+    class vt320x5250 extends vt320 {
+        @Override
+        public void debug(String s) {
+            Log.d(TAG, s);
+        }
+        @Override
+        public void write(byte[] b) {
+        }
+        @Override
+        public void write(int b) {
+        }
+        // bridge.monitor placement of new characters
+        @Override
+        public void putChar(int c, int l, char ch, int attributes) {
+            if (bridge.monitor != null) bridge.monitor.screenChanged(l, c);
+            super.putChar(c, l, ch, attributes);
+        }
+        @Override
+        public void setCursorPosition(int c, int l) {
+            if (bridge.monitor != null) bridge.monitor.cursorMove(l, c);
+            super.setCursorPosition(c, l);
+        }
+    };
+
+
     class Terminal5250KeyListener extends TerminalKeyListener {
-
+        public TerminalKeyListener(TerminalManager manager,
+                                   TerminalBridge bridge,
+                                   vt320 buffer,
+                                   String encoding) {
+            super(manager, bridge, buffer, encoding);
+        }
     };
 
     public TN5250() {
@@ -219,6 +250,13 @@
 
 
     @Override
+    public vt320 getTransportBuffer() {
+        buffer = new vt320x5250();
+        return super();
+    }
+
+
+    @Override
     public int getDefaultPort() {
         return DEFAULT_PORT;
     }
--- a/src/de/mud/terminal/vt320.java	Wed Jun 11 09:30:50 2014 -0700
+++ b/src/de/mud/terminal/vt320.java	Wed Jun 11 09:54:18 2014 -0700
@@ -39,12 +39,6 @@
  */
 public abstract class vt320 extends VDUBuffer implements VDUInput {
 
-    /** The current version id tag.<P>
-     * $Id: vt320.java 507 2005-10-25 10:14:52Z marcus $
-     *
-     */
-    public final static String ID = "$Id: vt320.java 507 2005-10-25 10:14:52Z marcus $";
-
     /** the debug level */
     private final static int debug = 0;
     private StringBuilder debugStr;