Buffer { public void replace(Consumer<int[]> out, String line, int width) { replace(out, Parser.toCodePoints(line), width); } Buffer();   Buffer(Prompt prompt);  Buffer(Buffer buf); CursorLocator getCursorLocator(); int get(int pos); int cursor(); int multiCursor(); boolean isMasking(); boolean isMultiLine(); String asString(); void reset(); void setIsPromptDisplayed(boolean isPromptDisplayed); void forceSetDeltaChangedAtEndOfBuffer(boolean delta); void disablePrompt(boolean disable); boolean isPromptDisabled(); Prompt prompt(); int length(); void setMultiLine(boolean multi); void invalidateCursorLocation(); void updateMultiLineBuffer(); void insert(Consumer<int[]> out, int[] data, int width); void insert(Consumer<int[]> out, int data, int width); void move(Consumer<int[]> out,  int move, int termWidth); void move(Consumer<int[]> out, int move, int termWidth, boolean viMode); static int[] moveNumberOfColumns(int column, char direction); int[] getLineMasked(); void clear(); void replace(Consumer<int[]> out, String line, int width); void replace(Consumer<int[]> out, int[] line, int width); int[] multiLine(); void delete(Consumer<int[]> out, int delta, int width); void delete(Consumer<int[]> out, int delta, int width, boolean viMode); void insert(Consumer<int[]> out, final String str, int width); void replace(Consumer<int[]> out, char rChar);  }
@Test public void replace() { Buffer buffer = new Buffer(new Prompt(": ")); List<int[]> outConsumer = new ArrayList<>(); buffer.insert(outConsumer::add, "foo bar", 100); outConsumer.clear(); buffer.replace(outConsumer::add, " gar", 120); assertEquals(" gar", Parser.fromCodePoints(Arrays.copyOfRange(outConsumer.get(0), outConsumer.get(0).length-4, outConsumer.get(0).length ))); outConsumer.clear(); buffer.insert(outConsumer::add, 'd', 100); assertEquals(" gard", buffer.asString()); assertEquals("d", Parser.fromCodePoints((outConsumer.get(0)))); }