document.replace(offset, 0, String.valueOf(trigger)); setCursorPosition(getCursorPosition() + 1); if (trigger == '(' && autocloseBrackets()) { document.replace(getReplacementOffset() + getCursorPosition(), 0, ")"); //$NON-NLS-1$ setUpLinkedMode(document, ')');
document.replace(offset, 0, String.valueOf(trigger)); setCursorPosition(getCursorPosition() + 1); if (trigger == '(' && autocloseBrackets()) { document.replace(getReplacementOffset() + getCursorPosition(), 0, ")"); //$NON-NLS-1$ setUpLinkedMode(document, ')');
document.replace(offset, 0, String.valueOf(trigger)); setCursorPosition(getCursorPosition() + 1); if (trigger == '(' && autocloseBrackets()) { document.replace(getReplacementOffset() + getCursorPosition(), 0, ")"); //$NON-NLS-1$ setUpLinkedMode(document, ')');
if (getTextViewer() != null && autocloseBrackets()) { int offset= getReplacementOffset() + getCursorPosition(); int exit= getReplacementOffset() + getReplacementString().length();
/** * 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); } } }
/** * 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); } } }