git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
#37 still need it afterall
[nikiroo-utils.git]
/
src
/
jexer
/
backend
/
SwingTerminal.java
diff --git
a/src/jexer/backend/SwingTerminal.java
b/src/jexer/backend/SwingTerminal.java
index 67211a6c64148e6204edcb23ab84029f2c21049c..f5d15447b37eca234bd460476a088cdfa94a41b8 100644
(file)
--- 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.
*/
/**
* The terminus font resource filename.
*/
- p
rivate
static final String FONTFILE = "terminus-ttf-4.39/TerminusTTF-Bold-4.39.ttf";
+ p
ublic
static final String FONTFILE = "terminus-ttf-4.39/TerminusTTF-Bold-4.39.ttf";
/**
* Cursor style to draw.
/**
* Cursor style to draw.
@@
-301,6
+301,13
@@
public class SwingTerminal extends LogicalScreen
// Constructors -----------------------------------------------------------
// ------------------------------------------------------------------------
// Constructors -----------------------------------------------------------
// ------------------------------------------------------------------------
+ /**
+ * Static constructor.
+ */
+ static {
+ setDOSColors();
+ }
+
/**
* Public constructor creates a new JFrame to render to.
*
/**
* Public constructor creates a new JFrame to render to.
*
@@
-316,7
+323,6
@@
public class SwingTerminal extends LogicalScreen
this.fontSize = fontSize;
this.fontSize = fontSize;
- setDOSColors();
reloadOptions();
try {
reloadOptions();
try {
@@
-438,7
+444,6
@@
public class SwingTerminal extends LogicalScreen
this.fontSize = fontSize;
this.fontSize = fontSize;
- setDOSColors();
reloadOptions();
try {
reloadOptions();
try {
@@
-715,6
+720,15
@@
public class SwingTerminal extends LogicalScreen
return blinkMillis;
}
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.
*
/**
* Get the font size in points.
*
@@
-882,7
+896,7
@@
public class SwingTerminal extends LogicalScreen
* @param attr the text attributes
* @return the Swing Color
*/
* @param attr the text attributes
* @return the Swing Color
*/
- p
rivate
Color attrToForegroundColor(final CellAttributes attr) {
+ p
ublic static
Color attrToForegroundColor(final CellAttributes attr) {
int rgb = attr.getForeColorRGB();
if (rgb >= 0) {
int red = (rgb >> 16) & 0xFF;
int rgb = attr.getForeColorRGB();
if (rgb >= 0) {
int red = (rgb >> 16) & 0xFF;
@@
-939,7
+953,7
@@
public class SwingTerminal extends LogicalScreen
* @param attr the text attributes
* @return the Swing Color
*/
* @param attr the text attributes
* @return the Swing Color
*/
- p
rivate
Color attrToBackgroundColor(final CellAttributes attr) {
+ p
ublic static
Color attrToBackgroundColor(final CellAttributes attr) {
int rgb = attr.getBackColorRGB();
if (rgb >= 0) {
int red = (rgb >> 16) & 0xFF;
int rgb = attr.getBackColorRGB();
if (rgb >= 0) {
int red = (rgb >> 16) & 0xFF;
@@
-1187,8
+1201,7
@@
public class SwingTerminal extends LogicalScreen
gr2 = (Graphics2D) gr;
}
gr2 = (Graphics2D) gr;
}
- Cell cellColor = new Cell();
- cellColor.setTo(cell);
+ Cell cellColor = new Cell(cell);
// Check for reverse
if (cell.isReverse()) {
// Check for reverse
if (cell.isReverse()) {
@@
-1220,8
+1233,7
@@
public class SwingTerminal extends LogicalScreen
// We need a new key that will not be mutated by
// invertCell().
// 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 {
if (cell.isBlink() && !cursorBlinkVisible) {
glyphCacheBlink.put(key, image);
} else {
@@
-1254,18
+1266,31
@@
public class SwingTerminal extends LogicalScreen
int xPixel = cursorX * textWidth + left;
int yPixel = cursorY * textHeight + top;
Cell lCell = logical[cursorX][cursorY];
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.setColor(attrToForegroundColor(lCell));
switch (cursorStyle) {
default:
// Fall through...
case UNDERLINE:
- gr.fillRect(xPixel, yPixel + textHeight - 2,
text
Width, 2);
+ gr.fillRect(xPixel, yPixel + textHeight - 2,
cursor
Width, 2);
break;
case BLOCK:
break;
case BLOCK:
- gr.fillRect(xPixel, yPixel,
text
Width, textHeight);
+ gr.fillRect(xPixel, yPixel,
cursor
Width, textHeight);
break;
case OUTLINE:
break;
case OUTLINE:
- gr.drawRect(xPixel, yPixel,
text
Width - 1, textHeight - 1);
+ gr.drawRect(xPixel, yPixel,
cursor
Width - 1, textHeight - 1);
break;
}
}
break;
}
}