Mercurial > 510Connectbot
changeset 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 |
files | src/com/five_ten_sg/connectbot/transport/TN5250.java src/org/tn5250j/framework/tn5250/Screen5250.java |
diffstat | 2 files changed, 44 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java Wed Jul 02 14:07:03 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java Wed Jul 02 14:32:13 2014 -0700 @@ -181,6 +181,32 @@ } @Override public void write(int b) { + if (b == 120) { + // special case x for testing + setField(17, 44, new char[] { '1', '2' }); + keyPressed(KEY_TAB, ' ', 0); + keyPressed(KEY_TAB, ' ', 0); + setField(-1, -1, new char[] { '3', '4' }); + setField(18, 44, new char[0]); + setField(-1, -1, new char[] { '5', '6' }); + return; + } + if (b == 121) { + // special case y for testing + setField(17, 44, new char[0]); + setField(-1, -1, new char[] { '2', '1' }); + keyPressed(KEY_TAB, ' ', 0); + keyPressed(KEY_TAB, ' ', 0); + setField(-1, -1, new char[] { '4', '3' }); + setField(18, 44, new char[0]); + setField(-1, -1, new char[] { '6', '5' }); + return; + } + if (b == 122) { + // special case z for testing + setField(17, 40, new char[0]); + return; + } if (controls.containsKey(b)) keyPressed(controls.get(b), ' ', 0); else screen52.sendKeys(new String(new byte[] {(byte)b})); testChanged();
--- a/src/org/tn5250j/framework/tn5250/Screen5250.java Wed Jul 02 14:07:03 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/Screen5250.java Wed Jul 02 14:32:13 2014 -0700 @@ -518,7 +518,7 @@ // gui.repaint(); // } else { goto_XY(pos); - isInField(lastPos); + isInField(); // return back to the calling object that the cursor was indeed // moved with in the screen object return true; @@ -948,9 +948,7 @@ bufferedKeys = null; } - // check to see if position is in a field and if it is then change - // current field to that field - isInField(lastPos, true); + isInField(); if (text.length() == 1 && !text.equals("[") && !text.equals("]")) { setCursorActive(false); @@ -966,9 +964,7 @@ while (!done) { if (strokenizer.hasMoreKeyStrokes()) { - // check to see if position is in a field and if it is - // then change current field to that field - isInField(lastPos, true); + isInField(); s = strokenizer.nextKeyStroke(); if (s.length() == 1) { @@ -1155,7 +1151,7 @@ || screenFields.isCurrentFieldContinuedLast()); } - isInField(lastPos); + isInField(); simulated = true; break; @@ -1230,7 +1226,7 @@ .isCurrentFieldContinuedLast())); } - isInField(lastPos); + isInField(); simulated = true; break; @@ -1334,8 +1330,7 @@ // position to the home position set if (lastPos + numCols + 1 != homePos) { goto_XY(homePos - numCols - 1); - // now check if we are in a field - isInField(lastPos); + isInField(); } else gotoField(1); @@ -1578,7 +1573,7 @@ case RESET: if (isStatusErrorCode()) { resetError(); - isInField(lastPos); + isInField(); updateDirty(); } else { @@ -2679,6 +2674,15 @@ lastPos = cf.getStartPos(); setDirty(lastPos); setDirty(lastPos + cf.getLength()); + lastPos += data.length; + if (!isInField()) { + gotoFieldNext(); + isInField(); + } + cf = screenFields.getCurrentField(); + lastPos = cf.getStartPos(); + setDirty(lastPos); + fireCursorChanged(); } updateDirty(); @@ -3591,13 +3595,13 @@ // - A default starting address of row 1 column 1. if (pendingInsert && homePos > 0) { setCursor(getRow(homePos), getCol(homePos)); - isInField(); // we now check if we are in a field + isInField(); } else { if (!gotoField(1)) { homePos = getPos(1, 1); setCursor(1, 1); - isInField(0, 0); // we now check if we are in a field + isInField(0, 0); } else { homePos = getPos(getCurrentRow(), getCurrentCol());