comparison src/org/tn5250j/framework/tn5250/Screen5250.java @ 184:cdaaa53b5eca

setfield positions the cursor properly as if the characters were typed
author Carl Byington <carl@five-ten-sg.com>
date Wed, 02 Jul 2014 14:32:13 -0700
parents 97848d5dd28f
children c51bcf9f0516
comparison
equal deleted inserted replaced
183:97848d5dd28f 184:cdaaa53b5eca
516 // if (gui.rubberband.isAreaSelected()) { 516 // if (gui.rubberband.isAreaSelected()) {
517 // gui.rubberband.reset(); 517 // gui.rubberband.reset();
518 // gui.repaint(); 518 // gui.repaint();
519 // } else { 519 // } else {
520 goto_XY(pos); 520 goto_XY(pos);
521 isInField(lastPos); 521 isInField();
522 // return back to the calling object that the cursor was indeed 522 // return back to the calling object that the cursor was indeed
523 // moved with in the screen object 523 // moved with in the screen object
524 return true; 524 return true;
525 // } 525 // }
526 } 526 }
946 946
947 oia.setKeysBuffered(false); 947 oia.setKeysBuffered(false);
948 bufferedKeys = null; 948 bufferedKeys = null;
949 } 949 }
950 950
951 // check to see if position is in a field and if it is then change 951 isInField();
952 // current field to that field
953 isInField(lastPos, true);
954 952
955 if (text.length() == 1 && !text.equals("[") && !text.equals("]")) { 953 if (text.length() == 1 && !text.equals("[") && !text.equals("]")) {
956 setCursorActive(false); 954 setCursorActive(false);
957 simulateKeyStroke(text.charAt(0)); 955 simulateKeyStroke(text.charAt(0));
958 setCursorActive(true); 956 setCursorActive(true);
964 // setCursorOff2(); 962 // setCursorOff2();
965 setCursorActive(false); 963 setCursorActive(false);
966 964
967 while (!done) { 965 while (!done) {
968 if (strokenizer.hasMoreKeyStrokes()) { 966 if (strokenizer.hasMoreKeyStrokes()) {
969 // check to see if position is in a field and if it is 967 isInField();
970 // then change current field to that field
971 isInField(lastPos, true);
972 s = strokenizer.nextKeyStroke(); 968 s = strokenizer.nextKeyStroke();
973 969
974 if (s.length() == 1) { 970 if (s.length() == 1) {
975 simulateKeyStroke(s.charAt(0)); 971 simulateKeyStroke(s.charAt(0));
976 } 972 }
1153 } 1149 }
1154 while (screenFields.isCurrentFieldContinuedMiddle() 1150 while (screenFields.isCurrentFieldContinuedMiddle()
1155 || screenFields.isCurrentFieldContinuedLast()); 1151 || screenFields.isCurrentFieldContinuedLast());
1156 } 1152 }
1157 1153
1158 isInField(lastPos); 1154 isInField();
1159 simulated = true; 1155 simulated = true;
1160 break; 1156 break;
1161 1157
1162 case UP: 1158 case UP:
1163 case MARK_UP: 1159 case MARK_UP:
1228 while (screenFields.getCurrentField() != null 1224 while (screenFields.getCurrentField() != null
1229 && (screenFields.isCurrentFieldContinuedMiddle() || screenFields 1225 && (screenFields.isCurrentFieldContinuedMiddle() || screenFields
1230 .isCurrentFieldContinuedLast())); 1226 .isCurrentFieldContinuedLast()));
1231 } 1227 }
1232 1228
1233 isInField(lastPos); 1229 isInField();
1234 simulated = true; 1230 simulated = true;
1235 break; 1231 break;
1236 1232
1237 case EOF: 1233 case EOF:
1238 if (screenFields.getCurrentField() != null 1234 if (screenFields.getCurrentField() != null
1332 1328
1333 case HOME: 1329 case HOME:
1334 // position to the home position set 1330 // position to the home position set
1335 if (lastPos + numCols + 1 != homePos) { 1331 if (lastPos + numCols + 1 != homePos) {
1336 goto_XY(homePos - numCols - 1); 1332 goto_XY(homePos - numCols - 1);
1337 // now check if we are in a field 1333 isInField();
1338 isInField(lastPos);
1339 } 1334 }
1340 else 1335 else
1341 gotoField(1); 1336 gotoField(1);
1342 1337
1343 break; 1338 break;
1576 break; 1571 break;
1577 1572
1578 case RESET: 1573 case RESET:
1579 if (isStatusErrorCode()) { 1574 if (isStatusErrorCode()) {
1580 resetError(); 1575 resetError();
1581 isInField(lastPos); 1576 isInField();
1582 updateDirty(); 1577 updateDirty();
1583 } 1578 }
1584 else { 1579 else {
1585 setPrehelpState(false, oia.isKeyBoardLocked(), false); 1580 setPrehelpState(false, oia.isKeyBoardLocked(), false);
1586 } 1581 }
2677 cf = screenFields.getCurrentField(); 2672 cf = screenFields.getCurrentField();
2678 cf.setString(new String(data)); 2673 cf.setString(new String(data));
2679 lastPos = cf.getStartPos(); 2674 lastPos = cf.getStartPos();
2680 setDirty(lastPos); 2675 setDirty(lastPos);
2681 setDirty(lastPos + cf.getLength()); 2676 setDirty(lastPos + cf.getLength());
2677 lastPos += data.length;
2678 if (!isInField()) {
2679 gotoFieldNext();
2680 isInField();
2681 }
2682 cf = screenFields.getCurrentField();
2683 lastPos = cf.getStartPos();
2684 setDirty(lastPos);
2685 fireCursorChanged();
2682 } 2686 }
2683 2687
2684 updateDirty(); 2688 updateDirty();
2685 } 2689 }
2686 2690
3589 // - The start of the first non-bypass input field defined in the 3593 // - The start of the first non-bypass input field defined in the
3590 // format table 3594 // format table
3591 // - A default starting address of row 1 column 1. 3595 // - A default starting address of row 1 column 1.
3592 if (pendingInsert && homePos > 0) { 3596 if (pendingInsert && homePos > 0) {
3593 setCursor(getRow(homePos), getCol(homePos)); 3597 setCursor(getRow(homePos), getCol(homePos));
3594 isInField(); // we now check if we are in a field 3598 isInField();
3595 } 3599 }
3596 else { 3600 else {
3597 if (!gotoField(1)) { 3601 if (!gotoField(1)) {
3598 homePos = getPos(1, 1); 3602 homePos = getPos(1, 1);
3599 setCursor(1, 1); 3603 setCursor(1, 1);
3600 isInField(0, 0); // we now check if we are in a field 3604 isInField(0, 0);
3601 } 3605 }
3602 else { 3606 else {
3603 homePos = getPos(getCurrentRow(), getCurrentCol()); 3607 homePos = getPos(getCurrentRow(), getCurrentCol());
3604 } 3608 }
3605 } 3609 }