diff options
author | Jack Palevich <jackpal@google.com> | 2012-09-22 21:23:14 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2012-09-22 21:23:14 -0700 |
commit | 3bf8591e76e44fadc0fb15ffc122f53167a3616e (patch) | |
tree | 095db2132838ae38965dfd513345783cc8b8ba46 | |
parent | c99140a22c1a3276b42980f61b1b1c760fb3a488 (diff) | |
download | AndroidTerm-3bf8591e76e44fadc0fb15ffc122f53167a3616e.tar.gz |
Implement DECSCNM (reverse video).
6 files changed, 32 insertions, 6 deletions
diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/BaseTextRenderer.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/BaseTextRenderer.java index f1237a3..8e910a9 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/BaseTextRenderer.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/BaseTextRenderer.java @@ -17,6 +17,8 @@ package jackpal.androidterm.emulatorview; abstract class BaseTextRenderer implements TextRenderer { + protected boolean mReverseVideo; + protected int[] mPalette; protected static final int[] sXterm256Paint = { @@ -296,6 +298,10 @@ abstract class BaseTextRenderer implements TextRenderer { setDefaultColors(scheme.getForeColor(), scheme.getBackColor()); } + public void setReverseVideo(boolean reverseVideo) { + mReverseVideo = reverseVideo; + } + private void setDefaultColors(int forePaintColor, int backPaintColor) { mPalette = cloneDefaultColors(); mPalette[TextStyle.ciForeground] = forePaintColor; diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/Bitmap4x8FontRenderer.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/Bitmap4x8FontRenderer.java index 054700a..221eabd 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/Bitmap4x8FontRenderer.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/Bitmap4x8FontRenderer.java @@ -66,7 +66,8 @@ class Bitmap4x8FontRenderer extends BaseTextRenderer { int backColor = TextStyle.decodeBackColor(textStyle); int effect = TextStyle.decodeEffect(textStyle); - boolean inverse = (effect & (TextStyle.fxInverse | TextStyle.fxItalic)) != 0; + boolean inverse = mReverseVideo ^ + ((effect & (TextStyle.fxInverse | TextStyle.fxItalic)) != 0); if (inverse) { int temp = foreColor; foreColor = backColor; diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java index 0640f7c..5d430e9 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/EmulatorView.java @@ -1153,6 +1153,9 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe int w = getWidth(); int h = getHeight(); + boolean reverseVideo = mEmulator.getReverseVideo(); + mTextRenderer.setReverseVideo(reverseVideo); + canvas.drawRect(0, 0, w, h, mBackgroundPaint); float x = -mLeftColumn * mCharacterWidth; float y = mCharacterHeight + mTopOfScreenMargin; diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/PaintRenderer.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/PaintRenderer.java index 994ab86..1759efc 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/PaintRenderer.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/PaintRenderer.java @@ -43,7 +43,8 @@ class PaintRenderer extends BaseTextRenderer { int backColor = TextStyle.decodeBackColor(textStyle); int effect = TextStyle.decodeEffect(textStyle); - boolean inverse = (effect & (TextStyle.fxInverse | TextStyle.fxItalic)) != 0; + boolean inverse = mReverseVideo ^ + (effect & (TextStyle.fxInverse | TextStyle.fxItalic)) != 0; if (inverse) { int temp = foreColor; foreColor = backColor; diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TerminalEmulator.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TerminalEmulator.java index a906046..30d7f5e 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TerminalEmulator.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TerminalEmulator.java @@ -179,6 +179,11 @@ class TerminalEmulator { private static final int K_132_COLUMN_MODE_MASK = 1 << 3; /** + * DECSCNM - set means reverse video (light background.) + */ + private static final int K_REVERSE_VIDEO_MASK = 1 << 5; + + /** * This mask indicates that origin mode is set. (Cursor addressing is * relative to the absolute screen size, rather than the currently set top * and bottom margins.) @@ -353,6 +358,10 @@ class TerminalEmulator { private CharsetDecoder mUTF8Decoder; private UpdateCallback mUTF8ModeNotify; + /** This is not accurate, but it makes the terminal more useful on + * small screens. + */ + private final static boolean DEFAULT_TO_AUTOWRAP_ENABLED = true; /** * Construct a terminal emulator that uses the supplied screen @@ -519,6 +528,10 @@ class TerminalEmulator { return mCursorCol; } + public final boolean getReverseVideo() { + return (mDecFlags & K_REVERSE_VIDEO_MASK) != 0; + } + public final boolean getKeypadApplicationMode() { return mbKeypadApplicationMode; } @@ -665,7 +678,7 @@ class TerminalEmulator { break; case ESC_LEFT_SQUARE_BRACKET_QUESTION_MARK: - doEscLSBQuest(b); + doEscLSBQuest(b); // CSI ? break; case ESC_PERCENT: @@ -1595,9 +1608,7 @@ class TerminalEmulator { } private boolean autoWrapEnabled() { - // Always enable auto wrap, because it's useful on a small screen - return true; - // return (mDecFlags & K_WRAPAROUND_MODE_MASK) != 0; + return (mDecFlags & K_WRAPAROUND_MODE_MASK) != 0; } /** @@ -1734,6 +1745,9 @@ class TerminalEmulator { mSavedCursorRow = 0; mSavedCursorCol = 0; mDecFlags = 0; + if (DEFAULT_TO_AUTOWRAP_ENABLED) { + mDecFlags |= K_WRAPAROUND_MODE_MASK; + } mSavedDecFlags = 0; mInsertMode = false; mAutomaticNewlineMode = false; diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TextRenderer.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TextRenderer.java index a484d15..07ee1b9 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TextRenderer.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/TextRenderer.java @@ -23,6 +23,7 @@ import android.graphics.Canvas; */ interface TextRenderer { + void setReverseVideo(boolean reverseVideo); float getCharacterWidth(); int getCharacterHeight(); /** @return pixels above top row of text to avoid looking cramped. */ |