comparison src/com/five_ten_sg/connectbot/service/TerminalMonitor.java @ 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 2dd627df4dfb
children ea49747c5447
comparison
equal deleted inserted replaced
228:c9a7f33b53a8 229:594101a0876a
39 public static final char MONITOR_CMD_DEPRESS = 8; 39 public static final char MONITOR_CMD_DEPRESS = 8;
40 public static final char MONITOR_CMD_SHOWURL = 9; 40 public static final char MONITOR_CMD_SHOWURL = 9;
41 public static final char MONITOR_CMD_SWITCHSESSION = 10; 41 public static final char MONITOR_CMD_SWITCHSESSION = 10;
42 public static final char MONITOR_CMD_CURSORREQUEST = 11; 42 public static final char MONITOR_CMD_CURSORREQUEST = 11;
43 43
44 public static final char CURSOR_REQUESTED = 0;
45 public static final char CURSOR_SCREEN_CHANGE = 1;
46 public static final char CURSOR_USER_KEY = 2;
47
44 private static final int MONITORPORT = 6000; 48 private static final int MONITORPORT = 6000;
45 private static final String LOCALHOST = "127.0.0.1"; 49 private static final String LOCALHOST = "127.0.0.1";
46 50
47 private Context parent = null; 51 private Context parent = null;
48 private vt320 buffer = null; 52 private vt320 buffer = null;
52 private int start_line = 0; // monitor part of the screen for changes 56 private int start_line = 0; // monitor part of the screen for changes
53 private int end_line = 500; // "" 57 private int end_line = 500; // ""
54 private int start_column = 0; // "" 58 private int start_column = 0; // ""
55 private int end_column = 500; // "" 59 private int end_column = 500; // ""
56 private boolean modified = false; // used to delay screen change notifications 60 private boolean modified = false; // used to delay screen change notifications
61 private boolean moved = false; // used to delay cursor moved notifications
57 private int to_line = 0; // "" 62 private int to_line = 0; // ""
58 private int to_column = 0; // "" 63 private int to_column = 0; // ""
59 private HashMap<Integer, Integer> keymap = null; // map MS VK_ keys to vt320 virtual keys 64 private HashMap<Integer, Integer> keymap = null; // map MS VK_ keys to vt320 virtual keys
60 private IBinder bound = null; 65 private IBinder bound = null;
61 private Socket monitor_socket = null; 66 private Socket monitor_socket = null;
368 arg[2] = (char)((down) ? 1 : 0); 373 arg[2] = (char)((down) ? 1 : 0);
369 monitorWrite(MONITOR_CMD_KEYSTATE, arg); 374 monitorWrite(MONITOR_CMD_KEYSTATE, arg);
370 } 375 }
371 376
372 public synchronized void cursorMove(int l, int c) { 377 public synchronized void cursorMove(int l, int c) {
378 if ((to_line != l) || (to_column != c)) moved = true;
373 to_line = l; 379 to_line = l;
374 to_column = c; 380 to_column = c;
375 } 381 }
376 382
377 public void cursorMoved() { 383 public void cursorMoved(char why) {
378 char[] arg = new char[4]; 384 char[] arg = new char[5];
379 arg[2] = (char)(to_line & 0x0000ffff); 385 arg[2] = (char)(to_line & 0x0000ffff);
380 arg[3] = (char)(to_column & 0x0000ffff); 386 arg[3] = (char)(to_column & 0x0000ffff);
387 arg[4] = why;
381 monitorWrite(MONITOR_CMD_CURSORMOVE, arg); 388 monitorWrite(MONITOR_CMD_CURSORMOVE, arg);
389 moved = false;
390 }
391
392 public void testMoved() {
393 if (moved) cursorMoved(CURSOR_USER_KEY);
382 } 394 }
383 395
384 public synchronized void testChanged() { 396 public synchronized void testChanged() {
385 if (modified) { 397 if (modified) {
386 modified = false; 398 modified = false;
387 sendScreen(MONITOR_CMD_SCREENCHANGE); 399 sendScreen(MONITOR_CMD_SCREENCHANGE);
388 cursorMoved(); 400 cursorMoved(CURSOR_SCREEN_CHANGE);
401 }
402 else {
403 if (moved) cursorMoved(CURSOR_SCREEN_CHANGE);
389 } 404 }
390 } 405 }
391 406
392 public synchronized void screenChanged(int llow, int lhigh, int clow, int chigh) { 407 public synchronized void screenChanged(int llow, int lhigh, int clow, int chigh) {
393 if ((start_line <= lhigh) && (llow <= end_line) && (start_column <= chigh) && (clow <= end_column)) { 408 if ((start_line <= lhigh) && (llow <= end_line) && (start_column <= chigh) && (clow <= end_column)) {
450 } 465 }
451 466
452 467
453 public synchronized void cursorRequest() { 468 public synchronized void cursorRequest() {
454 Log.i(TAG, "cursorRequest()"); 469 Log.i(TAG, "cursorRequest()");
455 cursorMoved(); 470 cursorMoved(CURSOR_REQUESTED);
456 } 471 }
457 472
458 } 473 }