git://git.nikiroo.be
/
fanfix.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d14e2d7
)
#49 cell attributes to int
author
Kevin Lamonte
<kevin.lamonte@gmail.com>
Thu, 8 Aug 2019 09:53:21 +0000
(
04:53
-0500)
committer
Kevin Lamonte
<kevin.lamonte@gmail.com>
Thu, 8 Aug 2019 09:53:21 +0000
(
04:53
-0500)
src/jexer/TTerminalWindow.java
patch
|
blob
|
blame
|
history
src/jexer/backend/GlyphMaker.java
patch
|
blob
|
blame
|
history
src/jexer/backend/LogicalScreen.java
patch
|
blob
|
blame
|
history
src/jexer/backend/SwingTerminal.java
patch
|
blob
|
blame
|
history
src/jexer/bits/Cell.java
patch
|
blob
|
blame
|
history
src/jexer/bits/CellAttributes.java
patch
|
blob
|
blame
|
history
src/jexer/tterminal/DisplayLine.java
patch
|
blob
|
blame
|
history
src/jexer/tterminal/ECMA48.java
patch
|
blob
|
blame
|
history
diff --git
a/src/jexer/TTerminalWindow.java
b/src/jexer/TTerminalWindow.java
index 5970b6c77aff4791a389d13a7aa9a1012dbf5147..4e0123fd7aa383a8d1aeaf4b5e693cb52d10d39d 100644
(file)
--- a/
src/jexer/TTerminalWindow.java
+++ b/
src/jexer/TTerminalWindow.java
@@
-326,10
+326,9
@@
public class TTerminalWindow extends TScrollableWindow
*/
@Override
public void draw() {
*/
@Override
public void draw() {
-
int width = getDisplayWidth();
boolean syncEmulator = false;
int width = getDisplayWidth();
boolean syncEmulator = false;
- if ((System.currentTimeMillis() - lastUpdateTime >
1
25)
+ if ((System.currentTimeMillis() - lastUpdateTime >
=
25)
&& (dirty == true)
) {
// Too much time has passed, draw it all.
&& (dirty == true)
) {
// Too much time has passed, draw it all.
@@
-410,8
+409,7
@@
public class TTerminalWindow extends TScrollableWindow
continue;
}
continue;
}
- Cell newCell = new Cell();
- newCell.setTo(ch);
+ Cell newCell = new Cell(ch);
boolean reverse = line.isReverseColor() ^ ch.isReverse();
newCell.setReverse(false);
if (reverse) {
boolean reverse = line.isReverseColor() ^ ch.isReverse();
newCell.setReverse(false);
if (reverse) {
@@
-985,8
+983,7
@@
public class TTerminalWindow extends TScrollableWindow
BufferedImage image;
if (line.getDoubleHeight() == 1) {
// Double-height top half: don't draw the underline.
BufferedImage image;
if (line.getDoubleHeight() == 1) {
// Double-height top half: don't draw the underline.
- Cell newCell = new Cell();
- newCell.setTo(cell);
+ Cell newCell = new Cell(cell);
newCell.setUnderline(false);
image = doubleFont.getImage(newCell, textWidth * 2, textHeight * 2,
cursorBlinkVisible);
newCell.setUnderline(false);
image = doubleFont.getImage(newCell, textWidth * 2, textHeight * 2,
cursorBlinkVisible);
@@
-997,10
+994,8
@@
public class TTerminalWindow extends TScrollableWindow
// Now that we have the double-wide glyph drawn, copy the right
// pieces of it to the cells.
// Now that we have the double-wide glyph drawn, copy the right
// pieces of it to the cells.
- Cell left = new Cell();
- Cell right = new Cell();
- left.setTo(cell);
- right.setTo(cell);
+ Cell left = new Cell(cell);
+ Cell right = new Cell(cell);
right.setChar(' ');
BufferedImage leftImage = null;
BufferedImage rightImage = null;
right.setChar(' ');
BufferedImage leftImage = null;
BufferedImage rightImage = null;
diff --git
a/src/jexer/backend/GlyphMaker.java
b/src/jexer/backend/GlyphMaker.java
index 0c798b1d7e1fdd48eb7d0df0b2f10f45326c5231..08cbee8ca10a91d48900e182d6b1fd25d9946c39 100644
(file)
--- a/
src/jexer/backend/GlyphMaker.java
+++ b/
src/jexer/backend/GlyphMaker.java
@@
-201,8
+201,7
@@
class GlyphMakerFont {
Graphics2D gr2 = image.createGraphics();
gr2.setFont(font);
Graphics2D gr2 = image.createGraphics();
gr2.setFont(font);
- Cell cellColor = new Cell();
- cellColor.setTo(cell);
+ Cell cellColor = new Cell(cell);
// Check for reverse
if (cell.isReverse()) {
// Check for reverse
if (cell.isReverse()) {
@@
-231,8
+230,7
@@
class GlyphMakerFont {
gr2.dispose();
// We need a new key that will not be mutated by invertCell().
gr2.dispose();
// 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() && !blinkVisible) {
glyphCacheBlink.put(key, image);
} else {
if (cell.isBlink() && !blinkVisible) {
glyphCacheBlink.put(key, image);
} else {
diff --git
a/src/jexer/backend/LogicalScreen.java
b/src/jexer/backend/LogicalScreen.java
index 9af633dbac645be3198a27935590d6145143b9cc..e8d2662943abd06d579fe86ff082c7fc482a900d 100644
(file)
--- a/
src/jexer/backend/LogicalScreen.java
+++ b/
src/jexer/backend/LogicalScreen.java
@@
-978,16
+978,14
@@
public class LogicalScreen implements Screen {
BufferedImage rightImage = image.getSubimage(getTextWidth(), 0,
getTextWidth(), getTextHeight());
BufferedImage rightImage = image.getSubimage(getTextWidth(), 0,
getTextWidth(), getTextHeight());
- Cell left = new Cell();
- left.setTo(cell);
+ Cell left = new Cell(cell);
left.setImage(leftImage);
left.setWidth(Cell.Width.LEFT);
// Blank out the char itself, so that shadows do not leave artifacts.
left.setChar(' ');
putCharXY(x, y, left);
left.setImage(leftImage);
left.setWidth(Cell.Width.LEFT);
// Blank out the char itself, so that shadows do not leave artifacts.
left.setChar(' ');
putCharXY(x, y, left);
- Cell right = new Cell();
- right.setTo(cell);
+ Cell right = new Cell(cell);
right.setImage(rightImage);
right.setWidth(Cell.Width.RIGHT);
// Blank out the char itself, so that shadows do not leave artifacts.
right.setImage(rightImage);
right.setWidth(Cell.Width.RIGHT);
// Blank out the char itself, so that shadows do not leave artifacts.
@@
-1006,8
+1004,7
@@
public class LogicalScreen implements Screen {
public final void putFullwidthCharXY(final int x, final int y,
final char ch, final CellAttributes attr) {
public final void putFullwidthCharXY(final int x, final int y,
final char ch, final CellAttributes attr) {
- Cell cell = new Cell(ch);
- cell.setAttr(attr);
+ Cell cell = new Cell(ch, attr);
putFullwidthCharXY(x, y, cell);
}
putFullwidthCharXY(x, y, cell);
}
diff --git
a/src/jexer/backend/SwingTerminal.java
b/src/jexer/backend/SwingTerminal.java
index 4cd6d07624010ae8facb31969042f118d59ce44b..58b8f799cf7f1e1153f2ef60f2af486ba96d03da 100644
(file)
--- a/
src/jexer/backend/SwingTerminal.java
+++ b/
src/jexer/backend/SwingTerminal.java
@@
-572,7
+572,6
@@
public class SwingTerminal extends LogicalScreen
&& (swing.getBufferStrategy() != null)
) {
do {
&& (swing.getBufferStrategy() != null)
) {
do {
- clearPhysical();
do {
drawToSwing();
} while (swing.getBufferStrategy().contentsRestored());
do {
drawToSwing();
} while (swing.getBufferStrategy().contentsRestored());
@@
-1201,8
+1200,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()) {
@@
-1234,8
+1232,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 {
diff --git
a/src/jexer/bits/Cell.java
b/src/jexer/bits/Cell.java
index 4be433c7d33d8d05201fd6d3b869ff37e06cfa54..c949c3e36c147efb830f019f988225df966974cf 100644
(file)
--- a/
src/jexer/bits/Cell.java
+++ b/
src/jexer/bits/Cell.java
@@
-73,7
+73,7
@@
public final class Cell extends CellAttributes {
/**
* The character at this cell.
*/
/**
* The character at this cell.
*/
- private char ch;
+ private char ch
= ' '
;
/**
* The display width of this cell.
/**
* The display width of this cell.
@@
-94,7
+94,7
@@
public final class Cell extends CellAttributes {
* The background color used for the area the image portion might not
* cover.
*/
* The background color used for the area the image portion might not
* cover.
*/
- private Color background =
null
;
+ private Color background =
Color.BLACK
;
/**
* hashCode() needs to call image.hashCode(), which can get quite
/**
* hashCode() needs to call image.hashCode(), which can get quite
@@
-119,7
+119,7
@@
public final class Cell extends CellAttributes {
* @see #reset()
*/
public Cell() {
* @see #reset()
*/
public Cell() {
- reset();
+ // NOP
}
/**
}
/**
@@
-130,7
+130,17
@@
public final class Cell extends CellAttributes {
* @see #reset()
*/
public Cell(final char ch) {
* @see #reset()
*/
public Cell(final char ch) {
- reset();
+ this.ch = ch;
+ }
+
+ /**
+ * Public constructor sets the character and attributes.
+ *
+ * @param ch character to set to
+ * @param attr attributes to use
+ */
+ public Cell(final char ch, final CellAttributes attr) {
+ super(attr);
this.ch = ch;
}
this.ch = ch;
}
diff --git
a/src/jexer/bits/CellAttributes.java
b/src/jexer/bits/CellAttributes.java
index f60fd3097f856ed6e70a098c018cfccbf1a5d2b8..99366fda690740b738563493fef900a506436d7d 100644
(file)
--- a/
src/jexer/bits/CellAttributes.java
+++ b/
src/jexer/bits/CellAttributes.java
@@
-34,43
+34,53
@@
package jexer.bits;
public class CellAttributes {
// ------------------------------------------------------------------------
public class CellAttributes {
// ------------------------------------------------------------------------
- //
Variable
s --------------------------------------------------------------
+ //
Constant
s --------------------------------------------------------------
// ------------------------------------------------------------------------
/**
* Bold attribute.
*/
// ------------------------------------------------------------------------
/**
* Bold attribute.
*/
- private
boolean bold
;
+ private
static final int BOLD = 0x01
;
/**
* Blink attribute.
*/
/**
* Blink attribute.
*/
- private
boolean blink
;
+ private
static final int BLINK = 0x02
;
/**
* Reverse attribute.
*/
/**
* Reverse attribute.
*/
- private
boolean reverse
;
+ private
static final int REVERSE = 0x04
;
/**
* Underline attribute.
*/
/**
* Underline attribute.
*/
- private
boolean underline
;
+ private
static final int UNDERLINE = 0x08
;
/**
* Protected attribute.
*/
/**
* Protected attribute.
*/
- private boolean protect;
+ private static final int PROTECT = 0x10;
+
+
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Boolean flags.
+ */
+ private int flags = 0;
/**
* Foreground color. Color.WHITE, Color.RED, etc.
*/
/**
* Foreground color. Color.WHITE, Color.RED, etc.
*/
- private Color foreColor;
+ private Color foreColor
= Color.WHITE
;
/**
* Background color. Color.WHITE, Color.RED, etc.
*/
/**
* Background color. Color.WHITE, Color.RED, etc.
*/
- private Color backColor;
+ private Color backColor
= Color.BLACK
;
/**
* Foreground color as 24-bit RGB value. Negative value means not set.
/**
* Foreground color as 24-bit RGB value. Negative value means not set.
@@
-93,7
+103,7
@@
public class CellAttributes {
* @see #reset()
*/
public CellAttributes() {
* @see #reset()
*/
public CellAttributes() {
- reset();
+ // NOP
}
/**
}
/**
@@
-116,7
+126,7
@@
public class CellAttributes {
* @return bold value
*/
public final boolean isBold() {
* @return bold value
*/
public final boolean isBold() {
- return
bold
;
+ return
((flags & BOLD) == 0 ? false : true)
;
}
/**
}
/**
@@
-125,7
+135,11
@@
public class CellAttributes {
* @param bold new bold value
*/
public final void setBold(final boolean bold) {
* @param bold new bold value
*/
public final void setBold(final boolean bold) {
- this.bold = bold;
+ if (bold) {
+ flags |= BOLD;
+ } else {
+ flags &= ~BOLD;
+ }
}
/**
}
/**
@@
-134,7
+148,7
@@
public class CellAttributes {
* @return blink value
*/
public final boolean isBlink() {
* @return blink value
*/
public final boolean isBlink() {
- return
blink
;
+ return
((flags & BLINK) == 0 ? false : true)
;
}
/**
}
/**
@@
-143,7
+157,11
@@
public class CellAttributes {
* @param blink new blink value
*/
public final void setBlink(final boolean blink) {
* @param blink new blink value
*/
public final void setBlink(final boolean blink) {
- this.blink = blink;
+ if (blink) {
+ flags |= BLINK;
+ } else {
+ flags &= ~BLINK;
+ }
}
/**
}
/**
@@
-152,7
+170,7
@@
public class CellAttributes {
* @return reverse value
*/
public final boolean isReverse() {
* @return reverse value
*/
public final boolean isReverse() {
- return
reverse
;
+ return
((flags & REVERSE) == 0 ? false : true)
;
}
/**
}
/**
@@
-161,7
+179,11
@@
public class CellAttributes {
* @param reverse new reverse value
*/
public final void setReverse(final boolean reverse) {
* @param reverse new reverse value
*/
public final void setReverse(final boolean reverse) {
- this.reverse = reverse;
+ if (reverse) {
+ flags |= REVERSE;
+ } else {
+ flags &= ~REVERSE;
+ }
}
/**
}
/**
@@
-170,7
+192,7
@@
public class CellAttributes {
* @return underline value
*/
public final boolean isUnderline() {
* @return underline value
*/
public final boolean isUnderline() {
- return
underline
;
+ return
((flags & UNDERLINE) == 0 ? false : true)
;
}
/**
}
/**
@@
-179,7
+201,11
@@
public class CellAttributes {
* @param underline new underline value
*/
public final void setUnderline(final boolean underline) {
* @param underline new underline value
*/
public final void setUnderline(final boolean underline) {
- this.underline = underline;
+ if (underline) {
+ flags |= UNDERLINE;
+ } else {
+ flags &= ~UNDERLINE;
+ }
}
/**
}
/**
@@
-188,7
+214,7
@@
public class CellAttributes {
* @return protect value
*/
public final boolean isProtect() {
* @return protect value
*/
public final boolean isProtect() {
- return
protect
;
+ return
((flags & PROTECT) == 0 ? false : true)
;
}
/**
}
/**
@@
-197,7
+223,11
@@
public class CellAttributes {
* @param protect new protect value
*/
public final void setProtect(final boolean protect) {
* @param protect new protect value
*/
public final void setProtect(final boolean protect) {
- this.protect = protect;
+ if (protect) {
+ flags |= PROTECT;
+ } else {
+ flags &= ~PROTECT;
+ }
}
/**
}
/**
@@
-286,11
+316,7
@@
public class CellAttributes {
* bold/underline/blink/rever/protect.
*/
public void reset() {
* bold/underline/blink/rever/protect.
*/
public void reset() {
- bold = false;
- blink = false;
- reverse = false;
- underline = false;
- protect = false;
+ flags = 0;
foreColor = Color.WHITE;
backColor = Color.BLACK;
foreColorRGB = -1;
foreColor = Color.WHITE;
backColor = Color.BLACK;
foreColorRGB = -1;
@@
-310,15
+336,11
@@
public class CellAttributes {
}
CellAttributes that = (CellAttributes) rhs;
}
CellAttributes that = (CellAttributes) rhs;
- return ((foreColor == that.foreColor)
+ return ((flags == that.flags)
+ && (foreColor == that.foreColor)
&& (backColor == that.backColor)
&& (foreColorRGB == that.foreColorRGB)
&& (backColor == that.backColor)
&& (foreColorRGB == that.foreColorRGB)
- && (backColorRGB == that.backColorRGB)
- && (bold == that.bold)
- && (reverse == that.reverse)
- && (underline == that.underline)
- && (blink == that.blink)
- && (protect == that.protect));
+ && (backColorRGB == that.backColorRGB));
}
/**
}
/**
@@
-331,11
+353,7
@@
public class CellAttributes {
int A = 13;
int B = 23;
int hash = A;
int A = 13;
int B = 23;
int hash = A;
- hash = (B * hash) + (bold ? 1 : 0);
- hash = (B * hash) + (blink ? 1 : 0);
- hash = (B * hash) + (underline ? 1 : 0);
- hash = (B * hash) + (reverse ? 1 : 0);
- hash = (B * hash) + (protect ? 1 : 0);
+ hash = (B * hash) + flags;
hash = (B * hash) + foreColor.hashCode();
hash = (B * hash) + backColor.hashCode();
hash = (B * hash) + foreColorRGB;
hash = (B * hash) + foreColor.hashCode();
hash = (B * hash) + backColor.hashCode();
hash = (B * hash) + foreColorRGB;
@@
-351,11
+369,7
@@
public class CellAttributes {
public void setTo(final Object rhs) {
CellAttributes that = (CellAttributes) rhs;
public void setTo(final Object rhs) {
CellAttributes that = (CellAttributes) rhs;
- this.bold = that.bold;
- this.blink = that.blink;
- this.reverse = that.reverse;
- this.underline = that.underline;
- this.protect = that.protect;
+ this.flags = that.flags;
this.foreColor = that.foreColor;
this.backColor = that.backColor;
this.foreColorRGB = that.foreColorRGB;
this.foreColor = that.foreColor;
this.backColor = that.backColor;
this.foreColorRGB = that.foreColorRGB;
@@
-374,8
+388,8
@@
public class CellAttributes {
(foreColorRGB & 0xFFFFFF),
(backColorRGB & 0xFFFFFF));
}
(foreColorRGB & 0xFFFFFF),
(backColorRGB & 0xFFFFFF));
}
- return String.format("%s%s%s on %s", (
bold == true
? "bold " : ""),
- (
blink == true
? "blink " : ""), foreColor, backColor);
+ return String.format("%s%s%s on %s", (
isBold()
? "bold " : ""),
+ (
isBlink()
? "blink " : ""), foreColor, backColor);
}
}
}
}
diff --git
a/src/jexer/tterminal/DisplayLine.java
b/src/jexer/tterminal/DisplayLine.java
index 74e63a85960e840e911c5999b44e21d1ede2799b..a32da9b4d603b7dd96d26807f6745c89d2549624 100644
(file)
--- a/
src/jexer/tterminal/DisplayLine.java
+++ b/
src/jexer/tterminal/DisplayLine.java
@@
-103,8
+103,7
@@
public class DisplayLine {
public DisplayLine(final CellAttributes attr) {
chars = new Cell[MAX_LINE_LENGTH];
for (int i = 0; i < chars.length; i++) {
public DisplayLine(final CellAttributes attr) {
chars = new Cell[MAX_LINE_LENGTH];
for (int i = 0; i < chars.length; i++) {
- chars[i] = new Cell();
- chars[i].setTo(attr);
+ chars[i] = new Cell(attr);
}
}
}
}
@@
-193,8
+192,7
@@
public class DisplayLine {
*/
public void insert(final int idx, final Cell newCell) {
System.arraycopy(chars, idx, chars, idx + 1, chars.length - idx - 1);
*/
public void insert(final int idx, final Cell newCell) {
System.arraycopy(chars, idx, chars, idx + 1, chars.length - idx - 1);
- chars[idx] = new Cell();
- chars[idx].setTo(newCell);
+ chars[idx] = new Cell(newCell);
}
/**
}
/**
@@
-247,8
+245,7
@@
public class DisplayLine {
*/
public void delete(final int idx, final Cell newCell) {
System.arraycopy(chars, idx + 1, chars, idx, chars.length - idx - 1);
*/
public void delete(final int idx, final Cell newCell) {
System.arraycopy(chars, idx + 1, chars, idx, chars.length - idx - 1);
- chars[chars.length - 1] = new Cell();
- chars[chars.length - 1].setTo(newCell);
+ chars[chars.length - 1] = new Cell(newCell);
}
}
}
}
diff --git
a/src/jexer/tterminal/ECMA48.java
b/src/jexer/tterminal/ECMA48.java
index 80f0ffbefa12133d270add78fc1a04ae85153412..b33c785d988766c5f000877ea0a6be50969f799c 100644
(file)
--- a/
src/jexer/tterminal/ECMA48.java
+++ b/
src/jexer/tterminal/ECMA48.java
@@
-690,9
+690,9
@@
public class ECMA48 implements Runnable {
char [] readBufferUTF8 = null;
byte [] readBuffer = null;
if (utf8) {
char [] readBufferUTF8 = null;
byte [] readBuffer = null;
if (utf8) {
- readBufferUTF8 = new char[
12
8];
+ readBufferUTF8 = new char[
204
8];
} else {
} else {
- readBuffer = new byte[
12
8];
+ readBuffer = new byte[
204
8];
}
while (!done && !stopReaderThread) {
}
while (!done && !stopReaderThread) {
@@
-3458,8
+3458,7
@@
public class ECMA48 implements Runnable {
* DECALN - Screen alignment display.
*/
private void decaln() {
* DECALN - Screen alignment display.
*/
private void decaln() {
- Cell newCell = new Cell();
- newCell.setChar('E');
+ Cell newCell = new Cell('E');
for (DisplayLine line: display) {
for (int i = 0; i < line.length(); i++) {
line.replace(i, newCell);
for (DisplayLine line: display) {
for (int i = 0; i < line.length(); i++) {
line.replace(i, newCell);
@@
-6909,8
+6908,7
@@
public class ECMA48 implements Runnable {
lastTextHeight = textHeight;
}
lastTextHeight = textHeight;
}
- Cell cell = new Cell(ch);
- cell.setAttr(currentState.attr);
+ Cell cell = new Cell(ch, currentState.attr);
BufferedImage image = glyphMaker.getImage(cell, textWidth * 2,
textHeight);
BufferedImage leftImage = image.getSubimage(0, 0, textWidth,
BufferedImage image = glyphMaker.getImage(cell, textWidth * 2,
textHeight);
BufferedImage leftImage = image.getSubimage(0, 0, textWidth,
@@
-6918,14
+6916,12
@@
public class ECMA48 implements Runnable {
BufferedImage rightImage = image.getSubimage(textWidth, 0, textWidth,
textHeight);
BufferedImage rightImage = image.getSubimage(textWidth, 0, textWidth,
textHeight);
- Cell left = new Cell();
- left.setTo(cell);
+ Cell left = new Cell(cell);
left.setImage(leftImage);
left.setWidth(Cell.Width.LEFT);
display.get(leftY).replace(leftX, left);
left.setImage(leftImage);
left.setWidth(Cell.Width.LEFT);
display.get(leftY).replace(leftX, left);
- Cell right = new Cell();
- right.setTo(cell);
+ Cell right = new Cell(cell);
right.setImage(rightImage);
right.setWidth(Cell.Width.RIGHT);
display.get(rightY).replace(rightX, right);
right.setImage(rightImage);
right.setWidth(Cell.Width.RIGHT);
display.get(rightY).replace(rightX, right);