/**
* Text size. Zero means 4 x 8 font.
*/
- private int mTextSize;
+ private int mTextSize = 10;
private int mCursorStyle;
private int mCursorBlink;
/**
* Foreground color.
*/
- private int mForeground;
+ private int mForeground = TermSettings.WHITE;
private int mForegroundIndex;
/**
* Background color.
*/
- private int mBackground;
+ private int mBackground = TermSettings.BLACK;
private int mBackgroundIndex;
/**
setFocusable(true);
setFocusableInTouchMode(true);
- initialize(session);
- session.setUpdateCallback(mUpdateNotify);
+ mTermSession = session;
// XXX We should really be able to fetch this from within TermSession
session.setProcessExitMessage(context.getString(R.string.process_exit_message));
+
+ mKeyListener = new TermKeyListener(session);
}
public void setWindowSizeCallback(WindowSizeCallback callback) {
/**
* Call this to initialize the view.
- *
- * @param session The terminal session this view will be displaying
*/
- private void initialize(TermSession session) {
- mTermSession = session;
- mTranscriptScreen = session.getTranscriptScreen();
- mEmulator = session.getEmulator();
+ private void initialize() {
+ TermSession session = mTermSession;
- mKeyListener = new TermKeyListener(session);
- mTextSize = 10;
- mForeground = TermSettings.WHITE;
- mBackground = TermSettings.BLACK;
updateText();
+ mTranscriptScreen = session.getTranscriptScreen();
+ mEmulator = session.getEmulator();
+ session.setUpdateCallback(mUpdateNotify);
+
requestFocus();
}
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if (!mKnownSize) {
mKnownSize = true;
+ initialize();
+ } else {
+ updateSize(false);
}
- updateSize(false);
}
private void updateSize(int w, int h) {
requestLayout();
mRedoLayout = false;
}
+
+ if (mEmulator == null) {
+ // Not ready yet
+ return;
+ }
+
int w = getWidth();
int h = getHeight();
private FileDescriptor mTermFd;
private FileOutputStream mTermOut;
private FileInputStream mTermIn;
+ private String mInitialCommand;
+ private Thread mWatcherThread;
private TranscriptScreen mTranscriptScreen;
private TerminalEmulator mEmulator;
private String mProcessExitMessage;
- private static final int DEFAULT_COLUMNS = 80;
- private static final int DEFAULT_ROWS = 24;
-
// Number of rows in the transcript
private static final int TRANSCRIPT_ROWS = 10000;
mProcId = processId[0];
mTermOut = new FileOutputStream(mTermFd);
mTermIn = new FileInputStream(mTermFd);
+ mInitialCommand = initialCommand;
- int[] colorScheme = settings.getColorScheme();
- mTranscriptScreen = new TranscriptScreen(DEFAULT_COLUMNS, TRANSCRIPT_ROWS, DEFAULT_ROWS, colorScheme[0], colorScheme[2]);
- mEmulator = new TerminalEmulator(settings, mTranscriptScreen, DEFAULT_COLUMNS, DEFAULT_ROWS, mTermOut);
-
- mIsRunning = true;
-
- Thread watcher = new Thread() {
+ mWatcherThread = new Thread() {
@Override
public void run() {
Log.i(TermDebug.LOG_TAG, "waiting for: " + mProcId);
mMsgHandler.sendMessage(mMsgHandler.obtainMessage(PROCESS_EXITED, result));
}
};
- watcher.setName("Process watcher");
- watcher.start();
+ mWatcherThread.setName("Process watcher");
mWriteCharBuffer = CharBuffer.allocate(2);
mWriteByteBuffer = ByteBuffer.allocate(4);
}
};
mPollingThread.setName("Input reader");
+ }
+
+ private void initializeEmulator(int columns, int rows) {
+ TermSettings settings = mSettings;
+ int[] colorScheme = settings.getColorScheme();
+ mTranscriptScreen = new TranscriptScreen(columns, TRANSCRIPT_ROWS, rows, colorScheme[0], colorScheme[2]);
+ mEmulator = new TerminalEmulator(settings, mTranscriptScreen, columns, rows, mTermOut);
+
+ mIsRunning = true;
+ mWatcherThread.start();
mPollingThread.start();
- sendInitialCommand(initialCommand);
+ sendInitialCommand(mInitialCommand);
}
private void sendInitialCommand(String initialCommand) {
public void updateSize(int columns, int rows) {
// Inform the attached pty of our new size:
Exec.setPtyWindowSize(mTermFd, rows, columns, 0, 0);
- mEmulator.updateSize(columns, rows);
+
+ if (mEmulator == null) {
+ initializeEmulator(columns, rows);
+ } else {
+ mEmulator.updateSize(columns, rows);
+ }
}
public String getTranscriptText() {
public void updatePrefs(TermSettings settings) {
mSettings = settings;
+ if (mEmulator == null) {
+ // Not initialized yet, we'll pick up the settings then
+ return;
+ }
+
mEmulator.updatePrefs(settings);
int[] colorScheme = settings.getColorScheme();