X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FSwingTerminal.java;h=bd1ba87ce2d3c442ce5254f358254586cae0227e;hb=9f613a0c54cb97e9305fd87ce8eb2f76ac82804e;hp=67211a6c64148e6204edcb23ab84029f2c21049c;hpb=2a92cf977ee2ae37d8302a294c6338fa51a5ca45;p=fanfix.git diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index 67211a6..bd1ba87 100644 --- a/src/jexer/backend/SwingTerminal.java +++ b/src/jexer/backend/SwingTerminal.java @@ -98,7 +98,7 @@ public class SwingTerminal extends LogicalScreen /** * The terminus font resource filename. */ - private static final String FONTFILE = "terminus-ttf-4.39/TerminusTTF-Bold-4.39.ttf"; + public static final String FONTFILE = "terminus-ttf-4.39/TerminusTTF-Bold-4.39.ttf"; /** * Cursor style to draw. @@ -301,6 +301,13 @@ public class SwingTerminal extends LogicalScreen // Constructors ----------------------------------------------------------- // ------------------------------------------------------------------------ + /** + * Static constructor. + */ + static { + setDOSColors(); + } + /** * Public constructor creates a new JFrame to render to. * @@ -316,7 +323,6 @@ public class SwingTerminal extends LogicalScreen this.fontSize = fontSize; - setDOSColors(); reloadOptions(); try { @@ -438,7 +444,6 @@ public class SwingTerminal extends LogicalScreen this.fontSize = fontSize; - setDOSColors(); reloadOptions(); try { @@ -567,7 +572,6 @@ public class SwingTerminal extends LogicalScreen && (swing.getBufferStrategy() != null) ) { do { - clearPhysical(); do { drawToSwing(); } while (swing.getBufferStrategy().contentsRestored()); @@ -715,6 +719,15 @@ public class SwingTerminal extends LogicalScreen return blinkMillis; } + /** + * Get the current status of the blink flag. + * + * @return true if the cursor and blinking text should be visible + */ + public boolean getCursorBlinkVisible() { + return cursorBlinkVisible; + } + /** * Get the font size in points. * @@ -882,7 +895,7 @@ public class SwingTerminal extends LogicalScreen * @param attr the text attributes * @return the Swing Color */ - private Color attrToForegroundColor(final CellAttributes attr) { + public static Color attrToForegroundColor(final CellAttributes attr) { int rgb = attr.getForeColorRGB(); if (rgb >= 0) { int red = (rgb >> 16) & 0xFF; @@ -939,7 +952,7 @@ public class SwingTerminal extends LogicalScreen * @param attr the text attributes * @return the Swing Color */ - private Color attrToBackgroundColor(final CellAttributes attr) { + public static Color attrToBackgroundColor(final CellAttributes attr) { int rgb = attr.getBackColorRGB(); if (rgb >= 0) { int red = (rgb >> 16) & 0xFF; @@ -1187,8 +1200,7 @@ public class SwingTerminal extends LogicalScreen gr2 = (Graphics2D) gr; } - Cell cellColor = new Cell(); - cellColor.setTo(cell); + Cell cellColor = new Cell(cell); // Check for reverse if (cell.isReverse()) { @@ -1220,8 +1232,7 @@ public class SwingTerminal extends LogicalScreen // We need a new key that will not be mutated by // invertCell(). - Cell key = new Cell(); - key.setTo(cell); + Cell key = new Cell(cell); if (cell.isBlink() && !cursorBlinkVisible) { glyphCacheBlink.put(key, image); } else { @@ -1254,18 +1265,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; } }