comparison src/org/tn5250j/framework/tn5250/tnvt.java @ 405:d3c5480e8441

fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
author Carl Byington <carl@five-ten-sg.com>
date Fri, 24 Oct 2014 14:19:06 -0700
parents 7ac1a0b02f44
children 4038389cb7ce
comparison
equal deleted inserted replaced
404:ec74f347ab5f 405:d3c5480e8441
1140 int la = 32; 1140 int la = 32;
1141 int sac = 0; 1141 int sac = 0;
1142 int len = rows * cols; 1142 int len = rows * cols;
1143 ScreenPlanes planes = screen52.planes; 1143 ScreenPlanes planes = screen52.planes;
1144 1144
1145 for (int y = 0; y < len; y++) { // save the screen data 1145 try {
1146 if (planes.isAttributePlace(y)) { 1146 for (int y = 0; y < len; y++) { // save the screen data
1147 la = planes.getCharAttr(y); 1147 if (planes.isAttributePlace(y)) {
1148 sa[sac++] = (byte) la;
1149 }
1150 else {
1151 if (planes.getCharAttr(y) != la) {
1152 la = planes.getCharAttr(y); 1148 la = planes.getCharAttr(y);
1153 sac = max(sac--, 0);
1154 sa[sac++] = (byte) la; 1149 sa[sac++] = (byte) la;
1155 } 1150 }
1156 1151 else {
1157 //LDC: Check to see if it is an displayable character. If not, 1152 // The characters on screen are in unicode
1158 // do not convert the character. 1153 char ch = planes.getChar(y);
1159 // The characters on screen are in unicode 1154 byte byteCh;
1160 //sa[sac++] = 1155 if (isDataUnicode(ch)) byteCh = codePage.uni2ebcdic(ch);
1161 // (byte)codePage.uni2ebcdic(screen52.screen[y].getChar()); 1156 else byteCh = (byte) ch;
1162 char ch = planes.getChar(y); 1157 sa[sac++] = byteCh;
1163 byte byteCh = (byte) ch; 1158 }
1164 1159 }
1165 if (isDataUnicode(ch)) 1160 }
1166 byteCh = codePage.uni2ebcdic(ch); 1161 catch (Exception exc) {
1167 1162 Log.i(TAG, exc.getMessage());
1168 sa[min(sac++, len - 1)] = byteCh; 1163 exc.printStackTrace();
1169 }
1170 } 1164 }
1171 } 1165 }
1172 1166
1173 private final void fillRegenerationBuffer(ByteArrayOutputStream sc, int rows, int cols) 1167 private final void fillRegenerationBuffer(ByteArrayOutputStream sc, int rows, int cols)
1174 throws IOException { 1168 throws IOException {
1204 if (planes.isAttributePlace(y)) { 1198 if (planes.isAttributePlace(y)) {
1205 la = planes.getCharAttr(y); 1199 la = planes.getCharAttr(y);
1206 sa[sac++] = (byte) la; 1200 sa[sac++] = (byte) la;
1207 } 1201 }
1208 else { 1202 else {
1209 if (planes.getCharAttr(y) != la) {
1210 la = planes.getCharAttr(y);
1211 sac = max(sac--, 0);
1212 sa[sac++] = (byte) la;
1213 }
1214
1215 //LDC: Check to see if it is an displayable character. If not,
1216 // do not convert the character.
1217 // The characters on screen are in unicode 1203 // The characters on screen are in unicode
1218 //sa[sac++] =
1219 // (byte)codePage.uni2ebcdic(screen52.screen[y].getChar());
1220 char ch = planes.getChar(y); 1204 char ch = planes.getChar(y);
1221 byte byteCh = (byte) ch; 1205 byte byteCh;
1222 1206 if (isDataUnicode(ch)) byteCh = codePage.uni2ebcdic(ch);
1223 if (isDataUnicode(ch)) 1207 else byteCh = (byte) ch;
1224 byteCh = codePage.uni2ebcdic(ch); 1208 sa[sac++] = byteCh;
1225
1226 sa[min(sac++, len - 1)] = byteCh;
1227 } 1209 }
1228 } 1210 }
1229 } 1211 }
1230 catch (Exception exc) { 1212 catch (Exception exc) {
1231 Log.i(TAG, exc.getMessage()); 1213 Log.i(TAG, exc.getMessage());
1367 if (isAttribute(b)) { 1349 if (isAttribute(b)) {
1368 planes.setScreenCharAndAttr(y, planes.getChar(y), b, true); 1350 planes.setScreenCharAndAttr(y, planes.getChar(y), b, true);
1369 la = b; 1351 la = b;
1370 } 1352 }
1371 else { 1353 else {
1372 //LDC - 12/02/2003 - Check to see if it is an displayable
1373 // character. If not,
1374 // do not convert the character.
1375 // The characters on screen are in unicode 1354 // The characters on screen are in unicode
1376 char ch = (char) b; 1355 char ch;
1377 1356 if (isDataEBCDIC(b)) ch = codePage.ebcdic2uni(b);
1378 if (isDataEBCDIC(b)) 1357 else ch = b;
1379 ch = codePage.ebcdic2uni(b);
1380
1381 planes.setScreenCharAndAttr(y, ch, la, false); 1358 planes.setScreenCharAndAttr(y, ch, la, false);
1382 } 1359 }
1383 } 1360 }
1384 } 1361 }
1385 1362