Mercurial > 510Connectbot
changeset 52:0e3fc85d0586 tn5250
start tn5250 integration
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 11 Jun 2014 12:18:18 -0700 |
parents | 8c6de858bb73 |
children | e872762ec105 |
files | src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java src/com/five_ten_sg/connectbot/transport/TN5250.java |
diffstat | 2 files changed, 26 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java Wed Jun 11 11:54:52 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java Wed Jun 11 12:18:18 2014 -0700 @@ -121,6 +121,10 @@ buffer.write(0x1b); } + protected void sendEncoded(String s) { + buffer.write(s.getBytes(encoding)); + } + /** * Handle onKey() events coming down from a {@link com.five_ten_sg.connectbot.TerminalView} above us. * Modify the keys to make more sense to a host then pass it to the vt320. @@ -198,8 +202,7 @@ if (keyCode == KeyEvent.KEYCODE_UNKNOWN && event.getAction() == KeyEvent.ACTION_MULTIPLE) { - byte[] input = event.getCharacters().getBytes(encoding); - buffer.write(input); + sendEncoded(event.getCharacters()); return true; } @@ -289,9 +292,7 @@ if (uchar < 0x80) buffer.write(uchar); else - // TODO write encoding routine that doesn't allocate each time - buffer.write(new String(Character.toChars(uchar)) - .getBytes(encoding)); + sendEncoded(new String(Character.toChars(uchar))); return true; } @@ -794,7 +795,7 @@ } } - private void metaKeyUp(int code) { + protected void metaKeyUp(int code) { if ((metaState & code) != 0) { metaState &= ~code; bridge.redraw();
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java Wed Jun 11 11:54:52 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java Wed Jun 11 12:18:18 2014 -0700 @@ -153,7 +153,7 @@ else if (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT && (metaState & META_TAB) != 0) { metaState &= ~(META_TAB | META_TRANSIENT); - buffer.write("[tab]"); + sendEncoded("[tab]"); return true; } } @@ -167,7 +167,7 @@ else if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT && (metaState & META_TAB) != 0) { metaState &= ~(META_TAB | META_TRANSIENT); - buffer.write("[tab]"); + sendEncoded("[tab]"); return true; } } @@ -270,7 +270,7 @@ if (uchar < 0x80) buffer.write(uchar); else - buffer.write(new String(Character.toChars(uchar)).getBytes(encoding)); + sendEncoded(new String(Character.toChars(uchar))); return true; } @@ -400,29 +400,29 @@ return true; case KeyEvent.KEYCODE_TAB: - buffer.write("[tab]"); + sendEncoded("[tab]"); return true; case KEYCODE_PAGE_DOWN: - buffer.write("[pgdown]"); + sendEncoded("[pgdown]"); metaState &= ~META_TRANSIENT; bridge.tryKeyVibrate(); return true; case KEYCODE_PAGE_UP: - buffer.write("[pgup]"); + sendEncoded("[pgup]"); metaState &= ~META_TRANSIENT; bridge.tryKeyVibrate(); return true; case KeyEvent.KEYCODE_MOVE_HOME: - buffer.write("[home]"); + sendEncoded("[home]"); metaState &= ~META_TRANSIENT; bridge.tryKeyVibrate(); return true; case KeyEvent.KEYCODE_MOVE_END: - buffer.write("[end]"); // does not exist!! + sendEncoded("[end]"); // does not exist!! metaState &= ~META_TRANSIENT; bridge.tryKeyVibrate(); return true; @@ -457,17 +457,17 @@ case KeyEvent.KEYCODE_DEL: if ((metaState & META_ALT_MASK) != 0) { - buffer.write("[insert]"); + sendEncoded("[insert]"); } else { - buffer.write("[backspace]"); + sendEncoded("[backspace]"); } metaState &= ~META_TRANSIENT; return true; case KeyEvent.KEYCODE_ENTER: - buffer.write("[enter]"); + sendEncoded("[enter]"); metaState &= ~META_TRANSIENT; return true; @@ -478,10 +478,10 @@ } else { if ((metaState & META_ALT_MASK) != 0) { - buffer.write("[home]"); + sendEncoded("[home]"); } else { - buffer.write("[left]"); + sendEncoded("[left]"); } metaState &= ~META_TRANSIENT; @@ -497,10 +497,10 @@ } else { if ((metaState & META_ALT_MASK) != 0) { - buffer.write("[pgup]"); + sendEncoded("[pgup]"); } else { - buffer.write("[up]"); + sendEncoded("[up]"); } metaState &= ~META_TRANSIENT; @@ -516,10 +516,10 @@ } else { if ((metaState & META_ALT_MASK) != 0) { - buffer.write("[pgdown]"); + sendEncoded("[pgdown]"); } else { - buffer.write("[down]"); + sendEncoded("[down]"); } metaState &= ~META_TRANSIENT; @@ -535,10 +535,10 @@ } else { if ((metaState & META_ALT_MASK) != 0) { - buffer.write("[end]"); + sendEncoded("[end]"); // does not exist!! } else { - buffer.write("[right]"); + sendEncoded("[right]"); } metaState &= ~META_TRANSIENT;