# HG changeset patch # User Carl Byington # Date 1402932240 25200 # Node ID 01d939969b10a1aa576f49755f286d0ced71aca1 # Parent b3d0d806cbe2567100d5df978a5617f0f47bcc32# Parent 044b1a9519257e8ea947b6746e5c1c8e7ba1b879 merge tn5250 branch into default diff -r 044b1a951925 -r 01d939969b10 res/values/version.xml --- a/res/values/version.xml Sun Jun 15 11:05:06 2014 -0700 +++ b/res/values/version.xml Mon Jun 16 08:24:00 2014 -0700 @@ -1,4 +1,4 @@ - 510 ConnectBot 1.7.2-1 (e11983ee7321+ 2014-04-20) + 510Connectbot 1.7.2-1 (ab7313512aba+ 2014-05-29) diff -r 044b1a951925 -r 01d939969b10 src/com/five_ten_sg/connectbot/service/TerminalBridge.java diff -r 044b1a951925 -r 01d939969b10 src/com/five_ten_sg/connectbot/service/TerminalMonitor.java --- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Sun Jun 15 11:05:06 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Mon Jun 16 08:24:00 2014 -0700 @@ -16,6 +16,9 @@ import java.net.Socket; import java.nio.charset.Charset; import java.util.HashMap; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ConcurrentHashMap; public class TerminalMonitor { public final static String TAG = "ConnectBot.TerminalMonitor"; @@ -43,13 +46,17 @@ private int end_line = 500; // "" private int start_column = 0; // "" private int end_column = 500; // "" - private boolean modified = false; // "" + 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 keymap = null; private IBinder bound = null; private Socket monitor_socket = null; private InputStream monitor_in = null; private OutputStream monitor_out = null; private MyReader monitor_reader = null; + private BlockingQueue pending_commands = new ArrayBlockingQueue(100); private MyServiceConnection monitor_connection = new MyServiceConnection(); class MyReader extends Thread { @@ -141,6 +148,12 @@ monitor_reader.start(); String x = " " + init; monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); + char [] c; + while (true) { + c = pending_commands.poll(); + if (c == null) break; + monitorWrite(c[1], c); + } } catch (IOException e) { Log.e(TAG, "exception in onServiceConnected()", e); @@ -161,7 +174,7 @@ this.init = init; // setup the windows->android keymapping - // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx + // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 // http://developer.android.com/reference/android/view/KeyEvent.html keymap = new HashMap(); keymap.put(0x08, KeyEvent.KEYCODE_BACK); // vk_back @@ -260,6 +273,13 @@ //Log.i(TAG, String.format("sending %d command", (int)cmd)); monitor_out.write(charsToBytes(c)); } + else { + c[1] = cmd; + pending_commands.put(c); + } + } + catch (InterruptedException e) { + Log.e(TAG, "exception in monitorWrite()", e); } catch (IOException e) { Log.i(TAG, "exception in monitorWrite(), monitor died or closed the socket", e); @@ -294,7 +314,6 @@ } public synchronized void hostData(byte[] b) { - if (b == null) return; for (int i = 0; i < b.length; i++) { hostData((int)b[i] & 0xff); } @@ -307,9 +326,15 @@ } public synchronized void cursorMove(int l, int c) { + moved = true; + to_line = l; + to_column = c; + } + + public void cursorMoved() { char[] arg = new char[4]; - arg[2] = (char)(l & 0x0000ffff); - arg[3] = (char)(c & 0x0000ffff); + arg[2] = (char)(to_line & 0x0000ffff); + arg[3] = (char)(to_column & 0x0000ffff); monitorWrite(MONITOR_CMD_CURSORMOVE, arg); } @@ -318,6 +343,10 @@ modified = false; sendScreen(MONITOR_CMD_SCREENCHANGE); } + if (moved) { + moved = false; + cursorMoved(); + } } public synchronized void screenChanged(int llow, int lhigh, int clow, int chigh) { @@ -332,9 +361,12 @@ public synchronized void setField(int l, int c, char[] data, int offset) { Log.i(TAG, "setField()"); - char[] d = new char[data.length - offset]; - System.arraycopy(data, offset, d, 0, data.length - offset); - buffer.setField(l, c, d); + byte[] b = new byte[data.length - offset]; + int i; + for (i=0; i