X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FSwingTerminal.java;h=65decfa3642688047465d568dfff2a6ccd88126c;hb=afdec5e9d0416e1c571f1961572b8ededef81146;hp=f5d15447b37eca234bd460476a088cdfa94a41b8;hpb=e13561306e98c5ec88a84d0fa4bfabbd584239df;p=fanfix.git diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index f5d1544..65decfa 100644 --- a/src/jexer/backend/SwingTerminal.java +++ b/src/jexer/backend/SwingTerminal.java @@ -182,12 +182,12 @@ public class SwingTerminal extends LogicalScreen /** * Width of a character cell in pixels. */ - private int textWidth = 1; + private int textWidth = 16; /** * Height of a character cell in pixels. */ - private int textHeight = 1; + private int textHeight = 20; /** * Width of a character cell in pixels, as reported by font. @@ -403,7 +403,7 @@ public class SwingTerminal extends LogicalScreen SwingTerminal.this.setDimensions(sessionInfo. getWindowWidth(), sessionInfo.getWindowHeight()); - SwingTerminal.this.resizeToScreen(); + SwingTerminal.this.resizeToScreen(true); SwingTerminal.this.swing.setVisible(true); } }); @@ -572,8 +572,8 @@ public class SwingTerminal extends LogicalScreen && (swing.getBufferStrategy() != null) ) { do { - clearPhysical(); do { + clearPhysical(); drawToSwing(); } while (swing.getBufferStrategy().contentsRestored()); @@ -761,7 +761,7 @@ public class SwingTerminal extends LogicalScreen swing.setFont(font); glyphCacheBlink = new HashMap(); glyphCache = new HashMap(); - resizeToScreen(); + resizeToScreen(true); } } @@ -1110,13 +1110,24 @@ public class SwingTerminal extends LogicalScreen gotFontDimensions = true; } + /** + * Resize the physical screen to match the logical screen dimensions. + * + * @param resizeComponent if true, resize the Swing component + */ + private void resizeToScreen(final boolean resizeComponent) { + if (resizeComponent) { + swing.setDimensions(textWidth * width, textHeight * height); + } + clearPhysical(); + } + /** * Resize the physical screen to match the logical screen dimensions. */ @Override public void resizeToScreen() { - swing.setDimensions(textWidth * width, textHeight * height); - clearPhysical(); + resizeToScreen(false); } /** @@ -1218,9 +1229,8 @@ public class SwingTerminal extends LogicalScreen || (cell.isBlink() && cursorBlinkVisible) ) { gr2.setColor(attrToForegroundColor(cellColor)); - char [] chars = new char[1]; - chars[0] = cell.getChar(); - gr2.drawChars(chars, 0, 1, gr2x + textAdjustX, + char [] chars = Character.toChars(cell.getChar()); + gr2.drawChars(chars, 0, chars.length, gr2x + textAdjustX, gr2y + textHeight - maxDescent + textAdjustY); if (cell.isUnderline()) { @@ -1818,6 +1828,7 @@ public class SwingTerminal extends LogicalScreen break; default: if (!alt && ctrl && !shift) { + // Control character, replace ch with 'A', 'B', etc. ch = KeyEvent.getKeyText(key.getKeyCode()).charAt(0); } // Not a special key, put it together