Program: 143909
Project: 143909
Buggy source:
private void putChar(char c,boolean doshowcursor){
  int rows=getRows();
  int columns=getColumns();
  int tm=getTopMargin();
  int bm=getBottomMargin();
  boolean mapped=false;
  if (debug > 4)   System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str"+ R+ "String_Node_Str"+ C+ "String_Node_Str"+ columns+ "String_Node_Str"+ rows);
  markLine(R,1);
  if (c > 255) {
    if (debug > 0)     System.out.println("String_Node_Str" + (int)c);
  }
switch (term_state) {
case TSTATE_DATA:
    if (!useibmcharset) {
      boolean doneflag=true;
switch (c) {
case OSC:
        osc="String_Node_Str";
      term_state=TSTATE_OSC;
    break;
case RI:
  if (R > tm)   R--;
 else   insertLine(R,1,SCROLL_DOWN);
if (debug > 1) System.out.println("String_Node_Str");
break;
case IND:
if (debug > 2) System.out.println("String_Node_Str" + R + "String_Node_Str"+ tm+ "String_Node_Str"+ bm);
if (R == bm || R == rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
if (debug > 1) System.out.println("String_Node_Str" + R + "String_Node_Str");
break;
case NEL:
if (R == bm || R == rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
C=0;
if (debug > 1) System.out.println("String_Node_Str" + R + "String_Node_Str");
break;
case HTS:
Tabs[C]=1;
if (debug > 1) System.out.println("String_Node_Str");
break;
case DCS:
dcs="String_Node_Str";
term_state=TSTATE_DCS;
break;
default :
doneflag=false;
break;
}
if (doneflag) break;
}
switch (c) {
case SS3:
onegl=3;
break;
case SS2:
onegl=2;
break;
case CSI:
DCEvar=0;
DCEvars[0]=0;
DCEvars[1]=0;
DCEvars[2]=0;
DCEvars[3]=0;
term_state=TSTATE_CSI;
break;
case ESC:
term_state=TSTATE_ESC;
lastwaslf=0;
break;
case 5:
write(answerBack,false);
break;
case 12:
deleteArea(0,0,columns,rows,attributes);
C=R=0;
break;
case '\b':
C--;
if (C < 0) C=0;
lastwaslf=0;
break;
case '\t':
do {
C++;
}
 while (C < columns && (Tabs[C] == 0));
lastwaslf=0;
break;
case '\r':
C=0;
break;
case '\n':
if (debug > 3) System.out.println("String_Node_Str" + R + "String_Node_Str"+ bm+ "String_Node_Str"+ tm+ "String_Node_Str"+ rows);
if (!vms) {
if (lastwaslf != 0 && lastwaslf != c) break;
lastwaslf=c;
}
if (R == bm || R >= rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
break;
case 7:
beep();
break;
case '\016':
gl=1;
usedcharsets=true;
break;
case '\017':
gl=0;
usedcharsets=true;
break;
default :
{
int thisgl=gl;
if (onegl >= 0) {
thisgl=onegl;
onegl=-1;
}
lastwaslf=0;
if (c < 32) {
if (c != 0) if (debug > 0) System.out.println("String_Node_Str" + ((int)c));
if (c == 0) break;
}
if (C >= columns) {
if (wraparound) {
if (R < rows - 1) R++;
 else insertLine(R,1,SCROLL_UP);
C=0;
}
 else {
C=columns - 1;
}
}
if (usedcharsets) {
if (c >= '\u0020' && c <= '\u007f') {
switch (gx[thisgl]) {
case '0':
if (terminalID.equals("String_Node_Str") || terminalID.equals("String_Node_Str")) {
for (int i=0; i < scoansi_acs.length(); i+=2) {
if (c == scoansi_acs.charAt(i)) {
c=scoansi_acs.charAt(i + 1);
break;
}
}
}
if (c >= '\u005f' && c <= '\u007e') {
c=DECSPECIAL[(short)c - 0x5f];
mapped=true;
}
break;
case '<':
c=(char)(((int)c & 0x7f) | 0x80);
mapped=true;
break;
case 'A':
case 'B':
mapped=true;
break;
default :
System.out.println("String_Node_Str" + gx[thisgl]);
break;
}
}
if (!mapped && (c >= '\u0080' && c <= '\u00ff')) {
switch (gx[gr]) {
case '0':
if (c >= '\u00df' && c <= '\u00fe') {
c=DECSPECIAL[c - '\u00df'];
mapped=true;
}
break;
case '<':
case 'A':
case 'B':
mapped=true;
break;
default :
System.out.println("String_Node_Str" + gx[gr]);
break;
}
}
}
if (!mapped && useibmcharset) c=map_cp850_unicode(c);
if (insertmode == 1) {
insertChar(C,R,c,attributes);
}
 else {
putChar(C,R,c,attributes);
}
C++;
break;
}
}
break;
case TSTATE_OSC:
if ((c < 0x20) && (c != ESC)) {
handle_osc(osc);
term_state=TSTATE_DATA;
break;
}
if (c == '\\' && osc.charAt(osc.length() - 1) == ESC) {
handle_osc(osc);
term_state=TSTATE_DATA;
break;
}
osc=osc + c;
break;
case TSTATE_ESCSPACE:
term_state=TSTATE_DATA;
switch (c) {
case 'F':
output8bit=false;
break;
case 'G':
output8bit=true;
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str");
}
break;
case TSTATE_ESC:
term_state=TSTATE_DATA;
switch (c) {
case ' ':
term_state=TSTATE_ESCSPACE;
break;
case '#':
term_state=TSTATE_ESCSQUARE;
break;
case 'c':
gx[0]='B';
gx[1]='0';
gx[2]='B';
gx[3]='B';
gl=0;
gr=1;
int nw=getColumns();
if (nw < 132) nw=132;
Tabs=new byte[nw];
for (int i=0; i < nw; i+=8) {
Tabs[i]=1;
}
break;
case '[':
DCEvar=0;
DCEvars[0]=0;
DCEvars[1]=0;
DCEvars[2]=0;
DCEvars[3]=0;
term_state=TSTATE_CSI;
break;
case ']':
osc="String_Node_Str";
term_state=TSTATE_OSC;
break;
case 'P':
dcs="String_Node_Str";
term_state=TSTATE_DCS;
break;
case 'A':
R--;
if (R < 0) R=0;
break;
case 'B':
R++;
if (R > rows - 1) R=rows - 1;
break;
case 'C':
C++;
if (C >= columns) C=columns - 1;
break;
case 'I':
insertLine(R,1,SCROLL_DOWN);
break;
case 'E':
if (R == bm || R == rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
C=0;
if (debug > 1) System.out.println("String_Node_Str" + R + "String_Node_Str");
break;
case 'D':
if (R == bm || R == rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
if (debug > 1) System.out.println("String_Node_Str" + R + "String_Node_Str");
break;
case 'J':
if (R < rows - 1) deleteArea(0,R + 1,columns,rows - R - 1,attributes);
if (C < columns - 1) deleteArea(C,R,columns - C,1,attributes);
break;
case 'K':
if (C < columns - 1) deleteArea(C,R,columns - C,1,attributes);
break;
case 'M':
if (R > bm) break;
if (R > tm) {
R--;
}
 else {
insertLine(R,1,SCROLL_DOWN);
}
if (debug > 2) System.out.println("String_Node_Str");
break;
case 'H':
if (debug > 1) System.out.println("String_Node_Str" + C);
if (C >= columns) C=columns - 1;
Tabs[C]=1;
break;
case 'N':
onegl=2;
break;
case 'O':
onegl=3;
break;
case '=':
if (debug > 0) System.out.println("String_Node_Str");
keypadmode=true;
break;
case '<':
vt52mode=false;
break;
case '>':
if (debug > 0) System.out.println("String_Node_Str");
keypadmode=false;
break;
case '7':
Sc=C;
Sr=R;
Sgl=gl;
Sgr=gr;
Sa=attributes;
Sgx=new char[4];
for (int i=0; i < 4; i++) Sgx[i]=gx[i];
Stm=getTopMargin();
Sbm=getBottomMargin();
if (debug > 1) System.out.println("String_Node_Str");
break;
case '8':
C=Sc;
R=Sr;
gl=Sgl;
gr=Sgr;
for (int i=0; i < 4; i++) gx[i]=Sgx[i];
setTopMargin(Stm);
setBottomMargin(Sbm);
attributes=Sa;
if (debug > 1) System.out.println("String_Node_Str");
break;
case '(':
term_state=TSTATE_SETG0;
usedcharsets=true;
break;
case ')':
term_state=TSTATE_SETG1;
usedcharsets=true;
break;
case '*':
term_state=TSTATE_SETG2;
usedcharsets=true;
break;
case '+':
term_state=TSTATE_SETG3;
usedcharsets=true;
break;
case '~':
gr=1;
usedcharsets=true;
break;
case 'n':
gl=2;
usedcharsets=true;
break;
case '}':
gr=2;
usedcharsets=true;
break;
case 'o':
gl=3;
usedcharsets=true;
break;
case '|':
gr=3;
usedcharsets=true;
break;
case 'Y':
term_state=TSTATE_VT52Y;
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
break;
}
break;
case TSTATE_VT52X:
C=c - 37;
term_state=TSTATE_VT52Y;
break;
case TSTATE_VT52Y:
R=c - 37;
term_state=TSTATE_DATA;
break;
case TSTATE_SETG0:
if (c != '0' && c != 'A' && c != 'B' && c != '<') System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
 else {
if (debug > 2) System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
gx[0]=c;
}
term_state=TSTATE_DATA;
break;
case TSTATE_SETG1:
if (c != '0' && c != 'A' && c != 'B' && c != '<') {
System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
}
 else {
if (debug > 2) System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
gx[1]=c;
}
term_state=TSTATE_DATA;
break;
case TSTATE_SETG2:
if (c != '0' && c != 'A' && c != 'B' && c != '<') System.out.println("String_Node_Str" + ((int)c) + "String_Node_Str");
 else {
if (debug > 2) System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
gx[2]=c;
}
term_state=TSTATE_DATA;
break;
case TSTATE_SETG3:
if (c != '0' && c != 'A' && c != 'B' && c != '<') System.out.println("String_Node_Str" + ((int)c) + "String_Node_Str");
 else {
if (debug > 2) System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
gx[3]=c;
}
term_state=TSTATE_DATA;
break;
case TSTATE_ESCSQUARE:
switch (c) {
case '8':
for (int i=0; i < columns; i++) for (int j=0; j < rows; j++) putChar(i,j,'E',0);
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str");
break;
}
term_state=TSTATE_DATA;
break;
case TSTATE_DCS:
if (c == '\\' && dcs.charAt(dcs.length() - 1) == ESC) {
handle_dcs(dcs);
term_state=TSTATE_DATA;
break;
}
dcs=dcs + c;
break;
case TSTATE_DCEQ:
term_state=TSTATE_DATA;
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
DCEvars[DCEvar]=DCEvars[DCEvar] * 10 + ((int)c) - 48;
term_state=TSTATE_DCEQ;
break;
case ';':
DCEvar++;
DCEvars[DCEvar]=0;
term_state=TSTATE_DCEQ;
break;
case 's':
if (true || debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'r':
if (true || debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
for (int i=0; i <= DCEvar; i++) {
switch (DCEvars[i]) {
case 3:
setScreenSize(80,getRows());
break;
case 4:
break;
case 5:
break;
case 6:
moveoutsidemargins=true;
break;
case 7:
wraparound=false;
break;
case 12:
break;
case 9:
case 1000:
case 1001:
case 1002:
case 1003:
mouserpt=DCEvars[i];
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
}
}
break;
case 'h':
if (debug > 0) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
for (int i=0; i <= DCEvar; i++) {
switch (DCEvars[i]) {
case 1:
KeyUp[0]="String_Node_Str";
KeyDown[0]="String_Node_Str";
KeyRight[0]="String_Node_Str";
KeyLeft[0]="String_Node_Str";
break;
case 2:
vt52mode=false;
break;
case 3:
setScreenSize(132,getRows());
break;
case 6:
moveoutsidemargins=false;
break;
case 7:
wraparound=true;
break;
case 25:
showCursor(true);
break;
case 9:
case 1000:
case 1001:
case 1002:
case 1003:
mouserpt=DCEvars[i];
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
}
break;
case 'i':
switch (DCEvars[0]) {
case 1:
if (debug > 1) System.out.println("String_Node_Str");
break;
case 4:
if (debug > 1) System.out.println("String_Node_Str");
break;
case 5:
if (debug > 1) System.out.println("String_Node_Str");
break;
}
break;
case 'l':
if (debug > 0) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
for (int i=0; i <= DCEvar; i++) {
switch (DCEvars[i]) {
case 1:
KeyUp[0]="String_Node_Str";
KeyDown[0]="String_Node_Str";
KeyRight[0]="String_Node_Str";
KeyLeft[0]="String_Node_Str";
break;
case 2:
vt52mode=true;
break;
case 3:
setScreenSize(80,getRows());
break;
case 6:
moveoutsidemargins=true;
break;
case 7:
wraparound=false;
break;
case 25:
showCursor(false);
break;
case 9:
case 1000:
case 1001:
case 1002:
case 1003:
mouserpt=0;
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
}
break;
case 'n':
if (debug > 0) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
switch (DCEvars[0]) {
case 15:
write(((char)ESC) + "String_Node_Str",false);
System.out.println("String_Node_Str");
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ c+ "String_Node_Str");
break;
}
break;
case TSTATE_CSI_EX:
term_state=TSTATE_DATA;
switch (c) {
case ESC:
term_state=TSTATE_ESC;
break;
default :
System.out.println("String_Node_Str" + (int)c);
break;
}
break;
case TSTATE_CSI_TICKS:
term_state=TSTATE_DATA;
switch (c) {
case 'p':
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ DCEvars[1]);
if (DCEvars[0] == 61) {
output8bit=false;
break;
}
if (DCEvars[1] == 1) {
output8bit=false;
}
 else {
output8bit=true;
}
break;
default :
System.out.println("String_Node_Str" + c);
break;
}
break;
case TSTATE_CSI_EQUAL:
term_state=TSTATE_DATA;
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
DCEvars[DCEvar]=DCEvars[DCEvar] * 10 + ((int)c) - 48;
term_state=TSTATE_CSI_EQUAL;
break;
case ';':
DCEvar++;
DCEvars[DCEvar]=0;
term_state=TSTATE_CSI_EQUAL;
break;
case 'F':
{
int newcolor;
attributes&=~COLOR_FG;
newcolor=((DCEvars[0] & 1) << 2) | (DCEvars[0] & 2) | ((DCEvars[0] & 4) >> 2);
attributes|=newcolor << COLOR_FG_SHIFT;
break;
}
case 'G':
{
int newcolor;
attributes&=~COLOR_BG;
newcolor=((DCEvars[0] & 1) << 2) | (DCEvars[0] & 2) | ((DCEvars[0] & 4) >> 2);
attributes|=newcolor << COLOR_BG_SHIFT;
break;
}
default :
System.out.print("String_Node_Str");
for (int i=0; i < DCEvar; i++) System.out.print(DCEvars[i] + "String_Node_Str");
System.out.println("String_Node_Str" + c);
break;
}
break;
case TSTATE_CSI_DOLLAR:
term_state=TSTATE_DATA;
switch (c) {
case '}':
System.out.println("String_Node_Str" + DCEvars[0]);
statusmode=DCEvars[0];
break;
case '~':
System.out.println("String_Node_Str" + DCEvars[0]);
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str"+ DCEvars[0]);
break;
}
break;
case TSTATE_CSI:
term_state=TSTATE_DATA;
switch (c) {
case '"':
term_state=TSTATE_CSI_TICKS;
break;
case '$':
term_state=TSTATE_CSI_DOLLAR;
break;
case '=':
term_state=TSTATE_CSI_EQUAL;
break;
case '!':
term_state=TSTATE_CSI_EX;
break;
case '?':
DCEvar=0;
DCEvars[0]=0;
term_state=TSTATE_DCEQ;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
DCEvars[DCEvar]=DCEvars[DCEvar] * 10 + ((int)c) - 48;
term_state=TSTATE_CSI;
break;
case ';':
DCEvar++;
DCEvars[DCEvar]=0;
term_state=TSTATE_CSI;
break;
case 'c':
String subcode="String_Node_Str";
if (terminalID.equals("String_Node_Str")) subcode="String_Node_Str";
if (terminalID.equals("String_Node_Str")) subcode="String_Node_Str";
if (terminalID.equals("String_Node_Str")) subcode="String_Node_Str";
write(((char)ESC) + "String_Node_Str" + subcode+ "String_Node_Str",false);
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'q':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'g':
switch (DCEvars[0]) {
case 3:
Tabs=new byte[getColumns()];
break;
case 0:
Tabs[C]=0;
break;
}
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'h':
switch (DCEvars[0]) {
case 4:
insertmode=1;
break;
case 20:
System.out.println("String_Node_Str");
sendcrlf=true;
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'i':
switch (DCEvars[0]) {
case 0:
if (debug > 1) System.out.println("String_Node_Str");
break;
case 4:
if (debug > 1) System.out.println("String_Node_Str");
break;
case 5:
if (debug > 1) System.out.println("String_Node_Str");
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
}
break;
case 'l':
switch (DCEvars[0]) {
case 4:
insertmode=0;
break;
case 20:
System.out.println("String_Node_Str");
sendcrlf=false;
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
break;
case 'A':
{
int limit;
if (R > bm) limit=bm + 1;
 else if (R >= tm) {
limit=tm;
}
 else limit=0;
if (DCEvars[0] == 0) R--;
 else R-=DCEvars[0];
if (R < limit) R=limit;
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
case 'B':
{
int limit;
if (R < tm) limit=tm - 1;
 else if (R <= bm) {
limit=bm;
}
 else limit=rows - 1;
if (DCEvars[0] == 0) R++;
 else R+=DCEvars[0];
if (R > limit) R=limit;
 else {
if (debug > 2) System.out.println("String_Node_Str");
}
if (debug > 2) System.out.println("String_Node_Str" + R);
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ C+ "String_Node_Str");
break;
}
case 'C':
if (DCEvars[0] == 0) C++;
 else C+=DCEvars[0];
if (C > columns - 1) C=columns - 1;
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'd':
R=DCEvars[0];
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'D':
if (DCEvars[0] == 0) C--;
 else C-=DCEvars[0];
if (C < 0) C=0;
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'r':
if (DCEvar > 0) {
R=DCEvars[1] - 1;
if (R < 0) R=rows - 1;
 else if (R >= rows) {
R=rows - 1;
}
}
 else R=rows - 1;
setBottomMargin(R);
if (R >= DCEvars[0]) {
R=DCEvars[0] - 1;
if (R < 0) R=0;
}
setTopMargin(R);
_SetCursor(0,0);
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ DCEvars[1]+ "String_Node_Str");
break;
case 'G':
C=DCEvars[0];
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'H':
_SetCursor(DCEvars[0] - 1,DCEvars[1] - 1);
if (debug > 2) {
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ DCEvars[1]+ "String_Node_Str"+ moveoutsidemargins);
System.out.println("String_Node_Str" + R + "String_Node_Str"+ C);
}
break;
case 'f':
R=DCEvars[0] - 1;
C=DCEvars[1] - 1;
if (C < 0) C=0;
if (R < 0) R=0;
if (debug > 2) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ DCEvars[1]+ "String_Node_Str");
break;
case 'S':
if (DCEvars[0] == 0) insertLine(rows - 1,SCROLL_UP);
 else insertLine(rows - 1,DCEvars[0],SCROLL_UP);
break;
case 'L':
if (DCEvars[0] == 0) insertLine(R,SCROLL_DOWN);
 else insertLine(R,DCEvars[0],SCROLL_DOWN);
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ (c)+ "String_Node_Str"+ R+ "String_Node_Str");
break;
case 'T':
if (DCEvars[0] == 0) insertLine(0,SCROLL_DOWN);
 else insertLine(0,DCEvars[0],SCROLL_DOWN);
break;
case 'M':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ (c)+ "String_Node_Str"+ R);
if (DCEvars[0] == 0) deleteLine(R);
 else for (int i=0; i < DCEvars[0]; i++) deleteLine(R);
break;
case 'K':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
switch (DCEvars[0]) {
case 6:
case 0:
if (C < columns - 1) deleteArea(C,R,columns - C,1,attributes);
break;
case 1:
if (C > 0) deleteArea(0,R,C + 1,1,attributes);
break;
case 2:
deleteArea(0,R,columns,1,attributes);
break;
}
break;
case 'J':
switch (DCEvars[0]) {
case 0:
if (R < rows - 1) deleteArea(0,R + 1,columns,rows - R - 1,attributes);
if (C < columns - 1) deleteArea(C,R,columns - C,1,attributes);
break;
case 1:
if (R > 0) deleteArea(0,0,columns,R,attributes);
if (C > 0) deleteArea(0,R,C + 1,1,attributes);
break;
case 2:
deleteArea(0,0,columns,rows,attributes);
break;
}
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case '@':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
for (int i=0; i < DCEvars[0]; i++) insertChar(C,R,' ',attributes);
break;
case 'X':
{
int toerase=DCEvars[0];
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ C+ "String_Node_Str"+ R);
if (toerase == 0) toerase=1;
if (toerase + C > columns) toerase=columns - C;
deleteArea(C,R,toerase,1,attributes);
break;
}
case 'P':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ C+ "String_Node_Str"+ R);
if (DCEvars[0] == 0) DCEvars[0]=1;
for (int i=0; i < DCEvars[0]; i++) deleteChar(C,R);
break;
case 'n':
switch (DCEvars[0]) {
case 5:
writeSpecial(((char)ESC) + "String_Node_Str");
if (debug > 1) System.out.println("String_Node_Str");
break;
case 6:
writeSpecial(((char)ESC) + "String_Node_Str" + R+ "String_Node_Str"+ C+ "String_Node_Str");
if (debug > 1) System.out.println("String_Node_Str");
break;
default :
if (debug > 0) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
break;
case 's':
Sc=C;
Sr=R;
Sa=attributes;
if (debug > 3) System.out.println("String_Node_Str");
break;
case 'u':
C=Sc;
R=Sr;
attributes=Sa;
if (debug > 3) System.out.println("String_Node_Str");
break;
case 'm':
if (debug > 3) System.out.print("String_Node_Str");
if (DCEvar == 0 && DCEvars[0] == 0) attributes=0;
for (int i=0; i <= DCEvar; i++) {
switch (DCEvars[i]) {
case 0:
if (DCEvar > 0) {
if (terminalID.equals("String_Node_Str")) {
attributes&=COLOR;
}
 else {
attributes=0;
}
}
break;
case 1:
attributes|=BOLD;
attributes&=~LOW;
break;
case 2:
if (terminalID.equals("String_Node_Str") && ((DCEvar - i) >= 2)) {
int ncolor;
attributes&=~(COLOR | BOLD);
ncolor=DCEvars[i + 1];
if ((ncolor & 8) == 8) attributes|=BOLD;
ncolor=((ncolor & 1) << 2) | (ncolor & 2) | ((ncolor & 4) >> 2);
attributes|=((ncolor) + 1) << COLOR_FG_SHIFT;
ncolor=DCEvars[i + 2];
ncolor=((ncolor & 1) << 2) | (ncolor & 2) | ((ncolor & 4) >> 2);
attributes|=((ncolor) + 1) << COLOR_BG_SHIFT;
i+=2;
}
 else {
attributes|=LOW;
}
break;
case 4:
attributes|=UNDERLINE;
break;
case 7:
attributes|=INVERT;
break;
case 8:
attributes|=INVISIBLE;
break;
case 5:
break;
case 10:
gl=0;
usedcharsets=true;
break;
case 11:
case 12:
gl=1;
usedcharsets=true;
break;
case 21:
attributes&=~(LOW | BOLD);
break;
case 25:
break;
case 27:
attributes&=~INVERT;
break;
case 28:
attributes&=~INVISIBLE;
break;
case 24:
attributes&=~UNDERLINE;
break;
case 22:
attributes&=~BOLD;
break;
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
attributes&=~COLOR_FG;
attributes|=((DCEvars[i] - 30) + 1) << COLOR_FG_SHIFT;
break;
case 39:
attributes&=~COLOR_FG;
break;
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
attributes&=~COLOR_BG;
attributes|=((DCEvars[i] - 40) + 1) << COLOR_BG_SHIFT;
break;
case 49:
attributes&=~COLOR_BG;
break;
default :
System.out.println("String_Node_Str" + DCEvars[i] + "String_Node_Str");
break;
}
if (debug > 3) System.out.print("String_Node_Str" + DCEvars[i] + "String_Node_Str");
}
if (debug > 3) System.out.print("String_Node_Str" + attributes + "String_Node_Str");
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
break;
}
break;
default :
term_state=TSTATE_DATA;
break;
}
if (C > columns) C=columns;
if (R > rows) R=rows;
if (C < 0) C=0;
if (R < 0) R=0;
if (doshowcursor) setCursorPosition(C,R);
markLine(R,1);
}

Fixed version (ground truth):
private void putChar(char c,boolean doshowcursor){
  int rows=getRows();
  int columns=getColumns();
  int tm=getTopMargin();
  int bm=getBottomMargin();
  boolean mapped=false;
  if (debug > 4)   System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str"+ R+ "String_Node_Str"+ C+ "String_Node_Str"+ columns+ "String_Node_Str"+ rows);
  markLine(R,1);
  if (c > 255) {
    if (debug > 0)     System.out.println("String_Node_Str" + (int)c);
  }
switch (term_state) {
case TSTATE_DATA:
    if (!useibmcharset) {
      boolean doneflag=true;
switch (c) {
case OSC:
        osc="String_Node_Str";
      term_state=TSTATE_OSC;
    break;
case RI:
  if (R > tm)   R--;
 else   insertLine(R,1,SCROLL_DOWN);
if (debug > 1) System.out.println("String_Node_Str");
break;
case IND:
if (debug > 2) System.out.println("String_Node_Str" + R + "String_Node_Str"+ tm+ "String_Node_Str"+ bm);
if (R == bm || R == rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
if (debug > 1) System.out.println("String_Node_Str" + R + "String_Node_Str");
break;
case NEL:
if (R == bm || R == rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
C=0;
if (debug > 1) System.out.println("String_Node_Str" + R + "String_Node_Str");
break;
case HTS:
Tabs[C]=1;
if (debug > 1) System.out.println("String_Node_Str");
break;
case DCS:
dcs="String_Node_Str";
term_state=TSTATE_DCS;
break;
default :
doneflag=false;
break;
}
if (doneflag) break;
}
switch (c) {
case SS3:
onegl=3;
break;
case SS2:
onegl=2;
break;
case CSI:
DCEvar=0;
DCEvars[0]=0;
DCEvars[1]=0;
DCEvars[2]=0;
DCEvars[3]=0;
term_state=TSTATE_CSI;
break;
case ESC:
term_state=TSTATE_ESC;
lastwaslf=0;
break;
case 5:
write(answerBack,false);
break;
case 12:
deleteArea(0,0,columns,rows,attributes);
C=R=0;
break;
case '\b':
C--;
if (C < 0) C=0;
lastwaslf=0;
break;
case '\t':
do {
C++;
}
 while (C < columns && (Tabs[C] == 0));
lastwaslf=0;
break;
case '\r':
C=0;
break;
case '\n':
if (debug > 3) System.out.println("String_Node_Str" + R + "String_Node_Str"+ bm+ "String_Node_Str"+ tm+ "String_Node_Str"+ rows);
if (!vms) {
if (lastwaslf != 0 && lastwaslf != c) break;
lastwaslf=c;
}
if (R == bm || R >= rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
break;
case 7:
beep();
break;
case '\016':
gl=1;
usedcharsets=true;
break;
case '\017':
gl=0;
usedcharsets=true;
break;
default :
{
int thisgl=gl;
if (onegl >= 0) {
thisgl=onegl;
onegl=-1;
}
lastwaslf=0;
if (c < 32) {
if (c != 0) if (debug > 0) System.out.println("String_Node_Str" + ((int)c));
if (c == 0) break;
}
if (C >= columns) {
if (wraparound) {
if (R < rows - 1) R++;
 else insertLine(R,1,SCROLL_UP);
C=0;
}
 else {
C=columns - 1;
}
}
if (usedcharsets) {
if (c >= '\u0020' && c <= '\u007f') {
switch (gx[thisgl]) {
case '0':
if (terminalID.equals("String_Node_Str") || terminalID.equals("String_Node_Str")) {
for (int i=0; i < scoansi_acs.length(); i+=2) {
if (c == scoansi_acs.charAt(i)) {
c=scoansi_acs.charAt(i + 1);
break;
}
}
}
if (c >= '\u005f' && c <= '\u007e') {
c=DECSPECIAL[(short)c - 0x5f];
mapped=true;
}
break;
case '<':
c=(char)(((int)c & 0x7f) | 0x80);
mapped=true;
break;
case 'A':
case 'B':
mapped=true;
break;
default :
System.out.println("String_Node_Str" + gx[thisgl]);
break;
}
}
if (!mapped && (c >= '\u0080' && c <= '\u00ff')) {
switch (gx[gr]) {
case '0':
if (c >= '\u00df' && c <= '\u00fe') {
c=DECSPECIAL[c - '\u00df'];
mapped=true;
}
break;
case '<':
case 'A':
case 'B':
mapped=true;
break;
default :
System.out.println("String_Node_Str" + gx[gr]);
break;
}
}
}
if (!mapped && useibmcharset) c=map_cp850_unicode(c);
if (insertmode == 1) {
insertChar(C,R,c,attributes);
}
 else {
putChar(C,R,c,attributes);
}
C++;
break;
}
}
break;
case TSTATE_OSC:
if ((c < 0x20) && (c != ESC)) {
handle_osc(osc);
term_state=TSTATE_DATA;
break;
}
if (c == '\\' && osc.charAt(osc.length() - 1) == ESC) {
handle_osc(osc);
term_state=TSTATE_DATA;
break;
}
osc=osc + c;
break;
case TSTATE_ESCSPACE:
term_state=TSTATE_DATA;
switch (c) {
case 'F':
output8bit=false;
break;
case 'G':
output8bit=true;
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str");
}
break;
case TSTATE_ESC:
term_state=TSTATE_DATA;
switch (c) {
case ' ':
term_state=TSTATE_ESCSPACE;
break;
case '#':
term_state=TSTATE_ESCSQUARE;
break;
case 'c':
gx[0]='B';
gx[1]='0';
gx[2]='B';
gx[3]='B';
gl=0;
gr=1;
int nw=getColumns();
if (nw < 132) nw=132;
Tabs=new byte[nw];
for (int i=0; i < nw; i+=8) {
Tabs[i]=1;
}
break;
case '[':
DCEvar=0;
DCEvars[0]=0;
DCEvars[1]=0;
DCEvars[2]=0;
DCEvars[3]=0;
term_state=TSTATE_CSI;
break;
case ']':
osc="String_Node_Str";
term_state=TSTATE_OSC;
break;
case 'P':
dcs="String_Node_Str";
term_state=TSTATE_DCS;
break;
case 'A':
R--;
if (R < 0) R=0;
break;
case 'B':
R++;
if (R > rows - 1) R=rows - 1;
break;
case 'C':
C++;
if (C >= columns) C=columns - 1;
break;
case 'I':
insertLine(R,1,SCROLL_DOWN);
break;
case 'E':
if (R == bm || R == rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
C=0;
if (debug > 1) System.out.println("String_Node_Str" + R + "String_Node_Str");
break;
case 'D':
if (R == bm || R == rows - 1) insertLine(R,1,SCROLL_UP);
 else R++;
if (debug > 1) System.out.println("String_Node_Str" + R + "String_Node_Str");
break;
case 'J':
if (R < rows - 1) deleteArea(0,R + 1,columns,rows - R - 1,attributes);
if (C < columns - 1) deleteArea(C,R,columns - C,1,attributes);
break;
case 'K':
if (C < columns - 1) deleteArea(C,R,columns - C,1,attributes);
break;
case 'M':
System.out.println("String_Node_Str" + R + "String_Node_Str"+ tm+ "String_Node_Str"+ bm);
if (R > bm) break;
if (R > tm) {
R--;
}
 else {
insertLine(R,1,SCROLL_DOWN);
}
if (debug > 2) System.out.println("String_Node_Str");
break;
case 'H':
if (debug > 1) System.out.println("String_Node_Str" + C);
if (C >= columns) C=columns - 1;
Tabs[C]=1;
break;
case 'N':
onegl=2;
break;
case 'O':
onegl=3;
break;
case '=':
if (debug > 0) System.out.println("String_Node_Str");
keypadmode=true;
break;
case '<':
vt52mode=false;
break;
case '>':
if (debug > 0) System.out.println("String_Node_Str");
keypadmode=false;
break;
case '7':
Sc=C;
Sr=R;
Sgl=gl;
Sgr=gr;
Sa=attributes;
Sgx=new char[4];
for (int i=0; i < 4; i++) Sgx[i]=gx[i];
Stm=getTopMargin();
Sbm=getBottomMargin();
if (debug > 1) System.out.println("String_Node_Str");
break;
case '8':
C=Sc;
R=Sr;
gl=Sgl;
gr=Sgr;
for (int i=0; i < 4; i++) gx[i]=Sgx[i];
setTopMargin(Stm);
setBottomMargin(Sbm);
attributes=Sa;
if (debug > 1) System.out.println("String_Node_Str");
break;
case '(':
term_state=TSTATE_SETG0;
usedcharsets=true;
break;
case ')':
term_state=TSTATE_SETG1;
usedcharsets=true;
break;
case '*':
term_state=TSTATE_SETG2;
usedcharsets=true;
break;
case '+':
term_state=TSTATE_SETG3;
usedcharsets=true;
break;
case '~':
gr=1;
usedcharsets=true;
break;
case 'n':
gl=2;
usedcharsets=true;
break;
case '}':
gr=2;
usedcharsets=true;
break;
case 'o':
gl=3;
usedcharsets=true;
break;
case '|':
gr=3;
usedcharsets=true;
break;
case 'Y':
term_state=TSTATE_VT52Y;
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
break;
}
break;
case TSTATE_VT52X:
C=c - 37;
term_state=TSTATE_VT52Y;
break;
case TSTATE_VT52Y:
R=c - 37;
term_state=TSTATE_DATA;
break;
case TSTATE_SETG0:
if (c != '0' && c != 'A' && c != 'B' && c != '<') System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
 else {
if (debug > 2) System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
gx[0]=c;
}
term_state=TSTATE_DATA;
break;
case TSTATE_SETG1:
if (c != '0' && c != 'A' && c != 'B' && c != '<') {
System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
}
 else {
if (debug > 2) System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
gx[1]=c;
}
term_state=TSTATE_DATA;
break;
case TSTATE_SETG2:
if (c != '0' && c != 'A' && c != 'B' && c != '<') System.out.println("String_Node_Str" + ((int)c) + "String_Node_Str");
 else {
if (debug > 2) System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
gx[2]=c;
}
term_state=TSTATE_DATA;
break;
case TSTATE_SETG3:
if (c != '0' && c != 'A' && c != 'B' && c != '<') System.out.println("String_Node_Str" + ((int)c) + "String_Node_Str");
 else {
if (debug > 2) System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
gx[3]=c;
}
term_state=TSTATE_DATA;
break;
case TSTATE_ESCSQUARE:
switch (c) {
case '8':
for (int i=0; i < columns; i++) for (int j=0; j < rows; j++) putChar(i,j,'E',0);
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str");
break;
}
term_state=TSTATE_DATA;
break;
case TSTATE_DCS:
if (c == '\\' && dcs.charAt(dcs.length() - 1) == ESC) {
handle_dcs(dcs);
term_state=TSTATE_DATA;
break;
}
dcs=dcs + c;
break;
case TSTATE_DCEQ:
term_state=TSTATE_DATA;
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
DCEvars[DCEvar]=DCEvars[DCEvar] * 10 + ((int)c) - 48;
term_state=TSTATE_DCEQ;
break;
case ';':
DCEvar++;
DCEvars[DCEvar]=0;
term_state=TSTATE_DCEQ;
break;
case 's':
if (true || debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'r':
if (true || debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
for (int i=0; i <= DCEvar; i++) {
switch (DCEvars[i]) {
case 3:
setScreenSize(80,getRows());
break;
case 4:
break;
case 5:
break;
case 6:
moveoutsidemargins=true;
break;
case 7:
wraparound=false;
break;
case 12:
break;
case 9:
case 1000:
case 1001:
case 1002:
case 1003:
mouserpt=DCEvars[i];
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
}
}
break;
case 'h':
if (debug > 0) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
for (int i=0; i <= DCEvar; i++) {
switch (DCEvars[i]) {
case 1:
KeyUp[0]="String_Node_Str";
KeyDown[0]="String_Node_Str";
KeyRight[0]="String_Node_Str";
KeyLeft[0]="String_Node_Str";
break;
case 2:
vt52mode=false;
break;
case 3:
setScreenSize(132,getRows());
break;
case 6:
moveoutsidemargins=false;
break;
case 7:
wraparound=true;
break;
case 25:
showCursor(true);
break;
case 9:
case 1000:
case 1001:
case 1002:
case 1003:
mouserpt=DCEvars[i];
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
}
break;
case 'i':
switch (DCEvars[0]) {
case 1:
if (debug > 1) System.out.println("String_Node_Str");
break;
case 4:
if (debug > 1) System.out.println("String_Node_Str");
break;
case 5:
if (debug > 1) System.out.println("String_Node_Str");
break;
}
break;
case 'l':
if (debug > 0) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
for (int i=0; i <= DCEvar; i++) {
switch (DCEvars[i]) {
case 1:
KeyUp[0]="String_Node_Str";
KeyDown[0]="String_Node_Str";
KeyRight[0]="String_Node_Str";
KeyLeft[0]="String_Node_Str";
break;
case 2:
vt52mode=true;
break;
case 3:
setScreenSize(80,getRows());
break;
case 6:
moveoutsidemargins=true;
break;
case 7:
wraparound=false;
break;
case 25:
showCursor(false);
break;
case 9:
case 1000:
case 1001:
case 1002:
case 1003:
mouserpt=0;
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
}
break;
case 'n':
if (debug > 0) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
switch (DCEvars[0]) {
case 15:
write(((char)ESC) + "String_Node_Str",false);
System.out.println("String_Node_Str");
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ c+ "String_Node_Str");
break;
}
break;
case TSTATE_CSI_EX:
term_state=TSTATE_DATA;
switch (c) {
case ESC:
term_state=TSTATE_ESC;
break;
default :
System.out.println("String_Node_Str" + (int)c);
break;
}
break;
case TSTATE_CSI_TICKS:
term_state=TSTATE_DATA;
switch (c) {
case 'p':
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ DCEvars[1]);
if (DCEvars[0] == 61) {
output8bit=false;
break;
}
if (DCEvars[1] == 1) {
output8bit=false;
}
 else {
output8bit=true;
}
break;
default :
System.out.println("String_Node_Str" + c);
break;
}
break;
case TSTATE_CSI_EQUAL:
term_state=TSTATE_DATA;
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
DCEvars[DCEvar]=DCEvars[DCEvar] * 10 + ((int)c) - 48;
term_state=TSTATE_CSI_EQUAL;
break;
case ';':
DCEvar++;
DCEvars[DCEvar]=0;
term_state=TSTATE_CSI_EQUAL;
break;
case 'F':
{
int newcolor;
System.out.print("String_Node_Str" + DCEvars[0] + "String_Node_Str");
attributes&=~COLOR_FG;
newcolor=((DCEvars[0] & 1) << 2) | (DCEvars[0] & 2) | ((DCEvars[0] & 4) >> 2);
attributes|=newcolor << COLOR_FG_SHIFT;
break;
}
case 'G':
{
int newcolor;
System.out.print("String_Node_Str" + DCEvars[0] + "String_Node_Str");
attributes&=~COLOR_BG;
newcolor=((DCEvars[0] & 1) << 2) | (DCEvars[0] & 2) | ((DCEvars[0] & 4) >> 2);
attributes|=newcolor << COLOR_BG_SHIFT;
break;
}
default :
System.out.print("String_Node_Str");
for (int i=0; i < DCEvar; i++) System.out.print(DCEvars[i] + "String_Node_Str");
System.out.println("String_Node_Str" + c);
break;
}
break;
case TSTATE_CSI_DOLLAR:
term_state=TSTATE_DATA;
switch (c) {
case '}':
System.out.println("String_Node_Str" + DCEvars[0]);
statusmode=DCEvars[0];
break;
case '~':
System.out.println("String_Node_Str" + DCEvars[0]);
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str"+ DCEvars[0]);
break;
}
break;
case TSTATE_CSI:
term_state=TSTATE_DATA;
switch (c) {
case '"':
term_state=TSTATE_CSI_TICKS;
break;
case '$':
term_state=TSTATE_CSI_DOLLAR;
break;
case '=':
term_state=TSTATE_CSI_EQUAL;
break;
case '!':
term_state=TSTATE_CSI_EX;
break;
case '?':
DCEvar=0;
DCEvars[0]=0;
term_state=TSTATE_DCEQ;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
DCEvars[DCEvar]=DCEvars[DCEvar] * 10 + ((int)c) - 48;
term_state=TSTATE_CSI;
break;
case ';':
DCEvar++;
DCEvars[DCEvar]=0;
term_state=TSTATE_CSI;
break;
case 'c':
String subcode="String_Node_Str";
if (terminalID.equals("String_Node_Str")) subcode="String_Node_Str";
if (terminalID.equals("String_Node_Str")) subcode="String_Node_Str";
if (terminalID.equals("String_Node_Str")) subcode="String_Node_Str";
write(((char)ESC) + "String_Node_Str" + subcode+ "String_Node_Str",false);
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'q':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'g':
switch (DCEvars[0]) {
case 3:
Tabs=new byte[getColumns()];
break;
case 0:
Tabs[C]=0;
break;
}
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'h':
switch (DCEvars[0]) {
case 4:
insertmode=1;
break;
case 20:
System.out.println("String_Node_Str");
sendcrlf=true;
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'i':
switch (DCEvars[0]) {
case 0:
if (debug > 1) System.out.println("String_Node_Str");
break;
case 4:
if (debug > 1) System.out.println("String_Node_Str");
break;
case 5:
if (debug > 1) System.out.println("String_Node_Str");
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
}
break;
case 'l':
switch (DCEvars[0]) {
case 4:
insertmode=0;
break;
case 20:
System.out.println("String_Node_Str");
sendcrlf=false;
break;
default :
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
break;
case 'A':
{
int limit;
if (R > bm) limit=bm + 1;
 else if (R >= tm) {
limit=tm;
}
 else limit=0;
if (DCEvars[0] == 0) R--;
 else R-=DCEvars[0];
if (R < limit) R=limit;
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
case 'B':
{
int limit;
if (R < tm) limit=tm - 1;
 else if (R <= bm) {
limit=bm;
}
 else limit=rows - 1;
if (DCEvars[0] == 0) R++;
 else R+=DCEvars[0];
if (R > limit) R=limit;
 else {
if (debug > 2) System.out.println("String_Node_Str");
}
if (debug > 2) System.out.println("String_Node_Str" + R);
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ C+ "String_Node_Str");
break;
}
case 'C':
if (DCEvars[0] == 0) C++;
 else C+=DCEvars[0];
if (C > columns - 1) C=columns - 1;
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'd':
R=DCEvars[0];
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'D':
if (DCEvars[0] == 0) C--;
 else C-=DCEvars[0];
if (C < 0) C=0;
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'r':
if (DCEvar > 0) {
R=DCEvars[1] - 1;
if (R < 0) R=rows - 1;
 else if (R >= rows) {
R=rows - 1;
}
}
 else R=rows - 1;
setBottomMargin(R);
if (R >= DCEvars[0]) {
R=DCEvars[0] - 1;
if (R < 0) R=0;
}
setTopMargin(R);
_SetCursor(0,0);
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ DCEvars[1]+ "String_Node_Str");
break;
case 'G':
C=DCEvars[0];
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case 'H':
_SetCursor(DCEvars[0] - 1,DCEvars[1] - 1);
if (debug > 2) {
System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ DCEvars[1]+ "String_Node_Str"+ moveoutsidemargins);
System.out.println("String_Node_Str" + R + "String_Node_Str"+ C);
}
break;
case 'f':
R=DCEvars[0] - 1;
C=DCEvars[1] - 1;
if (C < 0) C=0;
if (R < 0) R=0;
if (debug > 2) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ DCEvars[1]+ "String_Node_Str");
break;
case 'S':
if (DCEvars[0] == 0) insertLine(rows - 1,SCROLL_UP);
 else insertLine(rows - 1,DCEvars[0],SCROLL_UP);
break;
case 'L':
if (DCEvars[0] == 0) insertLine(R,SCROLL_DOWN);
 else insertLine(R,DCEvars[0],SCROLL_DOWN);
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ (c)+ "String_Node_Str"+ R+ "String_Node_Str");
break;
case 'T':
if (DCEvars[0] == 0) insertLine(0,SCROLL_DOWN);
 else insertLine(0,DCEvars[0],SCROLL_DOWN);
break;
case 'M':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ (c)+ "String_Node_Str"+ R);
if (DCEvars[0] == 0) deleteLine(R);
 else for (int i=0; i < DCEvars[0]; i++) deleteLine(R);
break;
case 'K':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
switch (DCEvars[0]) {
case 6:
case 0:
if (C < columns - 1) deleteArea(C,R,columns - C,1,attributes);
break;
case 1:
if (C > 0) deleteArea(0,R,C + 1,1,attributes);
break;
case 2:
deleteArea(0,R,columns,1,attributes);
break;
}
break;
case 'J':
switch (DCEvars[0]) {
case 0:
if (R < rows - 1) deleteArea(0,R + 1,columns,rows - R - 1,attributes);
if (C < columns - 1) deleteArea(C,R,columns - C,1,attributes);
break;
case 1:
if (R > 0) deleteArea(0,0,columns,R,attributes);
if (C > 0) deleteArea(0,R,C + 1,1,attributes);
break;
case 2:
deleteArea(0,0,columns,rows,attributes);
break;
}
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
case '@':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
for (int i=0; i < DCEvars[0]; i++) insertChar(C,R,' ',attributes);
break;
case 'X':
{
int toerase=DCEvars[0];
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ C+ "String_Node_Str"+ R);
if (toerase == 0) toerase=1;
if (toerase + C > columns) toerase=columns - C;
deleteArea(C,R,toerase,1,attributes);
break;
}
case 'P':
if (debug > 1) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str"+ C+ "String_Node_Str"+ R);
if (DCEvars[0] == 0) DCEvars[0]=1;
for (int i=0; i < DCEvars[0]; i++) deleteChar(C,R);
break;
case 'n':
switch (DCEvars[0]) {
case 5:
writeSpecial(((char)ESC) + "String_Node_Str");
if (debug > 1) System.out.println("String_Node_Str");
break;
case 6:
writeSpecial(((char)ESC) + "String_Node_Str" + R+ "String_Node_Str"+ C+ "String_Node_Str");
if (debug > 1) System.out.println("String_Node_Str");
break;
default :
if (debug > 0) System.out.println("String_Node_Str" + DCEvars[0] + "String_Node_Str");
break;
}
break;
case 's':
Sc=C;
Sr=R;
Sa=attributes;
if (debug > 3) System.out.println("String_Node_Str");
break;
case 'u':
C=Sc;
R=Sr;
attributes=Sa;
if (debug > 3) System.out.println("String_Node_Str");
break;
case 'm':
if (debug > 3) System.out.print("String_Node_Str");
if (DCEvar == 0 && DCEvars[0] == 0) attributes=0;
for (int i=0; i <= DCEvar; i++) {
switch (DCEvars[i]) {
case 0:
if (DCEvar > 0) {
if (terminalID.equals("String_Node_Str")) {
attributes&=COLOR;
}
 else {
attributes=0;
}
}
break;
case 1:
attributes|=BOLD;
attributes&=~LOW;
break;
case 2:
if (terminalID.equals("String_Node_Str") && ((DCEvar - i) >= 2)) {
int ncolor;
attributes&=~(COLOR | BOLD);
ncolor=DCEvars[i + 1];
if ((ncolor & 8) == 8) attributes|=BOLD;
ncolor=((ncolor & 1) << 2) | (ncolor & 2) | ((ncolor & 4) >> 2);
attributes|=((ncolor) + 1) << COLOR_FG_SHIFT;
ncolor=DCEvars[i + 2];
ncolor=((ncolor & 1) << 2) | (ncolor & 2) | ((ncolor & 4) >> 2);
attributes|=((ncolor) + 1) << COLOR_BG_SHIFT;
i+=2;
}
 else {
attributes|=LOW;
}
break;
case 4:
attributes|=UNDERLINE;
break;
case 7:
attributes|=INVERT;
break;
case 8:
attributes|=INVISIBLE;
break;
case 5:
break;
case 10:
gl=0;
usedcharsets=true;
break;
case 11:
case 12:
gl=1;
usedcharsets=true;
break;
case 21:
attributes&=~(LOW | BOLD);
break;
case 25:
break;
case 27:
attributes&=~INVERT;
break;
case 28:
attributes&=~INVISIBLE;
break;
case 24:
attributes&=~UNDERLINE;
break;
case 22:
attributes&=~BOLD;
break;
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
attributes&=~COLOR_FG;
attributes|=((DCEvars[i] - 30) + 1) << COLOR_FG_SHIFT;
break;
case 39:
attributes&=~COLOR_FG;
break;
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
attributes&=~COLOR_BG;
attributes|=((DCEvars[i] - 40) + 1) << COLOR_BG_SHIFT;
break;
case 49:
attributes&=~COLOR_BG;
break;
default :
System.out.println("String_Node_Str" + DCEvars[i] + "String_Node_Str");
break;
}
if (debug > 3) System.out.print("String_Node_Str" + DCEvars[i] + "String_Node_Str");
}
if (debug > 3) System.out.print("String_Node_Str" + attributes + "String_Node_Str");
break;
default :
System.out.println("String_Node_Str" + c + "String_Node_Str"+ ((int)c)+ "String_Node_Str");
break;
}
break;
default :
term_state=TSTATE_DATA;
break;
}
if (C > columns) C=columns;
if (R > rows) R=rows;
if (C < 0) C=0;
if (R < 0) R=0;
if (doshowcursor) setCursorPosition(C,R);
markLine(R,1);
}