@Test public void testSetText() throws Exception { EditorState viewState = setTextAndGet("test"); Assert.assertEquals("test", viewState.getTextString()); Assert.assertEquals(4, viewState.selection); viewState = setTextAndGet("testtest"); Assert.assertEquals("testtest", viewState.getTextString()); Assert.assertEquals(8, viewState.selection); viewState = setTextAndGet(""); Assert.assertEquals("", viewState.getTextString()); Assert.assertEquals(0, viewState.selection); viewState = setTextAndGet("testtest", 0); Assert.assertEquals("testtest", viewState.getTextString()); Assert.assertEquals(0, viewState.selection); viewState = setTextAndGet("testtest", 2); Assert.assertEquals("testtest", viewState.getTextString()); Assert.assertEquals(2, viewState.selection); viewState = setTextAndGet("", 0); Assert.assertEquals("", viewState.getTextString()); Assert.assertEquals(0, viewState.selection); viewState = setTextAndGet("", 3); Assert.assertEquals("", viewState.getTextString()); Assert.assertEquals(0, viewState.selection); viewState = setTextAndGet("", -3); Assert.assertEquals("", viewState.getTextString()); Assert.assertEquals(0, viewState.selection); viewState = setTextAndGet("test"); Assert.assertEquals("test", viewState.getTextString()); Assert.assertEquals(4, viewState.selection); viewState = setTextAndGet("", 2); Assert.assertEquals("", viewState.getTextString()); Assert.assertEquals(0, viewState.selection); }
public void setText(@Nonnull String text) { Check.isMainThread(); onTextChanged(EditorState.create(text, text.length())); }
Editor { public void setText(@Nonnull String text) { Check.isMainThread(); onTextChanged(EditorState.create(text, text.length())); } }
Editor { public void setText(@Nonnull String text) { Check.isMainThread(); onTextChanged(EditorState.create(text, text.length())); } @Inject  Editor(@Nonnull Application application, @Nonnull SharedPreferences preferences, @Nonnull Engine engine); }
Editor { public void setText(@Nonnull String text) { Check.isMainThread(); onTextChanged(EditorState.create(text, text.length())); } @Inject  Editor(@Nonnull Application application, @Nonnull SharedPreferences preferences, @Nonnull Engine engine); void init(); static int clamp(int selection, @Nonnull CharSequence text); static int clamp(int selection, int max); void setView(@Nonnull EditorView view); void clearView(@Nonnull EditorView view); @Nonnull EditorState getState(); void setState(@Nonnull EditorState state); @Nonnull EditorState setCursorOnStart(); @Nonnull EditorState setCursorOnEnd(); @Nonnull EditorState moveCursorLeft(); @Nonnull EditorState moveCursorRight(); boolean erase(); void clear(); void setText(@Nonnull String text); void setText(@Nonnull String text, int selection); void insert(@Nonnull String text); void insert(@Nonnull String text, int selectionOffset); @Nonnull EditorState moveSelection(int offset); @Nonnull EditorState setSelection(int selection); @Subscribe void onEngineChanged(@Nonnull Engine.ChangedEvent e); @Subscribe void onMemoryValueReady(@Nonnull Memory.ValueReadyEvent e); void onHistoryLoaded(@Nonnull RecentHistory history); }
Editor { public void setText(@Nonnull String text) { Check.isMainThread(); onTextChanged(EditorState.create(text, text.length())); } @Inject  Editor(@Nonnull Application application, @Nonnull SharedPreferences preferences, @Nonnull Engine engine); void init(); static int clamp(int selection, @Nonnull CharSequence text); static int clamp(int selection, int max); void setView(@Nonnull EditorView view); void clearView(@Nonnull EditorView view); @Nonnull EditorState getState(); void setState(@Nonnull EditorState state); @Nonnull EditorState setCursorOnStart(); @Nonnull EditorState setCursorOnEnd(); @Nonnull EditorState moveCursorLeft(); @Nonnull EditorState moveCursorRight(); boolean erase(); void clear(); void setText(@Nonnull String text); void setText(@Nonnull String text, int selection); void insert(@Nonnull String text); void insert(@Nonnull String text, int selectionOffset); @Nonnull EditorState moveSelection(int offset); @Nonnull EditorState setSelection(int selection); @Subscribe void onEngineChanged(@Nonnull Engine.ChangedEvent e); @Subscribe void onMemoryValueReady(@Nonnull Memory.ValueReadyEvent e); void onHistoryLoaded(@Nonnull RecentHistory history);  }