X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=inline;f=src%2Fjexer%2Fio%2FAWTScreen.java;h=208bea356496334386bf2ee0cd02b2172cdcdbe7;hb=091d8a06c7f9f91c2a15c9350b6502cf4c10f5a3;hp=a3fc41f19fa03563ca292c5f4feed4e28fd0c33f;hpb=aed3368728b9a72b738340b73a6fbc812b5cbf89;p=nikiroo-utils.git diff --git a/src/jexer/io/AWTScreen.java b/src/jexer/io/AWTScreen.java index a3fc41f..208bea3 100644 --- a/src/jexer/io/AWTScreen.java +++ b/src/jexer/io/AWTScreen.java @@ -38,7 +38,6 @@ import java.awt.Color; import java.awt.Cursor; import java.awt.Font; import java.awt.FontMetrics; -import java.awt.Frame; import java.awt.Graphics; import java.awt.Insets; import java.awt.Point; @@ -107,6 +106,11 @@ public final class AWTScreen extends Screen { */ class AWTFrame extends JFrame { + /** + * Serializable version. + */ + private static final long serialVersionUID = 1; + /** * The terminus font resource filename. */ @@ -256,24 +260,27 @@ public final class AWTScreen extends Screen { setFont(new Font(Font.MONOSPACED, Font.PLAIN, 24)); } pack(); - setVisible(true); - resizeToScreen(); // Kill the X11 cursor // Transparent 16 x 16 pixel cursor image. BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); - // Create a new blank cursor. Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor( cursorImg, new Point(0, 0), "blank cursor"); setCursor(blankCursor); + + // Be capable of seeing Tab / Shift-Tab + setFocusTraversalKeysEnabled(false); + + // Save the text cell width/height + getFontDimensions(); } /** - * Resize to font dimensions. + * Figure out my font dimensions. */ - public void resizeToScreen() { + private void getFontDimensions() { Graphics gr = getGraphics(); FontMetrics fm = gr.getFontMetrics(); maxDescent = fm.getMaxDescent(); @@ -284,7 +291,12 @@ public final class AWTScreen extends Screen { // This also produces the same number, but works better for ugly // monospace. textHeight = fm.getMaxAscent() + maxDescent - leading; + } + /** + * Resize to font dimensions. + */ + public void resizeToScreen() { // Figure out the thickness of borders and use that to set the // final size. Insets insets = getInsets(); @@ -293,11 +305,6 @@ public final class AWTScreen extends Screen { setSize(textWidth * screen.width + insets.left + insets.right, textHeight * screen.height + insets.top + insets.bottom); - - /* - System.err.printf("W: %d H: %d MD: %d L: %d\n", textWidth, - textHeight, maxDescent, leading); - */ } /** @@ -336,7 +343,7 @@ public final class AWTScreen extends Screen { if (bounds != null) { // Only update what is in the bounds xCellMin = screen.textColumn(bounds.x); - xCellMax = screen.textColumn(bounds.x + bounds.width) + 1; + xCellMax = screen.textColumn(bounds.x + bounds.width); if (xCellMax > screen.width) { xCellMax = screen.width; } @@ -347,7 +354,7 @@ public final class AWTScreen extends Screen { xCellMin = 0; } yCellMin = screen.textRow(bounds.y); - yCellMax = screen.textRow(bounds.y + bounds.height) + 1; + yCellMax = screen.textRow(bounds.y + bounds.height); if (yCellMax > screen.height) { yCellMax = screen.height; } @@ -357,6 +364,9 @@ public final class AWTScreen extends Screen { if (yCellMin < 0) { yCellMin = 0; } + } else { + // We need a total repaint + reallyCleared = true; } // Prevent updates to the screen's data from the TApplication @@ -409,7 +419,8 @@ public final class AWTScreen extends Screen { reallyCleared = false; } // synchronized (screen) } - } + + } // class AWTFrame /** * The raw AWT Frame. Note package private access. @@ -424,6 +435,16 @@ public final class AWTScreen extends Screen { SwingUtilities.invokeAndWait(new Runnable() { public void run() { AWTScreen.this.frame = new AWTFrame(AWTScreen.this); + AWTScreen.this.sessionInfo = + new AWTSessionInfo(AWTScreen.this.frame, + frame.textWidth, + frame.textHeight); + + AWTScreen.this.setDimensions(sessionInfo.getWindowWidth(), + sessionInfo.getWindowHeight()); + + AWTScreen.this.frame.resizeToScreen(); + AWTScreen.this.frame.setVisible(true); } } ); } catch (Exception e) { @@ -431,14 +452,17 @@ public final class AWTScreen extends Screen { } } + /** + * The sessionInfo. + */ + private AWTSessionInfo sessionInfo; + /** * Create the AWTSessionInfo. Note package private access. * * @return the sessionInfo */ AWTSessionInfo getSessionInfo() { - AWTSessionInfo sessionInfo = new AWTSessionInfo(frame, frame.textWidth, - frame.textHeight); return sessionInfo; }