From 3d54a8402531d8642df9af9341d8ec699a3b1fc0 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sat, 27 Oct 2012 17:33:26 +0100 Subject: Fix Enter==Ctrl-M again Without this, commit 8ac74bb made the Enter key send Ctrl-J which broke some programs, though most didn't notice because termios() canonicalised either to '\n'. Also renamed the 'key' variable to 'uchar' since it holds a Unicode character number and not a keycode. --- .../connectbot/service/TerminalKeyListener.java | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/org/connectbot/service/TerminalKeyListener.java b/src/org/connectbot/service/TerminalKeyListener.java index 952f3cd..b825e6b 100644 --- a/src/org/connectbot/service/TerminalKeyListener.java +++ b/src/org/connectbot/service/TerminalKeyListener.java @@ -186,28 +186,26 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha curMetaState |= KeyEvent.META_ALT_ON; } - int key = event.getUnicodeChar(curMetaState); + int uchar = event.getUnicodeChar(curMetaState); // no hard keyboard? ALT-k should pass through to below if ((orgMetaState & KeyEvent.META_ALT_ON) != 0 && (!hardKeyboard || hardKeyboardHidden)) { - key = 0; + uchar = 0; } - if ((key & KeyCharacterMap.COMBINING_ACCENT) != 0) { - mDeadKey = key & KeyCharacterMap.COMBINING_ACCENT_MASK; + if ((uchar & KeyCharacterMap.COMBINING_ACCENT) != 0) { + mDeadKey = uchar & KeyCharacterMap.COMBINING_ACCENT_MASK; return true; } if (mDeadKey != 0) { - key = KeyCharacterMap.getDeadChar(mDeadKey, keyCode); + uchar = KeyCharacterMap.getDeadChar(mDeadKey, keyCode); mDeadKey = 0; } - final boolean printing = (key != 0); - // otherwise pass through to existing session // print normal keys - if (printing) { + if (uchar >= 0x20) { metaState &= ~(META_SLASH | META_TAB); // Remove shift and alt modifiers @@ -227,7 +225,7 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha && sendFunctionKey(keyCode)) return true; - key = keyAsControl(key); + uchar = keyAsControl(uchar); } // handle pressing f-keys @@ -236,11 +234,11 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha && sendFunctionKey(keyCode)) return true; - if (key < 0x80) - bridge.transport.write(key); + if (uchar < 0x80) + bridge.transport.write(uchar); else // TODO write encoding routine that doesn't allocate each time - bridge.transport.write(new String(Character.toChars(key)) + bridge.transport.write(new String(Character.toChars(uchar)) .getBytes(encoding)); return true; -- cgit v1.2.3