Mercurial > 510Connectbot
diff src/com/five_ten_sg/connectbot/service/TerminalMonitor.java @ 112:77ac18bc1b2f
cleanup java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 18 Jun 2014 13:03:01 -0700 |
parents | f0ec55006f31 |
children | cb3b9b660b3d |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Wed Jun 18 13:03:01 2014 -0700 @@ -50,7 +50,7 @@ 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; + private HashMap<Integer, Integer> keymap = null; private IBinder bound = null; private Socket monitor_socket = null; private InputStream monitor_in = null; @@ -103,21 +103,25 @@ case MONITOR_CMD_SETFIELD: if (packet.length >= 4) setField(packet[1], packet[2], packet, 3); + break; case MONITOR_CMD_GETFIELD: if (packet.length == 4) getField(packet[1], packet[2], packet[3]); + break; case MONITOR_CMD_SCREENWATCH: if (packet.length == 4) screenWatch(packet[1], packet[2], packet[3]); + break; case MONITOR_CMD_DEPRESS: if (packet.length == 2) depress(packet[1]); + break; default: @@ -149,9 +153,12 @@ 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); } } @@ -172,11 +179,10 @@ this.keyListener = keyListener; this.view = view; this.init = init; - // setup the windows->android keymapping // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 // http://developer.android.com/reference/android/view/KeyEvent.html - keymap = new HashMap<Integer,Integer>(); + keymap = new HashMap<Integer, Integer>(); keymap.put(0x08, KeyEvent.KEYCODE_BACK); // vk_back keymap.put(0x09, KeyEvent.KEYCODE_TAB); // vk_tab keymap.put(0x0d, KeyEvent.KEYCODE_ENTER); // vk_return @@ -203,7 +209,6 @@ keymap.put(0x79, KeyEvent.KEYCODE_F10); // vk_f10 keymap.put(0x7a, KeyEvent.KEYCODE_F11); // vk_f11 keymap.put(0x7b, KeyEvent.KEYCODE_F12); // vk_f12 - // bind to the monitor service Intent intent = new Intent("com.five_ten_sg.connectbot.monitor.MonitorService"); parent.bindService(intent, monitor_connection, Context.BIND_AUTO_CREATE); @@ -302,10 +307,12 @@ arg[2] = lines; arg[3] = columns; int base = 4; + for (int i = 0; i < lines; i++) { System.arraycopy(buffer.charArray[buffer.screenBase + i], 0, arg, base, columns); base += columns; } + monitorWrite(cmd, arg); } @@ -343,6 +350,7 @@ modified = false; sendScreen(MONITOR_CMD_SCREENCHANGE); } + if (moved) { moved = false; cursorMoved(); @@ -363,9 +371,11 @@ Log.i(TAG, "setField()"); char[] da = new char[data.length - offset]; int i; - for (i=0; i<da.length; i++) { - da[i] = data[i+offset]; + + for (i = 0; i < da.length; i++) { + da[i] = data[i + offset]; } + buffer.setField(l, c, da); } @@ -390,6 +400,7 @@ public synchronized void depress(int vk_key) { Log.i(TAG, String.format("depress() %d", vk_key)); Integer x = keymap.get(new Integer(vk_key)); + if (x != null) { KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, x.intValue()); keyListener.onKey(view, event.getKeyCode(), event);