changeset 75:bf01d1eec5c6 tn5250

convert 5250 to vt320 attributes
author Carl Byington <carl@five-ten-sg.com>
date Sun, 15 Jun 2014 10:56:09 -0700
parents 1aff8d06d5ef
children 00464d9c2f54
files src/com/five_ten_sg/connectbot/util/Colors.java src/de/mud/terminal/VDUBuffer.java src/org/tn5250j/TN5250jConstants.java src/org/tn5250j/framework/tn5250/Screen5250.java src/org/tn5250j/framework/tn5250/ScreenPlanes.java
diffstat 5 files changed, 77 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/util/Colors.java	Sat Jun 14 09:04:35 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/util/Colors.java	Sun Jun 15 10:56:09 2014 -0700
@@ -23,22 +23,22 @@
  */
 public class Colors {
     public final static Integer[] defaults = new Integer[] {
-        0xff000000, // black
-        0xffcc0000, // red
-        0xff00cc00, // green
-        0xffcccc00, // brown
-        0xff0000cc, // blue
-        0xffcc00cc, // purple
-        0xff00cccc, // cyan
-        0xffcccccc, // light grey
-        0xff444444, // dark grey
-        0xffff4444, // light red
-        0xff44ff44, // light green
-        0xffffff44, // yellow
-        0xff4444ff, // light blue
-        0xffff44ff, // light purple
-        0xff44ffff, // light cyan
-        0xffffffff, // white
+        0xff000000, // black        // 0
+        0xffcc0000, // red          // 1
+        0xff00cc00, // green        // 2
+        0xffcccc00, // brown        // 3
+        0xff0000cc, // blue         // 4
+        0xffcc00cc, // purple       // 5
+        0xff00cccc, // cyan         // 6
+        0xffcccccc, // light grey   // 7
+        0xff444444, // dark grey    // 8
+        0xffff4444, // light red    // 9
+        0xff44ff44, // light green  // a
+        0xffffff44, // yellow       // b
+        0xff4444ff, // light blue   // c
+        0xffff44ff, // light purple // d
+        0xff44ffff, // light cyan   // e
+        0xffffffff, // white        // f
         0xff000000, 0xff00005f, 0xff000087, 0xff0000af, 0xff0000d7,
         0xff0000ff, 0xff005f00, 0xff005f5f, 0xff005f87, 0xff005faf,
         0xff005fd7, 0xff005fff, 0xff008700, 0xff00875f, 0xff008787,
--- a/src/de/mud/terminal/VDUBuffer.java	Sat Jun 14 09:04:35 2014 -0700
+++ b/src/de/mud/terminal/VDUBuffer.java	Sun Jun 15 10:56:09 2014 -0700
@@ -99,11 +99,11 @@
     /** how much to left shift the background color */
     public final static int COLOR_BG_SHIFT = 14;
     /** color mask */
-    public final static int COLOR = 0x7fffe0;    /* 0000 0000 0111 1111 1111 1111 1110 0000 */
+    public final static int COLOR    = 0x7fffe0;   /* 0000 0000 0111 1111 1111 1111 1110 0000 */
     /** foreground color mask */
-    public final static int COLOR_FG = 0x3fe0;   /* 0000 0000 0000 0000 0011 1111 1110 0000 */
+    public final static int COLOR_FG = 0x003fe0;   /* 0000 0000 0000 0000 0011 1111 1110 0000 */
     /** background color mask */
-    public final static int COLOR_BG = 0x7fc000; /* 0000 0000 0111 1111 1100 0000 0000 0000 */
+    public final static int COLOR_BG = 0x7fc000;   /* 0000 0000 0111 1111 1100 0000 0000 0000 */
 
     /**
      * Create a new video display buffer with the passed width and height in
--- a/src/org/tn5250j/TN5250jConstants.java	Sat Jun 14 09:04:35 2014 -0700
+++ b/src/org/tn5250j/TN5250jConstants.java	Sun Jun 15 10:56:09 2014 -0700
@@ -401,32 +401,32 @@
 
    // COLOR_BG
    public static final char COLOR_BG_BLACK   =  0;
-   public static final char COLOR_BG_BLUE   =  1;
+   public static final char COLOR_BG_BLUE    =  1;
    public static final char COLOR_BG_GREEN   =  2;
-   public static final char COLOR_BG_CYAN   =  3;
-   public static final char COLOR_BG_RED   =  4;
-   public static final char COLOR_BG_MAGENTA   =  5;
-   public static final char COLOR_BG_YELLOW   =  6;
+   public static final char COLOR_BG_CYAN    =  3;
+   public static final char COLOR_BG_RED     =  4;
+   public static final char COLOR_BG_MAGENTA =  5;
+   public static final char COLOR_BG_YELLOW  =  6;
    public static final char COLOR_BG_WHITE   =  7;
 
    // COLOR_FG
-   public static final char COLOR_FG_BLACK   =  0;
-   public static final char COLOR_FG_BLUE   =  1;
-   public static final char COLOR_FG_GREEN   =  2;
-   public static final char COLOR_FG_CYAN   =  3;
-   public static final char COLOR_FG_RED   =  4;
-   public static final char COLOR_FG_MAGENTA   =  5;
-   public static final char COLOR_FG_YELLOW   =  6;
-   public static final char COLOR_FG_WHITE   =  7;
-   public static final char COLOR_FG_BROWN   =  0xE;
-   public static final char COLOR_FG_GRAY   =  8;
-   public static final char COLOR_FG_LIGHT_BLUE   =  9;
+   public static final char COLOR_FG_BLACK         =  0;
+   public static final char COLOR_FG_BLUE          =  1;
+   public static final char COLOR_FG_GREEN         =  2;
+   public static final char COLOR_FG_CYAN          =  3;
+   public static final char COLOR_FG_RED           =  4;
+   public static final char COLOR_FG_MAGENTA       =  5;
+   public static final char COLOR_FG_YELLOW        =  6;
+   public static final char COLOR_FG_WHITE         =  7;
+   public static final char COLOR_FG_GRAY          =  8;
+   public static final char COLOR_FG_LIGHT_BLUE    =  9;
    public static final char COLOR_FG_LIGHT_GREEN   =  0xA;
-   public static final char COLOR_FG_LIGHT_CYAN   =  0xB;
-   public static final char COLOR_FG_LIGHT_RED   =  0xC;
-   public static final char COLOR_FG_LIGHT_MAGENTA   =  0xD;
-   public static final char COLOR_FG_WHITE_HIGH   =  0xF;
-
+   public static final char COLOR_FG_LIGHT_CYAN    =  0xB;
+   public static final char COLOR_FG_LIGHT_RED     =  0xC;
+   public static final char COLOR_FG_LIGHT_MAGENTA =  0xD;
+   public static final char COLOR_FG_BROWN         =  0xE;
+   public static final char COLOR_FG_WHITE_HIGH    =  0xF;
+                                                  
    public static final int EXTENDED_5250_REVERSE   =  0x10;
    public static final int EXTENDED_5250_UNDERLINE   =  0x08;
    public static final int EXTENDED_5250_BLINK   =  0x04;
--- a/src/org/tn5250j/framework/tn5250/Screen5250.java	Sat Jun 14 09:04:35 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/Screen5250.java	Sun Jun 15 10:56:09 2014 -0700
@@ -36,6 +36,7 @@
 import org.tn5250j.TN5250jConstants;
 import android.util.Log;
 import de.mud.terminal.vt320;
+import de.mud.terminal.VDUBuffer;
 
 
 public class Screen5250 {
@@ -3821,11 +3822,37 @@
      *
      */
     private void fireScreenChanged(int startRow, int startCol, int endRow, int endCol) {
+        int [] vt320color = {0x0, // black
+                             0x4, // blue
+                             0x2, // green
+                             0x6, // cyan
+                             0x1, // red
+                             0x5, // magenta/purple
+                             0xb, // yellow
+                             0x7, // light gray/white
+                             0x8, // dark gray
+                             0xc, // light blue
+                             0xa, // light green
+                             0xe, // light cyan
+                             0x9, // light red
+                             0xd, // light magenta/purple
+                             0x3, // brown
+                             0xf, // bright white
         for (int r = startRow; r <= endRow; r++) {
             for (int c = startCol; c <= endCol; c++) {
-                char ch = planes.getChar(getPos(r,c));
+                int p = getPos(r,c);
+                char ch = planes.getChar(p);
+                char co = planes.getCharColor(p);
+                char at = planes.getCharExtended(p);
                 if (ch < ' ') ch = ' ';
-                buffer.putChar(c, r, ch, 0);
+                int bg = vt320color[(int)((co >> 8) && 0x0f)];
+                int fg = vt320color[(int)(co        && 0x0f)];
+                int ul = (int)(at && EXTENDED_5250_UNDERLINE);
+                int nd = (int)(at && EXTENDED_5250_NON_DSP);
+                int vt_attr = (fg << COLOR_FG_SHIFT) + (bg << COLOR_BG_SHIFT)
+                if (ul > 0) vt_attr |= UNDERLINE;
+                if (nd > 0) vt_attr |= INVISIBLE;
+                buffer.putChar(c, r, ch, vt_attr);
             }
         }
         buffer.redrawPassthru();
--- a/src/org/tn5250j/framework/tn5250/ScreenPlanes.java	Sat Jun 14 09:04:35 2014 -0700
+++ b/src/org/tn5250j/framework/tn5250/ScreenPlanes.java	Sun Jun 15 10:56:09 2014 -0700
@@ -212,10 +212,18 @@
 		return screen[pos];
 	}
 
+	protected final char getCharColor(int pos) {
+		return screenColor[pos];
+	}
+
 	protected final int getCharAttr(int pos) {
 		return screenAttr[pos];
 	}
 
+	protected final int getCharExtended(int pos) {
+		return screenExtended[pos];
+	}
+
 	protected final boolean isAttributePlace(int pos) {
 		return screenIsAttr[pos] == 1 ? true : false;
 	}