changeset 229:594101a0876a

add why argument on cursor updates
author Carl Byington <carl@five-ten-sg.com>
date Wed, 09 Jul 2014 09:37:00 -0700
parents c9a7f33b53a8
children bc40032ad1da
files src/com/five_ten_sg/connectbot/service/TerminalMonitor.java src/com/five_ten_sg/connectbot/transport/TN5250.java xml/510connectbot.in
diffstat 3 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Wed Jul 09 09:05:05 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Wed Jul 09 09:37:00 2014 -0700
@@ -41,6 +41,10 @@
     public  static final char MONITOR_CMD_SWITCHSESSION = 10;
     public  static final char MONITOR_CMD_CURSORREQUEST = 11;
 
+    public  static final char CURSOR_REQUESTED      = 0;
+    public  static final char CURSOR_SCREEN_CHANGE  = 1;
+    public  static final char CURSOR_USER_KEY       = 2;
+
     private static final int    MONITORPORT       = 6000;
     private static final String LOCALHOST         = "127.0.0.1";
 
@@ -54,6 +58,7 @@
     private int                 start_column = 0;       // ""
     private int                 end_column   = 500;     // ""
     private boolean             modified     = false;   // used to delay screen change notifications
+    private boolean             moved        = false;   // used to delay cursor moved notifications
     private int                 to_line      = 0;       // ""
     private int                 to_column    = 0;       // ""
     private HashMap<Integer, Integer>  keymap = null;   // map MS VK_ keys to vt320 virtual keys
@@ -370,22 +375,32 @@
     }
 
     public synchronized void cursorMove(int l, int c) {
+        if ((to_line != l) || (to_column != c)) moved = true;
         to_line = l;
         to_column = c;
     }
 
-    public void cursorMoved() {
-        char[] arg = new char[4];
+    public void cursorMoved(char why) {
+        char[] arg = new char[5];
         arg[2] = (char)(to_line & 0x0000ffff);
         arg[3] = (char)(to_column & 0x0000ffff);
+        arg[4] = why;
         monitorWrite(MONITOR_CMD_CURSORMOVE, arg);
+        moved = false;
+    }
+
+    public void testMoved() {
+        if (moved) cursorMoved(CURSOR_USER_KEY);
     }
 
     public synchronized void testChanged() {
         if (modified) {
             modified = false;
             sendScreen(MONITOR_CMD_SCREENCHANGE);
-            cursorMoved();
+            cursorMoved(CURSOR_SCREEN_CHANGE);
+        }
+        else {
+            if (moved) cursorMoved(CURSOR_SCREEN_CHANGE);
         }
     }
 
@@ -452,7 +467,7 @@
 
     public synchronized void cursorRequest() {
         Log.i(TAG, "cursorRequest()");
-        cursorMoved();
+        cursorMoved(CURSOR_REQUESTED);
     }
 
 }
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java	Wed Jul 09 09:05:05 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java	Wed Jul 09 09:37:00 2014 -0700
@@ -177,18 +177,18 @@
         @Override
         public void write(byte[] b) {
             screen52.sendKeys(new String(b));
-            if (bridge.monitor != null) bridge.monitor.cursorMoved();
+            if (bridge.monitor != null) bridge.monitor.testMoved();
         }
         @Override
         public void write(int b) {
             if (controls.containsKey(b)) keyPressed(controls.get(b), ' ', 0);
             else                         screen52.sendKeys(new String(new byte[] {(byte)b}));
-            if (bridge.monitor != null) bridge.monitor.cursorMoved();
+            if (bridge.monitor != null) bridge.monitor.testMoved();
         }
         @Override
         public void keyPressed(int keyCode, char keyChar, int modifiers) {
             keyDepressed(keyCode, keyChar, modifiers);
-            if (bridge.monitor != null) bridge.monitor.cursorMoved();
+            if (bridge.monitor != null) bridge.monitor.testMoved();
         }
 
         // 5250 writing to the screen
--- a/xml/510connectbot.in	Wed Jul 09 09:05:05 2014 -0700
+++ b/xml/510connectbot.in	Wed Jul 09 09:37:00 2014 -0700
@@ -152,8 +152,12 @@
 
             <para>
                 CURSORMOVE = 3 (TE -> Monitor).
-                The first argument is the line number (0..23)
-                and the second argument is the column number (0..79).
+                The first argument is the line number (0..23),
+                the second argument is the column number (0..79), and the third
+                argument is the reason for sending this cursor update. REASON=0 is
+                from a previous CURSORREQUEST command. REASON=1 is a cursor update
+                related to the previous SCREENCHANGE buffer update. REASON=2 is
+                a cursor update caused by user keystrokes.
             </para>
 
             <para>