public void assertPainted(String s1, String s2) throws Exception { TestBuffer tmp = new TestBuffer(2, 2); VirtualScreen buffer = new VirtualScreen(tmp); buffer.append(s1); assertTrue(buffer.isRefresh()); assertTrue(buffer.paint().isPainting()); buffer.append(s2); assertTrue(buffer.isPainting()); assertTrue(buffer.paint().isPainted()); } }
} else { if (isPainted()) { int count = 0; int _offset = cursorOffset; int _index = cursorIndex; while (count < amount) { Pair<Integer, Integer> next = nextRow(_offset, _index, width); if (next != null) { _offset = next.getFirst(); } else { if (nextRow(_offset, _index, 1) != null) { count++; _index = index; for (int i = 0;i < count;i++) { Pair<Integer, Integer> next = nextRow(_offset, _index, width); _offset = next.getFirst(); _index = next.getSecond();
public synchronized boolean nextRow() throws IOException { return scroll(1) == 1; }
public void testNextRow0() throws Exception { TestBuffer tmp = new TestBuffer(2, 2); VirtualScreen buffer = new VirtualScreen(tmp); assertTrue(buffer.isRefresh()); assertTrue(buffer.paint().isPainting()); assertFalse(buffer.nextRow()); assertTrue(buffer.isPainting()); }
@Override public Screenable append(CharSequence csq, int start, int end) throws IOException { return append(csq.subSequence(start, end)); }
public synchronized boolean previousRow() throws IOException { // Current strategy is to increment updates, a bit dumb, but fast (in memory) and works // correctly if (row > 0) { int previousOffset = 0; int previousIndex = 0; int previousRow = 0; while (previousRow < row - 1) { Pair<Integer, Integer> next = nextRow(previousOffset, previousIndex, width); if (next != null) { previousOffset = next.getFirst(); previousIndex = next.getSecond(); previousRow++; } else { break; } } status = REFRESH; cursorX = cursorY = 0; cursorOffset = offset = previousOffset; cursorIndex = index = previousIndex; row = previousRow; return true; } else { return false; } }
public void testRefresh() throws Exception { TestBuffer tmp = new TestBuffer(2, 2); VirtualScreen buffer = new VirtualScreen(tmp); tmp.width = 3; assertFalse(buffer.update()); }
@Override public Screenable append(char c) throws IOException { return append(Character.toString(c)); }
public synchronized boolean previousRow() throws IOException { // Current strategy is to increment updates, a bit dumb, but fast (in memory) and works // correctly if (row > 0) { int previousOffset = 0; int previousIndex = 0; int previousRow = 0; while (previousRow < row - 1) { Pair<Integer, Integer> next = nextRow(previousOffset, previousIndex, width); if (next != null) { previousOffset = next.getFirst(); previousIndex = next.getSecond(); previousRow++; } else { break; } } status = REFRESH; cursorX = cursorY = 0; cursorOffset = offset = previousOffset; cursorIndex = index = previousIndex; row = previousRow; return true; } else { return false; } }
} else { if (isPainted()) { int count = 0; int _offset = cursorOffset; int _index = cursorIndex; while (count < amount) { Pair<Integer, Integer> next = nextRow(_offset, _index, width); if (next != null) { _offset = next.getFirst(); } else { if (nextRow(_offset, _index, 1) != null) { count++; _index = index; for (int i = 0;i < count;i++) { Pair<Integer, Integer> next = nextRow(_offset, _index, width); _offset = next.getFirst(); _index = next.getSecond();
@Override public Screenable append(CharSequence csq, int start, int end) throws IOException { return append(csq.subSequence(start, end)); }
public synchronized boolean previousRow() throws IOException { // Current strategy is to increment updates, a bit dumb, but fast (in memory) and works // correctly if (row > 0) { int previousOffset = 0; int previousIndex = 0; int previousRow = 0; while (previousRow < row - 1) { Pair<Integer, Integer> next = nextRow(previousOffset, previousIndex, width); if (next != null) { previousOffset = next.getFirst(); previousIndex = next.getSecond(); previousRow++; } else { break; } } status = REFRESH; cursorX = cursorY = 0; cursorOffset = offset = previousOffset; cursorIndex = index = previousIndex; row = previousRow; return true; } else { return false; } }
public synchronized int nextPage() throws IOException { return scroll(height); }
private void assertBuffer(int width, int height, String actual, String... test) throws IOException { TestBuffer tmp = new TestBuffer(width, height); VirtualScreen buffer = new VirtualScreen(tmp); for (String a : test) { buffer.append(a); buffer.paint(); assertTrue(buffer.isPainting() || buffer.isPainted()); } assertEquals(actual, tmp.toString()); }
} else { if (isPainted()) { int count = 0; int _offset = cursorOffset; int _index = cursorIndex; while (count < amount) { Pair<Integer, Integer> next = nextRow(_offset, _index, width); if (next != null) { _offset = next.getFirst(); } else { if (nextRow(_offset, _index, 1) != null) { count++; _index = index; for (int i = 0;i < count;i++) { Pair<Integer, Integer> next = nextRow(_offset, _index, width); _offset = next.getFirst(); _index = next.getSecond();
@Override public Screenable append(char c) throws IOException { return append(Character.toString(c)); }
public synchronized int nextPage() throws IOException { return scroll(height); }
public void testNextRow2() throws Exception { TestBuffer tmp = new TestBuffer(2, 2); VirtualScreen buffer = new VirtualScreen(tmp); buffer.append("abcde"); assertTrue(buffer.isRefresh()); assertTrue(buffer.paint().isPainted()); assertTrue(buffer.nextRow()); assertTrue(buffer.isRefresh()); assertTrue(buffer.paint().isPainting()); assertFalse(buffer.nextRow()); assertTrue(buffer.isPainting()); buffer.append("fg"); assertTrue(buffer.isPainting()); assertTrue(buffer.paint().isPainted()); assertTrue(buffer.nextRow()); assertTrue(buffer.isRefresh()); assertTrue(buffer.paint().isPainting()); }
@Override public Screenable append(CharSequence csq, int start, int end) throws IOException { return append(csq.subSequence(start, end)); }