comparison src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java @ 49:8887bff45dee tn5250

start tn5250 integration
author Carl Byington <carl@five-ten-sg.com>
date Wed, 11 Jun 2014 11:28:31 -0700
parents 1e931ef5f776
children 2cd3d8091e37
comparison
equal deleted inserted replaced
48:1e931ef5f776 49:8887bff45dee
43 import android.widget.AdapterView; 43 import android.widget.AdapterView;
44 import android.widget.AdapterView.OnItemClickListener; 44 import android.widget.AdapterView.OnItemClickListener;
45 import android.widget.ArrayAdapter; 45 import android.widget.ArrayAdapter;
46 import android.widget.ListView; 46 import android.widget.ListView;
47 import android.widget.TextView; 47 import android.widget.TextView;
48 import android.widget.Toast;
49 import de.mud.terminal.VDUBuffer; 48 import de.mud.terminal.VDUBuffer;
50 import de.mud.terminal.vt320; 49 import de.mud.terminal.vt320;
51 50
52 /** 51 /**
53 * @author kenny 52 * @author kenny
89 private String keymode = null; 88 private String keymode = null;
90 private boolean hardKeyboard = false; 89 private boolean hardKeyboard = false;
91 private String customKeyboard = null; 90 private String customKeyboard = null;
92 91
93 private int metaState = 0; 92 private int metaState = 0;
94
95 private int mDeadKey = 0; 93 private int mDeadKey = 0;
96 94
97 // TODO add support for the new API. 95 // TODO add support for the new API.
98 private ClipboardManager clipboard = null; 96 private ClipboardManager clipboard = null;
99
100 private boolean selectingForCopy = false; 97 private boolean selectingForCopy = false;
101 private final SelectionArea selectionArea; 98 private final SelectionArea selectionArea;
102
103
104 private final SharedPreferences prefs; 99 private final SharedPreferences prefs;
105 100
106 private Toast debugToast = null;
107 private Toast metakeyToast = null;
108 101
109 public TerminalKeyListener(TerminalManager manager, 102 public TerminalKeyListener(TerminalManager manager,
110 TerminalBridge bridge, 103 TerminalBridge bridge,
111 vt320 buffer, 104 vt320 buffer,
112 String encoding) { 105 String encoding) {
147 140
148 // if keycode debugging enabled, log and print the pressed key 141 // if keycode debugging enabled, log and print the pressed key
149 if (prefs.getBoolean(PreferenceConstants.DEBUG_KEYCODES, false)) { 142 if (prefs.getBoolean(PreferenceConstants.DEBUG_KEYCODES, false)) {
150 String keyCodeString = String.format(": %d", keyCode); 143 String keyCodeString = String.format(": %d", keyCode);
151 String toastText = v.getContext().getString(R.string.keycode_pressed) + keyCodeString; 144 String toastText = v.getContext().getString(R.string.keycode_pressed) + keyCodeString;
152 145 Log.d(TAG, toastText);
153 if (debugToast == null)
154 debugToast = Toast.makeText(v.getContext(), toastText, Toast.LENGTH_LONG);
155 else
156 debugToast.setText(toastText);
157
158 debugToast.show();
159 } 146 }
160 147
161 if (fullKeyboard()) { 148 if (fullKeyboard()) {
162 switch (keyCode) { 149 switch (keyCode) {
163 case KeyEvent.KEYCODE_CTRL_LEFT: 150 case KeyEvent.KEYCODE_CTRL_LEFT:
651 638
652 return (true); 639 return (true);
653 } 640 }
654 641
655 private void showMetakeyToast(View v, String keyname) { 642 private void showMetakeyToast(View v, String keyname) {
656 if (metakeyToast == null) 643 Log.d(TAG, keyname);
657 metakeyToast = Toast.makeText(v.getContext(), keyname, Toast.LENGTH_LONG);
658 else
659 metakeyToast.setText(keyname);
660
661 metakeyToast.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 0);
662 metakeyToast.show();
663 } 644 }
664 645
665 public int keyAsControl(int key) { 646 public int keyAsControl(int key) {
666 // Support CTRL-a through CTRL-z 647 // Support CTRL-a through CTRL-z
667 if (key >= 0x60 && key <= 0x7A) 648 if (key >= 0x60 && key <= 0x7A)