chars[chars.length - 1] = new Cell(newCell);
}
+ /**
+ * Determine if line contains image data.
+ *
+ * @return true if the line has image data
+ */
+ public boolean isImage() {
+ for (int i = 0; i < chars.length; i++) {
+ if (chars[i].isImage()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Clear image data from line.
+ */
+ public void clearImages() {
+ for (int i = 0; i < chars.length; i++) {
+ if (chars[i].isImage()) {
+ chars[i].reset();
+ }
+ }
+ }
+
}
/**
* The maximum number of lines in the scrollback buffer.
*/
- private int maxScrollback = 10000;
+ private int scrollbackMax = 10000;
/**
* The terminal's input. For type == XTERM, this is an InputStreamReader
display.add(line);
}
while (display.size() > height) {
- scrollback.add(display.remove(0));
+ appendScrollbackLine(display.remove(0));
}
}
+ /**
+ * Get the maximum number of lines in the scrollback buffer.
+ *
+ * @return the maximum number of lines in the scrollback buffer
+ */
+ public int getScrollbackMax() {
+ return scrollbackMax;
+ }
+
+ /**
+ * Set the maximum number of lines for the scrollback buffer.
+ *
+ * @param scrollbackMax the maximum number of lines for the scrollback
+ * buffer
+ */
+ public final void setScrollbackMax(final int scrollbackMax) {
+ this.scrollbackMax = scrollbackMax;
+ }
+
/**
* Get visible cursor flag.
*
toGround();
}
+ /**
+ * Append a to the scrollback buffer, clearing image data for lines more
+ * than three screenfuls in.
+ */
+ private void appendScrollbackLine(DisplayLine line) {
+ scrollback.add(line);
+ if (scrollback.size() > height * 3) {
+ scrollback.get(scrollback.size() - (height * 3)).clearImages();
+ }
+ }
+
/**
* Append a new line to the bottom of the display, adding lines off the
* top to the scrollback buffer.
*/
private void newDisplayLine() {
// Scroll the top line off into the scrollback buffer
- scrollback.add(display.get(0));
- if (scrollback.size() > maxScrollback) {
+ appendScrollbackLine(display.get(0));
+ while (scrollback.size() > scrollbackMax) {
scrollback.remove(0);
scrollback.trimToSize();
}