Skip to content

Commit ac18d03

Browse files
committed
feat: added clear() to Screen
1 parent e6b564c commit ac18d03

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/org/codejive/context/terminal/Screen.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
public interface Screen extends Rectangular {
1212
void printAt(int x, int y, AttributedString str);
1313

14+
void clear();
15+
1416
void update();
1517
}
1618

1719
class ScreenImpl implements Screen {
1820
private final Rect rect;
1921
private final Display display;
20-
private final AttributedStringBuilder[] lines;
22+
private AttributedStringBuilder[] lines;
2123

2224
@Override
2325
public Rect rect() {
@@ -28,6 +30,13 @@ protected ScreenImpl(Term term, int width, int height) {
2830
this.rect = new Rect(0, 0, width, height);
2931
this.display = new Display(term.terminal, false);
3032
this.display.resize(height, width);
33+
clear();
34+
}
35+
36+
@Override
37+
public void clear() {
38+
int width = rect().width();
39+
int height = rect().height();
3140
this.lines = new AttributedStringBuilder[height];
3241
for (int i = 0; i < height; i++) {
3342
this.lines[i] = new AttributedStringBuilder(width);

0 commit comments

Comments
 (0)