development
リビジョン | 8768990de5d2b227c821ae5effcb300b87101c46 (tree) |
---|---|
日時 | 2009-11-11 18:04:36 |
作者 | Yi Sun <beyounn@gmai...> |
コミッター | Yi Sun |
Changed ctrl to the real Ctrl keys. I did not add CAP key support for the Term yet.
@@ -41,20 +41,6 @@ | ||
41 | 41 | </PreferenceCategory> |
42 | 42 | |
43 | 43 | <PreferenceCategory |
44 | - android:title="@string/keyboard_preferences"> | |
45 | - | |
46 | - <ListPreference | |
47 | - android:key="controlkey" | |
48 | - android:defaultValue="@string/default_value_controlkey_preference" | |
49 | - android:title="@string/title_controlkey_preference" | |
50 | - android:summary="@string/summary_controlkey_preference" | |
51 | - android:entries="@array/entries_controlkey_preference" | |
52 | - android:entryValues="@array/entryvalues_controlkey_preference" | |
53 | - android:dialogTitle="@string/dialog_title_controlkey_preference" /> | |
54 | - | |
55 | - </PreferenceCategory> | |
56 | - | |
57 | - <PreferenceCategory | |
58 | 44 | android:title="@string/shell_preferences"> |
59 | 45 | |
60 | 46 | <EditTextPreference |
@@ -121,11 +121,9 @@ public class Term extends Activity { | ||
121 | 121 | |
122 | 122 | private int mFontSize = 9; |
123 | 123 | private int mColorId = 2; |
124 | - private int mControlKeyId = 0; | |
125 | 124 | |
126 | 125 | private static final String FONTSIZE_KEY = "fontsize"; |
127 | 126 | private static final String COLOR_KEY = "color"; |
128 | - private static final String CONTROLKEY_KEY = "controlkey"; | |
129 | 127 | private static final String SHELL_KEY = "shell"; |
130 | 128 | private static final String INITIALCOMMAND_KEY = "initialcommand"; |
131 | 129 |
@@ -136,18 +134,6 @@ public class Term extends Activity { | ||
136 | 134 | private static final int[][] COLOR_SCHEMES = { |
137 | 135 | {BLACK, WHITE}, {WHITE, BLACK}, {WHITE, BLUE}}; |
138 | 136 | |
139 | - private static final int[] CONTROL_KEY_SCHEMES = { | |
140 | - KeyEvent.KEYCODE_DPAD_CENTER, | |
141 | - KeyEvent.KEYCODE_AT, | |
142 | - KeyEvent.KEYCODE_ALT_LEFT, | |
143 | - KeyEvent.KEYCODE_ALT_RIGHT | |
144 | - }; | |
145 | - private static final String[] CONTROL_KEY_NAME = { | |
146 | - "Ball", "@", "Left-Alt", "Right-Alt" | |
147 | - }; | |
148 | - | |
149 | - private int mControlKeyCode; | |
150 | - | |
151 | 137 | private final static String DEFAULT_SHELL = "/system/bin/sh -"; |
152 | 138 | private String mShell; |
153 | 139 |
@@ -315,8 +301,6 @@ public class Term extends Activity { | ||
315 | 301 | private void readPrefs() { |
316 | 302 | mFontSize = readIntPref(FONTSIZE_KEY, mFontSize, 20); |
317 | 303 | mColorId = readIntPref(COLOR_KEY, mColorId, COLOR_SCHEMES.length - 1); |
318 | - mControlKeyId = readIntPref(CONTROLKEY_KEY, mControlKeyId, | |
319 | - CONTROL_KEY_SCHEMES.length - 1); | |
320 | 304 | { |
321 | 305 | String newShell = readStringPref(SHELL_KEY, mShell); |
322 | 306 | if ((newShell == null) || ! newShell.equals(mShell)) { |
@@ -344,7 +328,6 @@ public class Term extends Activity { | ||
344 | 328 | private void updatePrefs() { |
345 | 329 | mEmulatorView.setTextSize(mFontSize); |
346 | 330 | setColors(); |
347 | - mControlKeyCode = CONTROL_KEY_SCHEMES[mControlKeyId]; | |
348 | 331 | } |
349 | 332 | |
350 | 333 | private int readIntPref(String key, int defaultValue, int maxValue) { |
@@ -369,7 +352,6 @@ public class Term extends Activity { | ||
369 | 352 | e.clear(); |
370 | 353 | e.putString(FONTSIZE_KEY, Integer.toString(mFontSize)); |
371 | 354 | e.putString(COLOR_KEY, Integer.toString(mColorId)); |
372 | - e.putString(CONTROLKEY_KEY, Integer.toString(mControlKeyId)); | |
373 | 355 | e.putString(SHELL_KEY, mShell); |
374 | 356 | e.putString(INITIALCOMMAND_KEY, mInitialCommand); |
375 | 357 | e.commit(); |
@@ -424,7 +406,8 @@ public class Term extends Activity { | ||
424 | 406 | } |
425 | 407 | |
426 | 408 | private boolean handleControlKey(int keyCode, boolean down) { |
427 | - if (keyCode == mControlKeyCode) { | |
409 | + if (keyCode == KeyEvent.KEYCODE_CTRL_RIGHT || | |
410 | + keyCode == KeyEvent.KEYCODE_CTRL_LEFT) { | |
428 | 411 | mKeyListener.handleControlKey(down); |
429 | 412 | return true; |
430 | 413 | } |
@@ -531,9 +514,9 @@ public class Term extends Activity { | ||
531 | 514 | } |
532 | 515 | |
533 | 516 | private void doDocumentKeys() { |
534 | - String controlKey = CONTROL_KEY_NAME[mControlKeyId]; | |
517 | + String controlKey = "ctrl"; | |
535 | 518 | new AlertDialog.Builder(this). |
536 | - setTitle("Press " + controlKey + " and Key"). | |
519 | + setTitle("Press "+controlKey+" and Key"). | |
537 | 520 | setMessage(controlKey + " Space ==> Control-@ (NUL)\n" |
538 | 521 | + controlKey + " A..Z ==> Control-A..Z\n" |
539 | 522 | + controlKey + " 1 ==> Control-[ (ESC)\n" |
@@ -3181,6 +3164,7 @@ class TermKeyListener { | ||
3181 | 3164 | mControlKey.onPress(); |
3182 | 3165 | } else { |
3183 | 3166 | mControlKey.onRelease(); |
3167 | + mControlKey.adjustAfterKeypress(); | |
3184 | 3168 | } |
3185 | 3169 | } |
3186 | 3170 |
@@ -3207,8 +3191,6 @@ class TermKeyListener { | ||
3207 | 3191 | |
3208 | 3192 | if (result > -1) { |
3209 | 3193 | mAltKey.adjustAfterKeypress(); |
3210 | - mCapKey.adjustAfterKeypress(); | |
3211 | - mControlKey.adjustAfterKeypress(); | |
3212 | 3194 | } |
3213 | 3195 | return result; |
3214 | 3196 | } |
@@ -3232,7 +3214,6 @@ class TermKeyListener { | ||
3232 | 3214 | case KeyEvent.KEYCODE_SHIFT_RIGHT: |
3233 | 3215 | mCapKey.onPress(); |
3234 | 3216 | break; |
3235 | - | |
3236 | 3217 | case KeyEvent.KEYCODE_ENTER: |
3237 | 3218 | // Convert newlines into returns. The vt100 sends a |
3238 | 3219 | // '\r' when the 'Return' key is pressed, but our |
@@ -3272,6 +3253,7 @@ class TermKeyListener { | ||
3272 | 3253 | case KeyEvent.KEYCODE_SHIFT_LEFT: |
3273 | 3254 | case KeyEvent.KEYCODE_SHIFT_RIGHT: |
3274 | 3255 | mCapKey.onRelease(); |
3256 | + mCapKey.adjustAfterKeypress(); | |
3275 | 3257 | break; |
3276 | 3258 | default: |
3277 | 3259 | // Ignore other keyUps |