resolved conflicts for merge of 3945e1 to master

This commit is contained in:
Jack Palevich
2009-06-10 15:09:22 -07:00

View File

@@ -99,8 +99,6 @@ public class Term extends Activity {
*/ */
private FileDescriptor mTermFd; private FileDescriptor mTermFd;
private boolean mShellRunning;
/** /**
* Used to send data to the remote process. * Used to send data to the remote process.
*/ */
@@ -179,7 +177,9 @@ public class Term extends Activity {
mKeyListener = new TermKeyListener(); mKeyListener = new TermKeyListener();
mEmulatorView.setFocusable(true); mEmulatorView.setFocusable(true);
mEmulatorView.setFocusableInTouchMode(true);
mEmulatorView.requestFocus(); mEmulatorView.requestFocus();
mEmulatorView.register(mKeyListener);
updatePrefs(); updatePrefs();
} }
@@ -197,14 +197,11 @@ public class Term extends Activity {
int[] processId = new int[1]; int[] processId = new int[1];
createSubprocess(processId); createSubprocess(processId);
mShellRunning = true;
final int procId = processId[0]; final int procId = processId[0];
final Handler handler = new Handler() { final Handler handler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
mShellRunning = false;
} }
}; };
@@ -1360,7 +1357,7 @@ class TerminalEmulator {
printableB = ' '; printableB = ' ';
} }
Log.w(Term.LOG_TAG, "'" + Character.toString(printableB) Log.w(Term.LOG_TAG, "'" + Character.toString(printableB)
+ "' (" + Integer.toString((int) b) + ")"); + "' (" + Integer.toString(b) + ")");
} }
process(b); process(b);
mProcessedCharCount++; mProcessedCharCount++;
@@ -2087,7 +2084,7 @@ class TerminalEmulator {
buf.append(" char: '"); buf.append(" char: '");
buf.append((char) b); buf.append((char) b);
buf.append("' ("); buf.append("' (");
buf.append((int) b); buf.append(b);
buf.append(")"); buf.append(")");
boolean firstArg = true; boolean firstArg = true;
for (int i = 0; i <= mArgIndex; i++) { for (int i = 0; i <= mArgIndex; i++) {
@@ -2607,6 +2604,7 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
private GestureDetector mGestureDetector; private GestureDetector mGestureDetector;
private float mScrollRemainder; private float mScrollRemainder;
private TermKeyListener mKeyListener;
/** /**
* Our message handler class. Implements a periodic callback. * Our message handler class. Implements a periodic callback.
@@ -2618,6 +2616,7 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
* *
* @param msg The callback message. * @param msg The callback message.
*/ */
@Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
if (msg.what == UPDATE) { if (msg.what == UPDATE) {
update(); update();
@@ -2630,6 +2629,10 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
commonConstructor(); commonConstructor();
} }
public void register(TermKeyListener listener) {
mKeyListener = listener;
}
public void setColors(int foreground, int background) { public void setColors(int foreground, int background) {
mForeground = foreground; mForeground = foreground;
mBackground = background; mBackground = background;
@@ -2654,52 +2657,64 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
public InputConnection onCreateInputConnection(EditorInfo outAttrs) { public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return new BaseInputConnection(this, false) { return new BaseInputConnection(this, false) {
@Override
public boolean beginBatchEdit() { public boolean beginBatchEdit() {
return true; return true;
} }
@Override
public boolean clearMetaKeyStates(int states) { public boolean clearMetaKeyStates(int states) {
return true; return true;
} }
@Override
public boolean commitCompletion(CompletionInfo text) { public boolean commitCompletion(CompletionInfo text) {
return true; return true;
} }
@Override
public boolean commitText(CharSequence text, int newCursorPosition) { public boolean commitText(CharSequence text, int newCursorPosition) {
sendText(text); sendText(text);
return true; return true;
} }
@Override
public boolean deleteSurroundingText(int leftLength, int rightLength) { public boolean deleteSurroundingText(int leftLength, int rightLength) {
return true; return true;
} }
@Override
public boolean endBatchEdit() { public boolean endBatchEdit() {
return true; return true;
} }
@Override
public boolean finishComposingText() { public boolean finishComposingText() {
return true; return true;
} }
@Override
public int getCursorCapsMode(int reqModes) { public int getCursorCapsMode(int reqModes) {
return 0; return 0;
} }
@Override
public ExtractedText getExtractedText(ExtractedTextRequest request, public ExtractedText getExtractedText(ExtractedTextRequest request,
int flags) { int flags) {
return null; return null;
} }
@Override
public CharSequence getTextAfterCursor(int n, int flags) { public CharSequence getTextAfterCursor(int n, int flags) {
return null; return null;
} }
@Override
public CharSequence getTextBeforeCursor(int n, int flags) { public CharSequence getTextBeforeCursor(int n, int flags) {
return null; return null;
} }
@Override
public boolean performEditorAction(int actionCode) { public boolean performEditorAction(int actionCode) {
if(actionCode == EditorInfo.IME_ACTION_UNSPECIFIED) { if(actionCode == EditorInfo.IME_ACTION_UNSPECIFIED) {
// The "return" key has been pressed on the IME. // The "return" key has been pressed on the IME.
@@ -2709,14 +2724,17 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
return false; return false;
} }
@Override
public boolean performContextMenuAction(int id) { public boolean performContextMenuAction(int id) {
return true; return true;
} }
@Override
public boolean performPrivateCommand(String action, Bundle data) { public boolean performPrivateCommand(String action, Bundle data) {
return true; return true;
} }
@Override
public boolean sendKeyEvent(KeyEvent event) { public boolean sendKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch(event.getKeyCode()) { switch(event.getKeyCode()) {
@@ -2728,17 +2746,19 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
return true; return true;
} }
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition) { public boolean setComposingText(CharSequence text, int newCursorPosition) {
return true; return true;
} }
@Override
public boolean setSelection(int start, int end) { public boolean setSelection(int start, int end) {
return true; return true;
} }
private void sendChar(int c) { private void sendChar(int c) {
try { try {
mTermOut.write(c); mapAndSend(c);
} catch (IOException ex) { } catch (IOException ex) {
} }
@@ -2748,11 +2768,16 @@ class EmulatorView extends View implements GestureDetector.OnGestureListener {
try { try {
for(int i = 0; i < n; i++) { for(int i = 0; i < n; i++) {
char c = text.charAt(i); char c = text.charAt(i);
mTermOut.write(c); mapAndSend(c);
} }
} catch (IOException e) { } catch (IOException e) {
} }
} }
private void mapAndSend(int c) throws IOException {
mTermOut.write(
mKeyListener.mapControlChar(c));
}
}; };
} }
@@ -3164,6 +3189,35 @@ class TermKeyListener {
} }
} }
public int mapControlChar(int ch) {
int result = ch;
if (mControlKey.isActive()) {
// Search is the control key.
if (result >= 'a' && result <= 'z') {
result = (char) (result - 'a' + '\001');
} else if (result == ' ') {
result = 0;
} else if ((result == '[') || (result == '1')) {
result = 27;
} else if ((result == '\\') || (result == '.')) {
result = 28;
} else if ((result == ']') || (result == '0')) {
result = 29;
} else if ((result == '^') || (result == '6')) {
result = 30; // control-^
} else if ((result == '_') || (result == '5')) {
result = 31;
}
}
if (result > -1) {
mAltKey.adjustAfterKeypress();
mCapKey.adjustAfterKeypress();
mControlKey.adjustAfterKeypress();
}
return result;
}
/** /**
* Handle a keyDown event. * Handle a keyDown event.
* *
@@ -3204,30 +3258,7 @@ class TermKeyListener {
} }
} }
if (mControlKey.isActive()) { result = mapControlChar(result);
// Search is the control key.
if (result >= 'a' && result <= 'z') {
result = (char) (result - 'a' + '\001');
} else if (result == ' ') {
result = 0;
} else if ((result == '[') || (result == '1')) {
result = 27;
} else if ((result == '\\') || (result == '.')) {
result = 28;
} else if ((result == ']') || (result == '0')) {
result = 29;
} else if ((result == '^') || (result == '6')) {
result = 30; // control-^
} else if ((result == '_') || (result == '5')) {
result = 31;
}
}
if (result > -1) {
mAltKey.adjustAfterKeypress();
mCapKey.adjustAfterKeypress();
mControlKey.adjustAfterKeypress();
}
return result; return result;
} }