# HG changeset patch # User Carl Byington # Date 1404340818 25200 # Node ID 81f9ba83c0e926115dfbb7c4ff6bbda74ba226dd # Parent 61a90cb1938d9c370449f4cd1248e8b223f60ef5 setfield positions the cursor properly as if the characters were typed diff -r 61a90cb1938d -r 81f9ba83c0e9 src/org/tn5250j/framework/tn5250/Screen5250.java --- a/src/org/tn5250j/framework/tn5250/Screen5250.java Wed Jul 02 15:03:06 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/Screen5250.java Wed Jul 02 15:40:18 2014 -0700 @@ -2662,8 +2662,8 @@ if (l >= 0) { int position = l * numCols + c; if (!isInField(position, true)) { - gotoFieldNext(); - isInField(); + lastPos = position; + while (!isInField()) advancePos(); cf = screenFields.getCurrentField(); lastPos = cf.getStartPos(); } @@ -3576,19 +3576,11 @@ */ protected void changePos(int i) { lastPos += i; - - if (lastPos < 0) - lastPos = lenScreen + lastPos; - - if (lastPos > lenScreen - 1) - lastPos = lastPos - lenScreen; - - // System.out.println(lastRow + "," + ((lastPos) / numCols) + "," + - // lastCol + "," + ((lastPos) % numCols) + "," + - // ((lastRow * numCols) + lastCol) + "," + - // (lastPos)); + while (lastPos < 0) lastPos += lenScreen; + while (lastPos >= lenScreen) lastPos -= lenScreen; } + protected void goHome() { // now we try to move to first input field according to // 14.6 WRITE TO DISPLAY Command