X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FSwingTerminal.java;h=134eceda63772cec5c776b9d0dedf323f4559bf3;hb=bfa37f3b2ef87d39c15fad7d565c00cbabd92acf;hp=58b8f799cf7f1e1153f2ef60f2af486ba96d03da;hpb=027de5ae322ef58d3bc74051d3aa20847455361a;p=fanfix.git diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index 58b8f79..134eced 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); } }); @@ -573,6 +573,7 @@ public class SwingTerminal extends LogicalScreen ) { do { do { + clearPhysical(); drawToSwing(); } while (swing.getBufferStrategy().contentsRestored()); @@ -760,7 +761,7 @@ public class SwingTerminal extends LogicalScreen swing.setFont(font); glyphCacheBlink = new HashMap(); glyphCache = new HashMap(); - resizeToScreen(); + resizeToScreen(true); } } @@ -1109,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); } /** @@ -1265,18 +1277,31 @@ public class SwingTerminal extends LogicalScreen int xPixel = cursorX * textWidth + left; int yPixel = cursorY * textHeight + top; Cell lCell = logical[cursorX][cursorY]; + int cursorWidth = textWidth; + switch (lCell.getWidth()) { + case SINGLE: + // NOP + break; + case LEFT: + cursorWidth *= 2; + break; + case RIGHT: + cursorWidth *= 2; + xPixel -= textWidth; + break; + } gr.setColor(attrToForegroundColor(lCell)); switch (cursorStyle) { default: // Fall through... case UNDERLINE: - gr.fillRect(xPixel, yPixel + textHeight - 2, textWidth, 2); + gr.fillRect(xPixel, yPixel + textHeight - 2, cursorWidth, 2); break; case BLOCK: - gr.fillRect(xPixel, yPixel, textWidth, textHeight); + gr.fillRect(xPixel, yPixel, cursorWidth, textHeight); break; case OUTLINE: - gr.drawRect(xPixel, yPixel, textWidth - 1, textHeight - 1); + gr.drawRect(xPixel, yPixel, cursorWidth - 1, textHeight - 1); break; } }