- for (int y = 0; y < screen.height; y++) {
- for (int x = 0; x < screen.width; x++) {
- int xPixel = x * textWidth + left;
- int yPixel = y * textHeight + top;
-
- Cell lCell = screen.logical[x][y];
- Cell pCell = screen.physical[x][y];
-
- boolean inBounds = true;
- if (bounds != null) {
- if (bounds.contains(xPixel, yPixel)
- || bounds.contains(xPixel + textWidth, yPixel)
- || bounds.contains(xPixel, yPixel + textHeight)
- || bounds.contains(xPixel + textWidth,
- yPixel + textHeight)
- ) {
- // This area is damaged and will definitely be
- // redrawn.
- inBounds = true;
+ // Prevent updates to the screen's data from the TApplication
+ // threads.
+ synchronized (screen) {
+ /*
+ System.err.printf("bounds %s X %d %d Y %d %d\n",
+ bounds, xCellMin, xCellMax, yCellMin, yCellMax);
+ */
+
+ for (int y = yCellMin; y < yCellMax; y++) {
+ for (int x = xCellMin; x < xCellMax; x++) {
+
+ int xPixel = x * textWidth + left;
+ int yPixel = y * textHeight + top;
+
+ Cell lCell = screen.logical[x][y];
+ Cell pCell = screen.physical[x][y];
+
+ if (!lCell.equals(pCell) || reallyCleared) {
+ // Draw the background rectangle, then the
+ // foreground character.
+ gr.setColor(attrToBackgroundColor(lCell));
+ gr.fillRect(xPixel, yPixel, textWidth, textHeight);
+ gr.setColor(attrToForegroundColor(lCell));
+ char [] chars = new char[1];
+ chars[0] = lCell.getChar();
+ gr.drawChars(chars, 0, 1, xPixel,
+ yPixel + textHeight - maxDescent);
+
+ // Physical is always updated
+ physical[x][y].setTo(lCell);