changeset 147:1350adb077b1

monitor key state tracking
author Carl Byington <carl@five-ten-sg.com>
date Sun, 22 Jun 2014 07:57:20 -0700
parents 8754f293f2fd
children 69333ca1563c
files src/com/five_ten_sg/connectbot/service/TerminalMonitor.java src/com/five_ten_sg/connectbot/transport/AbsTransport.java src/com/five_ten_sg/connectbot/transport/TN5250.java xml/510connectbot.in
diffstat 4 files changed, 12 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Sat Jun 21 17:54:29 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Sun Jun 22 07:57:20 2014 -0700
@@ -24,7 +24,7 @@
 
     public  static final char MONITOR_CMD_INIT         = 0;
     public  static final char MONITOR_CMD_ACTIVATE     = 1;
-    public  static final char MONITOR_CMD_HOSTDATA     = 2;
+    public  static final char MONITOR_CMD_KEYSTATE     = 2;
     public  static final char MONITOR_CMD_CURSORMOVE   = 3;
     public  static final char MONITOR_CMD_SCREENCHANGE = 4;
     public  static final char MONITOR_CMD_FIELDVALUE   = 5;
@@ -316,16 +316,10 @@
         sendScreen(MONITOR_CMD_ACTIVATE);
     }
 
-    public synchronized void hostData(byte[] b) {
-        for (int i = 0; i < b.length; i++) {
-            hostData((int)b[i] & 0xff);
-        }
-    }
-
-    public synchronized void hostData(int b) {
+    public synchronized void keyState(int b) {
         char[] arg = new char[3];
         arg[2] = (char)(b & 0x0000ffff);
-        monitorWrite(MONITOR_CMD_HOSTDATA, arg);
+        monitorWrite(MONITOR_CMD_KEYSTATE, arg);
     }
 
     public synchronized void cursorMove(int l, int c) {
--- a/src/com/five_ten_sg/connectbot/transport/AbsTransport.java	Sat Jun 21 17:54:29 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/AbsTransport.java	Sun Jun 22 07:57:20 2014 -0700
@@ -67,8 +67,6 @@
         @Override
         public void write(byte[] b) {
             try {
-                if (bridge.monitor != null) bridge.monitor.hostData(b);
-
                 AbsTransport.this.write(b);
             }
             catch (IOException e) {
@@ -78,8 +76,6 @@
         @Override
         public void write(int b) {
             try {
-                if (bridge.monitor != null) bridge.monitor.hostData(b);
-
                 AbsTransport.this.write(b);
             }
             catch (IOException e) {
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java	Sat Jun 21 17:54:29 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java	Sun Jun 22 07:57:20 2014 -0700
@@ -145,8 +145,6 @@
         // terminal key listener sending to local screen
         @Override
         public void write(byte[] b) {
-            if (bridge.monitor != null) bridge.monitor.hostData(b);
-
             screen52.sendKeys(new String(b));
         }
         @Override
@@ -161,25 +159,14 @@
                 setField(-1, -1, new char[] { '4', '5' });
                 return;
             }
-            if (controls.containsKey(b)) {
-                keyPressed(controls.get(b), ' ', 0);
-            }
-            else {
-                if (bridge.monitor != null) bridge.monitor.hostData(b);
-
-                screen52.sendKeys(new String(new byte[] {(byte)b}));
-            }
+            if (controls.containsKey(b)) keyPressed(controls.get(b), ' ', 0);
+            else                         screen52.sendKeys(new String(new byte[] {(byte)b}));
         }
         @Override
         public void keyPressed(int keyCode, char keyChar, int modifiers) {
             if (mnemonics.containsKey(keyCode)) {
                 String s = mnemonics.get(keyCode);
-
-                if (s != "") {
-                    if (bridge.monitor != null) bridge.monitor.hostData(s.getBytes());
-
-                    screen52.sendKeys(s);
-                }
+                if (s != "") screen52.sendKeys(s);
             }
         }
         // 5250 writing to the screen
@@ -405,8 +392,7 @@
         selection.put(HostDatabase.FIELD_HOST_HOSTNAME, uri.getHost());
         int port = uri.getPort();
 
-        if (port < 0)
-            port = DEFAULT_PORT;
+        if (port < 0) port = DEFAULT_PORT;
 
         selection.put(HostDatabase.FIELD_HOST_PORT, Integer.toString(port));
     }
@@ -419,8 +405,7 @@
         host.setHostname(uri.getHost());
         int port = uri.getPort();
 
-        if (port < 0)
-            port = DEFAULT_PORT;
+        if (port < 0) port = DEFAULT_PORT;
 
         host.setPort(port);
         String nickname = uri.getFragment();
--- a/xml/510connectbot.in	Sat Jun 21 17:54:29 2014 -0700
+++ b/xml/510connectbot.in	Sun Jun 22 07:57:20 2014 -0700
@@ -121,8 +121,10 @@
             </para>
 
             <para>
-                HOSTDATA = 2 (TE -> Monitor). The argument is a single uint16
-                value containing the 8 bit character that was sent to the host.
+                KEYSTATE = 2 (TE -> Monitor). The argument is a single uint16
+                value, 1 for key down, 0 for key up. The TE tracks a single special
+                key for the monitor, and reports key up/down state when it changes.
+                The actual key is configurable.
             </para>
 
             <para>