X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fjexer%2Ftterminal%2FECMA48.java;fp=src%2Fjexer%2Ftterminal%2FECMA48.java;h=5d7eaaa0e1a2afaf646b38d9c18462169eeee645;hp=c6aa0b21e7f981ac5a66d7f65fa49ac7aec2e9f8;hb=564040def0ab28b40a9571aca3622643e28451f4;hpb=12d0abe244f0d80712b99f0ad309ad836d5a4c06 diff --git a/src/jexer/tterminal/ECMA48.java b/src/jexer/tterminal/ECMA48.java index c6aa0b2..5d7eaaa 100644 --- a/src/jexer/tterminal/ECMA48.java +++ b/src/jexer/tterminal/ECMA48.java @@ -274,7 +274,7 @@ public class ECMA48 implements Runnable { /** * 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 @@ -1255,10 +1255,29 @@ public class ECMA48 implements Runnable { 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. * @@ -1452,14 +1471,25 @@ public class ECMA48 implements Runnable { 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(); }