Skip to content

Commit

Permalink
Prevent typing outside unprotected fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolony committed Feb 22, 2015
1 parent ea000a7 commit 5bd80bb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/com/bytezone/dm3270/application/ConsoleKeyEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public void handle (KeyEvent e) // onKeyTyped
char ch = c.charAt (0);
if (ch >= 32 && ch < 0x7F)
{
ScreenPosition sp = cursor.getScreenPosition ();
sp.setCharacter ((byte) Utility.asc2ebc[ch]);
cursor.setVisible (false);
ScreenPosition screenPosition = cursor.getScreenPosition ();
ScreenField screenField = screenHandler.getCurrentField ();

if (screenHandler.getCurrentField () != null)
screenHandler.getCurrentField ().setModified (true);

sp = screenHandler.getScreenPosition (cursor.moveRight ());
cursor.setVisible (true);
if (screenField != null && screenField.isModifiable ())
{
screenPosition.setCharacter ((byte) Utility.asc2ebc[ch]);
screenField.setModified (true);
screenHandler.moveCursor (KeyCode.RIGHT);
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/com/bytezone/dm3270/application/ScreenField.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public boolean matchesLocation (int location)
return startPosition == location;
}

public void clear () // NB this will assigns the attribute byte as well
public void clear () // NB this will assign the attribute byte as well
{
setModified (true);
for (ScreenPosition sp : screenPositions)
sp.setCharacter ((byte) 0);
sp.resetCharacter ();
}

public boolean isModified ()
Expand All @@ -147,7 +147,7 @@ public void setModified (boolean modified)
StartFieldAttribute sfa = getStartFieldAttribute ();
if (sfa != null)
sfa.setModified (modified);
screenHandler.fieldModified (this);
screenHandler.fieldModified (this); // display the new status
}

public String getFieldType ()
Expand Down Expand Up @@ -219,7 +219,7 @@ public int pack (byte[] buffer, int ptr)
@Override
public String toString ()
{
return String.format ("%04d-%04d %4d [%s]", startPosition, endPosition,
getLength (), getString ());
return String.format ("%04d-%04d %4d %s [%s]", startPosition, endPosition,
getLength (), getFieldType (), getString ());
}
}
6 changes: 6 additions & 0 deletions src/com/bytezone/dm3270/application/ScreenPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public boolean isProtected ()
return isStartField && getStartFieldAttribute ().isProtected ();
}

public void resetCharacter ()
{
character = 0;
isGraphicsCharacter = false;
}

public void setCharacter (byte b)
{
character = b;
Expand Down

0 comments on commit 5bd80bb

Please sign in to comment.