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
first screenshot attempt
[nikiroo-utils.git]
/
src
/
jexer
/
io
/
Screen.java
diff --git
a/src/jexer/io/Screen.java
b/src/jexer/io/Screen.java
index eab9650d14aac19735f732b78036e3fcf7d28d2d..e3f72191809b73565397c98c8b8523c800b9f8be 100644
(file)
--- a/
src/jexer/io/Screen.java
+++ b/
src/jexer/io/Screen.java
@@
-185,6
+185,16
@@
public abstract class Screen {
*/
protected boolean dirty;
*/
protected boolean dirty;
+ /**
+ * Get dirty flag.
+ *
+ * @return if true, the logical screen is not in sync with the physical
+ * screen
+ */
+ public final boolean isDirty() {
+ return dirty;
+ }
+
/**
* Set if the user explicitly wants to redraw everything starting with a
* ECMATerminal.clearAll().
/**
* Set if the user explicitly wants to redraw everything starting with a
* ECMATerminal.clearAll().
@@
-215,8
+225,11
@@
public abstract class Screen {
* @return attributes at (x, y)
*/
public final CellAttributes getAttrXY(final int x, final int y) {
* @return attributes at (x, y)
*/
public final CellAttributes getAttrXY(final int x, final int y) {
+
CellAttributes attr = new CellAttributes();
CellAttributes attr = new CellAttributes();
- attr.setTo(logical[x][y]);
+ if ((x >= 0) && (x < width) && (y >= 0) && (y < height)) {
+ attr.setTo(logical[x][y]);
+ }
return attr;
}
return attr;
}
@@
-241,8
+254,8
@@
public abstract class Screen {
* @param attr attributes to use (bold, foreColor, backColor)
* @param clip if true, honor clipping/offset
*/
* @param attr attributes to use (bold, foreColor, backColor)
* @param clip if true, honor clipping/offset
*/
- public final void putAttrXY(final int x, final int y
,
- final CellAttributes attr, final boolean clip) {
+ public final void putAttrXY(final int x, final int y
+
,
final CellAttributes attr, final boolean clip) {
int X = x;
int Y = y;
int X = x;
int Y = y;
@@
-278,6
+291,7
@@
public abstract class Screen {
* @param attr attributes to use (bold, foreColor, backColor)
*/
public final void putAll(final char ch, final CellAttributes attr) {
* @param attr attributes to use (bold, foreColor, backColor)
*/
public final void putAll(final char ch, final CellAttributes attr) {
+
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
putCharXY(x, y, ch, attr);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
putCharXY(x, y, ch, attr);
@@
-346,6
+360,7
@@
public abstract class Screen {
* @param ch character to draw
*/
public final void putCharXY(final int x, final int y, final char ch) {
* @param ch character to draw
*/
public final void putCharXY(final int x, final int y, final char ch) {
+
if ((x < clipLeft)
|| (x >= clipRight)
|| (y < clipTop)
if ((x < clipLeft)
|| (x >= clipRight)
|| (y < clipTop)
@@
-396,6
+411,7
@@
public abstract class Screen {
* @param str string to draw
*/
public final void putStrXY(final int x, final int y, final String str) {
* @param str string to draw
*/
public final void putStrXY(final int x, final int y, final String str) {
+
int i = x;
for (int j = 0; j < str.length(); j++) {
char ch = str.charAt(j);
int i = x;
for (int j = 0; j < str.length(); j++) {
char ch = str.charAt(j);
@@
-447,7
+463,7
@@
public abstract class Screen {
* @param width new width
* @param height new height
*/
* @param width new width
* @param height new height
*/
- private void reallocate(final int width, final int height) {
+ private
synchronized
void reallocate(final int width, final int height) {
if (logical != null) {
for (int row = 0; row < this.height; row++) {
for (int col = 0; col < this.width; col++) {
if (logical != null) {
for (int row = 0; row < this.height; row++) {
for (int col = 0; col < this.width; col++) {
@@
-492,7
+508,7
@@
public abstract class Screen {
*
* @param width new screen width
*/
*
* @param width new screen width
*/
- public final void setWidth(final int width) {
+ public final
synchronized
void setWidth(final int width) {
reallocate(width, this.height);
}
reallocate(width, this.height);
}
@@
-502,7
+518,7
@@
public abstract class Screen {
*
* @param height new screen height
*/
*
* @param height new screen height
*/
- public final void setHeight(final int height) {
+ public final
synchronized
void setHeight(final int height) {
reallocate(this.width, height);
}
reallocate(this.width, height);
}
@@
-522,7
+538,7
@@
public abstract class Screen {
*
* @return current screen height
*/
*
* @return current screen height
*/
- public final int getHeight() {
+ public final
synchronized
int getHeight() {
return this.height;
}
return this.height;
}
@@
-531,7
+547,7
@@
public abstract class Screen {
*
* @return current screen width
*/
*
* @return current screen width
*/
- public final int getWidth() {
+ public final
synchronized
int getWidth() {
return this.width;
}
return this.width;
}
@@
-552,7
+568,7
@@
public abstract class Screen {
* Reset screen to not-bold, white-on-black. Also flushes the offset and
* clip variables.
*/
* Reset screen to not-bold, white-on-black. Also flushes the offset and
* clip variables.
*/
- public final void reset() {
+ public final
synchronized
void reset() {
dirty = true;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
dirty = true;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
@@
-727,7
+743,7
@@
public abstract class Screen {
* Subclasses must provide an implementation to push the logical screen
* to the physical device.
*/
* Subclasses must provide an implementation to push the logical screen
* to the physical device.
*/
-
abstract public
void flushPhysical();
+
public abstract
void flushPhysical();
/**
* Put the cursor at (x,y).
/**
* Put the cursor at (x,y).
@@
-736,8
+752,7
@@
public abstract class Screen {
* @param x column coordinate to put the cursor on
* @param y row coordinate to put the cursor on
*/
* @param x column coordinate to put the cursor on
* @param y row coordinate to put the cursor on
*/
- public final void putCursor(final boolean visible,
- final int x, final int y) {
+ public void putCursor(final boolean visible, final int x, final int y) {
cursorVisible = visible;
cursorX = x;
cursorVisible = visible;
cursorX = x;