@Override public Point getSelection(IDocument document) { if (!fIsValidated) return null; return new Point(getReplacementOffset() + getCursorPosition(), 0); }
@Override public Point getSelection(IDocument document) { if (!fIsValidated) return null; return new Point(getReplacementOffset() + getCursorPosition(), 0); }
public Point getSelection(IDocument document) { return new Point(getReplacementOffset() + getCursorPosition(), 0); }
@Override protected final int getCursorPosition() { if (!fCursorPositionComputed) setCursorPosition(computeCursorPosition()); return super.getCursorPosition(); }
protected final int getCursorPosition() { if (!fCursorPositionComputed) setCursorPosition(computeCursorPosition()); return super.getCursorPosition(); }
@Override protected final int getCursorPosition() { if (!fCursorPositionComputed) setCursorPosition(computeCursorPosition()); return super.getCursorPosition(); }
@Override public int getContextInformationPosition() { if (getContextInformation() == null) return getReplacementOffset() - 1; return getReplacementOffset() + getCursorPosition(); }
@Override public int getContextInformationPosition() { if (getContextInformation() == null) return getReplacementOffset() - 1; return getReplacementOffset() + getCursorPosition(); }
public int getContextInformationPosition() { if (getContextInformation() == null) return getReplacementOffset() - 1; return getReplacementOffset() + getCursorPosition(); }
private void handleSmartTrigger(IDocument document, char trigger, int referenceOffset) throws BadLocationException { DocumentCommand cmd= new DocumentCommand() { }; cmd.offset= referenceOffset; cmd.length= 0; cmd.text= Character.toString(trigger); cmd.doit= true; cmd.shiftsCaret= true; cmd.caretOffset= getReplacementOffset() + getCursorPosition(); SmartSemicolonAutoEditStrategy strategy= new SmartSemicolonAutoEditStrategy(IJavaPartitions.JAVA_PARTITIONING); strategy.customizeDocumentCommand(document, cmd); replace(document, cmd.offset, cmd.length, cmd.text); setCursorPosition(cmd.caretOffset - getReplacementOffset() + cmd.text.length()); }
private void handleSmartTrigger(IDocument document, char trigger, int referenceOffset) throws BadLocationException { DocumentCommand cmd= new DocumentCommand() { }; cmd.offset= referenceOffset; cmd.length= 0; cmd.text= Character.toString(trigger); cmd.doit= true; cmd.shiftsCaret= true; cmd.caretOffset= getReplacementOffset() + getCursorPosition(); SmartSemicolonAutoEditStrategy strategy= new SmartSemicolonAutoEditStrategy(IJavaPartitions.JAVA_PARTITIONING); strategy.customizeDocumentCommand(document, cmd); replace(document, cmd.offset, cmd.length, cmd.text); setCursorPosition(cmd.caretOffset - getReplacementOffset() + cmd.text.length()); }
private void handleSmartTrigger(IDocument document, char trigger, int referenceOffset) throws BadLocationException { DocumentCommand cmd= new DocumentCommand() { }; cmd.offset= referenceOffset; cmd.length= 0; cmd.text= Character.toString(trigger); cmd.doit= true; cmd.shiftsCaret= true; cmd.caretOffset= getReplacementOffset() + getCursorPosition(); SmartSemicolonAutoEditStrategy strategy= new SmartSemicolonAutoEditStrategy(IJavaPartitions.JAVA_PARTITIONING); strategy.customizeDocumentCommand(document, cmd); replace(document, cmd.offset, cmd.length, cmd.text); setCursorPosition(cmd.caretOffset - getReplacementOffset() + cmd.text.length()); }
try { document.replace(offset, 0, String.valueOf(trigger)); setCursorPosition(getCursorPosition() + 1); if (trigger == '(' && autocloseBrackets()) { document.replace(getReplacementOffset() + getCursorPosition(), 0, ")"); //$NON-NLS-1$ setUpLinkedMode(document, ')');
try { document.replace(offset, 0, String.valueOf(trigger)); setCursorPosition(getCursorPosition() + 1); if (trigger == '(' && autocloseBrackets()) { document.replace(getReplacementOffset() + getCursorPosition(), 0, ")"); //$NON-NLS-1$ setUpLinkedMode(document, ')');
try { document.replace(offset, 0, String.valueOf(trigger)); setCursorPosition(getCursorPosition() + 1); if (trigger == '(' && autocloseBrackets()) { document.replace(getReplacementOffset() + getCursorPosition(), 0, ")"); //$NON-NLS-1$ setUpLinkedMode(document, ')');
if ((getCursorPosition() > 0 && getCursorPosition() <= buffer.length() && buffer.charAt(getCursorPosition() - 1) != trigger)) { if (trigger == ';' && getCursorPosition() != length) { if (buffer.charAt(length - 1) != trigger) { buffer.insert(length, trigger); buffer.insert(getCursorPosition(), trigger); setCursorPosition(getCursorPosition() + 1);
if ((getCursorPosition() > 0 && getCursorPosition() <= buffer.length() && buffer.charAt(getCursorPosition() - 1) != trigger)) { buffer.insert(getCursorPosition(), trigger); setCursorPosition(getCursorPosition() + 1);
/** * Sets up a simple linked mode at {@link #getCursorPosition()} and an exit policy that will * exit the mode when <code>closingCharacter</code> is typed and an exit position at * <code>getCursorPosition() + 1</code>. * * @param document the document * @param closingCharacter the exit character */ protected void setUpLinkedMode(IDocument document, char closingCharacter) { if (getTextViewer() != null && autocloseBrackets()) { int offset= getReplacementOffset() + getCursorPosition(); int exit= getReplacementOffset() + getReplacementString().length(); try { LinkedPositionGroup group= new LinkedPositionGroup(); group.addPosition(new LinkedPosition(document, offset, 0, LinkedPositionGroup.NO_STOP)); LinkedModeModel model= new LinkedModeModel(); model.addGroup(group); model.forceInstall(); LinkedModeUI ui= new EditorLinkedModeUI(model, getTextViewer()); ui.setSimpleMode(true); ui.setExitPolicy(new ExitPolicy(closingCharacter, document)); ui.setExitPosition(getTextViewer(), exit, 0, Integer.MAX_VALUE); ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER); ui.enter(); } catch (BadLocationException x) { JavaPlugin.log(x); } } }
int offset= getReplacementOffset() + getCursorPosition(); int exit= getReplacementOffset() + getReplacementString().length(); try {
/** * Sets up a simple linked mode at {@link #getCursorPosition()} and an exit policy that will * exit the mode when <code>closingCharacter</code> is typed and an exit position at * <code>getCursorPosition() + 1</code>. * * @param document the document * @param closingCharacter the exit character */ protected void setUpLinkedMode(IDocument document, char closingCharacter) { if (getTextViewer() != null && autocloseBrackets()) { int offset= getReplacementOffset() + getCursorPosition(); int exit= getReplacementOffset() + getReplacementString().length(); try { LinkedPositionGroup group= new LinkedPositionGroup(); group.addPosition(new LinkedPosition(document, offset, 0, LinkedPositionGroup.NO_STOP)); LinkedModeModel model= new LinkedModeModel(); model.addGroup(group); model.forceInstall(); LinkedModeUI ui= new EditorLinkedModeUI(model, getTextViewer()); ui.setSimpleMode(true); ui.setExitPolicy(new ExitPolicy(closingCharacter, document)); ui.setExitPosition(getTextViewer(), exit, 0, Integer.MAX_VALUE); ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER); ui.enter(); } catch (BadLocationException x) { JavaPlugin.log(x); } } }