@Override public default CharSequence subSequence(int start, int end) { return getTextRange(start, end - start); } }
@Override public default char charAt(int index) { return getTextRange(index, 1).charAt(0); }
/** * Get the text for the given range * * @param start * the start * @param end * the end * @return the text */ public @NonNull String getText(int start, int end) { return getContent().getTextRange(start, end - start + 1); }
/** * Get the text for the given range * * @param start * the start * @param end * the end * @return the text */ public @NonNull String getText(int start, int end) { return getContent().getTextRange(start, end - start + 1); }
public String read() { return getControl().getContent().getTextRange(this.start, this.length); }
@SuppressWarnings("deprecation") private void moveCaretAbsolute(int absoluteOffset, boolean select) { int offset = Math.max(0, absoluteOffset); offset = Math.min(getControl().getCharCount(), offset); // we need to jump 2 chars if windows line endings are in effect if( offset > 0 ) { String textRange = getControl().getContent().getTextRange(offset-1, 1); // check the navigation direction if( getControl().getCaretOffset() > offset ) { if( textRange.equals("\r") ) { //$NON-NLS-1$ offset -= 1; } } else { if( textRange.equals("\r") ) { //$NON-NLS-1$ offset += 1; } } } getControl().impl_setCaretOffset(Math.max(0,offset), select); }
/** * Copy the current selection into the clipboard */ @SuppressWarnings("null") public void copy() { if (getSelection().length > 0) { final Clipboard clipboard = Clipboard.getSystemClipboard(); clipboard.setContent(Collections.singletonMap(DataFormat.PLAIN_TEXT, getContent().getTextRange(getSelection().offset, getSelection().length))); } }
/** * Copy the current selection into the clipboard */ @SuppressWarnings("null") public void copy() { if (getSelection().length > 0) { final Clipboard clipboard = Clipboard.getSystemClipboard(); clipboard.setContent(Collections.singletonMap(DataFormat.PLAIN_TEXT, getContent().getTextRange(getSelection().offset, getSelection().length))); } }
/** * Cut the current selection into the clipboard */ public void cut() { TextSelection selection = getSelection(); if (selection.length > 0) { final Clipboard clipboard = Clipboard.getSystemClipboard(); String content = getContent().getTextRange(selection.offset, selection.length); setCaretOffset(selection.offset); getContent().replaceTextRange(selection.offset, content.length(), ""); //$NON-NLS-1$ clipboard.setContent(Collections.singletonMap(DataFormat.PLAIN_TEXT, content)); } }
/** * Cut the current selection into the clipboard */ public void cut() { if( getSelection().length > 0 ) { final Clipboard clipboard = Clipboard.getSystemClipboard(); String content = getContent().getTextRange(getSelection().offset, getSelection().length); getContent().replaceTextRange(getSelection().offset, content.length(), ""); //$NON-NLS-1$ clipboard.setContent(Collections.singletonMap(DataFormat.PLAIN_TEXT, content)); } }
String allContent = getControl().getContent().getTextRange(0, getControl().getCharCount()); StringBuffer dataBuffer = new StringBuffer(allContent);
String allContent = getControl().getContent().getTextRange(0, getControl().getCharCount()); StringBuffer dataBuffer = new StringBuffer(allContent);
/** * default implementation for {@link DefaultTextEditActions#DELETE_PREVIOUS} */ protected void defaultDeletePrevious() { int offset = getControl().getCaretOffset(); TextSelection selection = getControl().getSelection(); if (selection.length > 0) { getControl().getContent().replaceTextRange(selection.offset, selection.length, ""); //$NON-NLS-1$ getControl().setCaretOffset(selection.offset); } else { int start = getControl().getCaretOffset() - 1; int del = 1; if (start - 1 >= 0) { if ("\r\n".equals(getControl().getContent().getTextRange(getControl().getCaretOffset()-2, 2))) { //$NON-NLS-1$ start = start - 1; del = 2; } } if( start >= 0 ) { getControl().getContent().replaceTextRange(start, del, ""); //$NON-NLS-1$ getControl().setCaretOffset(offset - del); } } }
/** * default implementation for {@link DefaultTextEditActions#DELETE} */ protected void defaultDelete() { int offset = getControl().getCaretOffset(); TextSelection selection = getControl().getSelection(); if (selection.length > 0) { getControl().getContent().replaceTextRange(selection.offset, selection.length, ""); //$NON-NLS-1$ getControl().setCaretOffset(selection.offset); } else { int del = 1; if (getControl().getCaretOffset() + 2 <= getControl().getContent().getCharCount()) { if ("\r\n".equals(getControl().getContent().getTextRange(getControl().getCaretOffset(), 2))) { //$NON-NLS-1$ del = 2; } } if (getControl().getCaretOffset() + del <= getControl().getContent().getCharCount()) { getControl().getContent().replaceTextRange(getControl().getCaretOffset(), del, ""); //$NON-NLS-1$ getControl().setCaretOffset(offset); } } }
String text = getControl().getContent().getTextRange(this.dragMoveTextOffset, this.dragMoveTextLength);