Display a message in the EmulatorView when the shell exits
Currently, if the shell exits and the option to close windows on shell exit isn't activated, the user gets no visual cue that the shell has exited -- only an unresponsive session. Instead, take a page from the Mac OS X Terminal's book and display a message that the terminal session has finished. Signed-off-by: Jack Palevich <jackpal@google.com>
This commit is contained in:
parent
78c3d0b5d2
commit
8e6145ca11
@ -41,6 +41,8 @@
|
||||
|
||||
<string name="service_notify_text">Terminal session is running</string>
|
||||
|
||||
<string name="process_exit_message">Terminal session finished</string>
|
||||
|
||||
<!-- Preference dialog -->
|
||||
<string name="screen_preferences">Screen</string>
|
||||
|
||||
|
@ -226,7 +226,7 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe
|
||||
|
||||
public EmulatorView(Context context, TermSession session, TermViewFlipper viewFlipper, DisplayMetrics metrics) {
|
||||
super(context);
|
||||
commonConstructor(session, viewFlipper);
|
||||
commonConstructor(context, session, viewFlipper);
|
||||
setDensity(metrics);
|
||||
}
|
||||
|
||||
@ -572,7 +572,7 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe
|
||||
return mEmulator.getKeypadApplicationMode();
|
||||
}
|
||||
|
||||
private void commonConstructor(TermSession session, TermViewFlipper viewFlipper) {
|
||||
private void commonConstructor(Context context, TermSession session, TermViewFlipper viewFlipper) {
|
||||
mTextRenderer = null;
|
||||
mCursorPaint = new Paint();
|
||||
mCursorPaint.setARGB(255,128,128,128);
|
||||
@ -587,6 +587,8 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe
|
||||
|
||||
initialize(session, viewFlipper);
|
||||
session.setUpdateCallback(mUpdateNotify);
|
||||
// XXX We should really be able to fetch this from within TermSession
|
||||
session.setProcessExitMessage(context.getString(R.string.process_exit_message));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ import java.io.FileDescriptor;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
@ -64,6 +65,8 @@ public class TermSession {
|
||||
private ByteBuffer mWriteByteBuffer;
|
||||
private CharsetEncoder mUTF8Encoder;
|
||||
|
||||
private String mProcessExitMessage;
|
||||
|
||||
private static final int DEFAULT_COLUMNS = 80;
|
||||
private static final int DEFAULT_ROWS = 24;
|
||||
private static final String DEFAULT_SHELL = "/system/bin/sh -";
|
||||
@ -311,12 +314,26 @@ public class TermSession {
|
||||
mEmulator.reset();
|
||||
}
|
||||
|
||||
/* XXX We should really get this ourselves from the resource bundle, but
|
||||
we cannot hold a context */
|
||||
public void setProcessExitMessage(String message) {
|
||||
mProcessExitMessage = message;
|
||||
}
|
||||
|
||||
private void onProcessExit(int result) {
|
||||
if (mSettings.closeWindowOnProcessExit()) {
|
||||
if (mFinishCallback != null) {
|
||||
mFinishCallback.onSessionFinish(this);
|
||||
}
|
||||
finish();
|
||||
} else if (mProcessExitMessage != null) {
|
||||
try {
|
||||
byte[] msg = ("\r\n[" + mProcessExitMessage + "]").getBytes("UTF-8");
|
||||
mEmulator.append(msg, 0, msg.length);
|
||||
mNotify.onUpdate();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Never happens
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user