diff src/org/tn5250j/framework/tn5250/Screen5250.java @ 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 c56032728742
children 00464d9c2f54
line wrap: on
line diff
--- 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();