@Override public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) { if (editor.getSelectionModel().hasSelection()) { int selStart = editor.getSelectionModel().getSelectionStart(); int selEnd = editor.getSelectionModel().getSelectionEnd(); if (selEnd > selStart && DocumentUtil.isAtLineStart(selEnd, editor.getDocument())) { selEnd--; } VisualPosition rangeStart = editor.offsetToVisualPosition(Math.min(selStart, selEnd)); VisualPosition rangeEnd = editor.offsetToVisualPosition(Math.max(selStart, selEnd)); final Couple<Integer> copiedRange = DuplicateAction.duplicateLinesRange(editor, editor.getDocument(), rangeStart, rangeEnd); if (copiedRange != null) { editor.getSelectionModel().setSelection(copiedRange.first, copiedRange.second); } } else { VisualPosition caretPos = editor.getCaretModel().getVisualPosition(); DuplicateAction.duplicateLinesRange(editor, editor.getDocument(), caretPos, caretPos); } }
public EditorComponentImpl(@NotNull EditorImpl editor) { myEditor = editor; enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.INPUT_METHOD_EVENT_MASK); enableInputMethods(true); setFocusCycleRoot(true); setOpaque(true); putClientProperty(Magnificator.CLIENT_PROPERTY_KEY, new Magnificator() { @Override public Point magnify(double scale, Point at) { VisualPosition magnificationPosition = myEditor.xyToVisualPosition(at); double currentSize = myEditor.getColorsScheme().getEditorFontSize(); int defaultFontSize = EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize(); myEditor.setFontSize(Math.max((int)(currentSize * scale), defaultFontSize)); return myEditor.visualPositionToXY(magnificationPosition); } }); myApplication = (ApplicationImpl)ApplicationManager.getApplication(); }
/** * Every soft wrap implies that multiple visual positions correspond to the same document offset. We can classify * such positions by the following criteria: * <pre> * <ul> * <li>positions from visual line with soft wrap start;</li> * <li>positions from visual line with soft wrap end;</li> * </ul> * </pre> * <p/> * This method allows to answer if caret offset of the given editor points to soft wrap and visual caret position * belongs to the visual line where soft wrap end is located. * * @param editor target editor * @return <code>true</code> if caret offset of the given editor points to visual position that belongs to * visual line where soft wrap end is located */ public static boolean isCaretAfterSoftWrap(CaretImpl caret) { if (!caret.isUpToDate()) { return false; } EditorImpl editor = caret.getEditor(); SoftWrapModel softWrapModel = editor.getSoftWrapModel(); int offset = caret.getOffset(); SoftWrap softWrap = softWrapModel.getSoftWrap(offset); if (softWrap == null) { return false; } if (editor.myUseNewRendering) { VisualPosition afterWrapPosition = editor.offsetToVisualPosition(offset, false, false); VisualPosition caretPosition = caret.getVisualPosition(); return caretPosition.line == afterWrapPosition.line && caretPosition.column <= afterWrapPosition.column; } else { return editor.offsetToVisualLine(offset) == caret.getVisualPosition().line; } }
@Nullable private static Point getVisibleBestPopupLocation(@NotNull Editor editor) { VisualPosition visualPosition = editor.getUserData(ANCHOR_POPUP_POSITION); if (visualPosition == null) { CaretModel caretModel = editor.getCaretModel(); if (caretModel.isUpToDate()) { visualPosition = caretModel.getVisualPosition(); } else { visualPosition = editor.offsetToVisualPosition(caretModel.getOffset()); } } Point p = editor.visualPositionToXY(new VisualPosition(visualPosition.line + 1, visualPosition.column)); final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); return visibleArea.contains(p) ? p : null; }
public void testMoveCaretFromVirtualSpaceToRealOffset() throws IOException { boolean virtualSpacesBefore = EditorSettingsExternalizable.getInstance().isVirtualSpace(); EditorSettingsExternalizable.getInstance().setVirtualSpace(true); try { doTestDeleteToStart("\n a a \n b b \n", new VisualPosition(1, 10), "\n<caret>\n b b \n", new VisualPosition(1, 0)); doTestDeleteToStart("\n a a \n b b \n", new VisualPosition(2, 10), "\n a a \n<caret>\n", new VisualPosition(2, 0)); doTestDeleteToStart("\n a a \n b b \n", new VisualPosition(3, 10), "\n a a \n b b \n<caret>", new VisualPosition(3, 0)); doTestDeleteToStart("\n a a \n b b \n", new VisualPosition(20, 10), "\n a a \n b b \n<caret>", new VisualPosition(3, 0)); doTestDeleteToEnd("\n a a \n b b \n", new VisualPosition(1, 10), "\n a a <caret> b b \n", new VisualPosition(1, 5)); // keep old behavior - not sure if it was intentional or not doTestDeleteToEnd("\n a a \n b b \n", new VisualPosition(3, 10), "\n a a \n b b \n<caret>", new VisualPosition(3, 10)); } finally { EditorSettingsExternalizable.getInstance().setVirtualSpace(virtualSpacesBefore); } }
private void doTestDelete(boolean toStart, @NotNull String before, @Nullable VisualPosition positionBefore, @NotNull String after, @Nullable VisualPosition positionAfter) throws IOException { configureFromFileText(getTestName(false) + ".txt", before); if (positionBefore != null) mouse().clickAt(positionBefore.line, positionBefore.column); if (toStart) { deleteToLineStart(); } else { deleteToLineEnd(); } checkResultByText(after); if (positionAfter != null) { assertEquals(positionAfter, getEditor().getCaretModel().getVisualPosition()); } }
private static void checkOffsetConversions(int offset, LogicalPosition logicalPosition, VisualPosition visualPositionTowardsSmallerOffsets, VisualPosition visualPositionTowardsLargerOffsets, Point xyTowardsSmallerOffsets, Point xyTowardsLargerOffsets) { assertLogicalPositionsEqual("Wrong offset->logicalPosition calculation", logicalPosition, myEditor.offsetToLogicalPosition(offset)); assertVisualPositionsEqual("Wrong beforeOffset->visualPosition calculation", visualPositionTowardsSmallerOffsets, myEditor.offsetToVisualPosition(offset, false, false)); assertVisualPositionsEqual("Wrong afterOffset->visualPosition calculation", visualPositionTowardsLargerOffsets, myEditor.offsetToVisualPosition(offset, true, false)); assertEquals("Wrong afterOffset->visualLine calculation", visualPositionTowardsLargerOffsets.line, ((EditorImpl)myEditor).offsetToVisualLine(offset)); assertEquals("Wrong beforeOffset->xy calculation", xyTowardsSmallerOffsets, ((EditorImpl)myEditor).offsetToXY(offset, false)); assertEquals("Wrong afterOffset->xy calculation", xyTowardsLargerOffsets, ((EditorImpl)myEditor).offsetToXY(offset, true)); }
@Override public void executeWriteAction(Editor editor, DataContext dataContext) { Project project = editor.getProject(); if (project != null && !editor.getSelectionModel().hasSelection()) { PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file != null) { VisualPosition caret = editor.getCaretModel().getVisualPosition(); Pair<LogicalPosition, LogicalPosition> lines = EditorUtil.calcSurroundingRange(editor, caret, caret); TextRange toDuplicate = new TextRange(editor.logicalPositionToOffset(lines.first), editor.logicalPositionToOffset(lines.second)); PsiElement name = findNameIdentifier(editor, file, toDuplicate); if (name != null && !name.getTextRange().containsOffset(editor.getCaretModel().getOffset())) { editor.getCaretModel().moveToOffset(name.getTextOffset()); } } } myOriginal.execute(editor, dataContext); }
private void calculateSelectedTextRectangle() { SelectionModel selectionModel = myEditor.getSelectionModel(); int selectionStartOffset = selectionModel.getSelectionStart(); int selectionEndOffset = selectionModel.getSelectionEnd(); VisualPosition maxColumnVp = getMaxColumnInsideRange(selectionStartOffset, selectionEndOffset); Point maxColumnsPoint = myEditor.visualPositionToXY(maxColumnVp); Point selectionStart = myEditor.visualPositionToXY(myEditor.offsetToVisualPosition(selectionStartOffset)); Point selectionEnd = myEditor.visualPositionToXY(myEditor.offsetToVisualPosition(selectionEndOffset)); selectionStart = SwingUtilities.convertPoint(myContentComponent, selectionStart, myEditorComponent); selectionEnd = SwingUtilities.convertPoint(myContentComponent, selectionEnd, myEditorComponent); maxColumnsPoint = SwingUtilities.convertPoint(myContentComponent, maxColumnsPoint, myEditorComponent); mySelectionStartY = selectionStart.y; mySelectionEndY = selectionEnd.y; myTextRangeMaxColumnX = maxColumnsPoint.x; }
/** * This method is executed just after the <code>toString</code> method is created or updated. * * @param method the newly created/updated <code>toString</code> method. * @param params additional parameters stored with key/value in the map. * @param template the template to use * @throws IncorrectOperationException is thrown by IDEA */ private void afterCreateToStringMethod(PsiMethod method, Map<String, String> params, TemplateResource template) { PsiFile containingFile = clazz.getContainingFile(); if (containingFile instanceof PsiJavaFile) { final PsiJavaFile javaFile = (PsiJavaFile)containingFile; if (params.get("autoImportPackages") != null) { // keep this for old user templates autoImportPackages(javaFile, params.get("autoImportPackages")); } } method = (PsiMethod)JavaCodeStyleManager.getInstance(clazz.getProject()).shortenClassReferences(method); // jump to method if (!config.isJumpToMethod() || editor == null) { return; } int offset = method.getTextOffset(); if (offset <= 2) { return; } VisualPosition vp = editor.offsetToVisualPosition(offset); if (logger.isDebugEnabled()) logger.debug("Moving/Scrolling caret to " + vp + " (offset=" + offset + ")"); editor.getCaretModel().moveToVisualPosition(vp); editor.getScrollingModel().scrollToCaret(ScrollType.CENTER_DOWN); }
private String getSelectedText(SelectionModel selectionModel, Document document) { VisualPosition start = selectionModel.getSelectionStartPosition(); VisualPosition end = selectionModel.getSelectionEndPosition(); String lines[] = document.getText().split("\n"); List<String> contentLines = new ArrayList<String>(); for (int i = start.getLine(); i <= end.getLine(); i++) { contentLines.add(lines[i]); } int diff = contentLines.get(0).length() - contentLines.get(0).trim().length(); if (diff > 0) { for (int i = 0; i < contentLines.size(); i++) { contentLines.set(i, this.leftTrim(contentLines.get(i), diff)); } } return this.arrayToStringConversion(contentLines); }
public static String getTypeInfo(Module module, VisualPosition blockStart, VisualPosition blockEnd, VirtualFile projectFile) { final String canonicalPath = projectFile.getCanonicalPath(); if (canonicalPath == null){ return "canonical path is null"; } final String workDir = ExecUtil.guessWorkDir(module); if (ToolKey.GHC_MODI_KEY.getPath(module.getProject()) != null) { GhcModi ghcModi = module.getComponent(GhcModi.class); if (ghcModi != null) { return GhcModi.getFutureType(module.getProject(), ghcModi.type(canonicalPath, blockStart, blockEnd)); } else { return "ghcModi is not configured"; } } else { return GhcMod.type(module, workDir, canonicalPath, blockStart, blockEnd); } }
public Future<String> type(final @NotNull String canonicalPath, @NotNull final VisualPosition startPosition, @NotNull final VisualPosition stopPosition) { return handleGhcModiCall(new GhcModiCallable<String>(){ @Override public String call() throws GhcModiError { final String command = "type " + canonicalPath + ' ' + startPosition.line + ' ' + startPosition.column; final String stdout = simpleExec(command); try { return stdout == null ? "Type info not found" : GhcModUtil.handleTypeInfo(startPosition, stopPosition, stdout); } catch (GhcModUtil.TypeInfoParseException e) { NotificationUtil.displayToolsNotification( NotificationType.ERROR, module.getProject(), "Type Info Error", "There was an error when executing the ghc-modi `type` command:\n\n" + stdout); return null; } } }); }
@Override public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) { int startOffset = element.getTextRange().getStartOffset(); int endOffset = element.getTextRange().getEndOffset(); Module module = ModuleUtilCore.findModuleForPsiElement(element); FileDocumentManager fileDocumentManager= FileDocumentManager.getInstance(); VirtualFile projectFile = element.getContainingFile().getVirtualFile(); Document cachedDocument = fileDocumentManager.getCachedDocument(projectFile); if (cachedDocument == null) { return null; } int startLineNumber = cachedDocument.getLineNumber(startOffset); int endLineNumber = cachedDocument.getLineNumber(endOffset); int startColumn = startOffset - cachedDocument.getLineStartOffset(startLineNumber); int endColumn = endOffset - cachedDocument.getLineStartOffset(endLineNumber); // and also correct them for (0,0) vs (1,1) leftmost coordinate (intellij -> ghc) VisualPosition startPosition = TypeInfoUtil.correctFor0BasedVS1Based(new VisualPosition(startLineNumber, startColumn)); VisualPosition endPosition = TypeInfoUtil.correctFor0BasedVS1Based(new VisualPosition(endLineNumber, endColumn)); return TypeInfoUtil.getTypeInfo(module,startPosition,endPosition, projectFile); }
@Override public void executeWriteAction(Editor editor, DataContext dataContext) { if (editor.getSelectionModel().hasSelection()) { int selStart = editor.getSelectionModel().getSelectionStart(); int selEnd = editor.getSelectionModel().getSelectionEnd(); VisualPosition rangeStart = editor.offsetToVisualPosition(Math.min(selStart, selEnd)); VisualPosition rangeEnd = editor.offsetToVisualPosition(Math.max(selStart, selEnd)); final Pair<Integer,Integer> copiedRange = DuplicateAction.duplicateLinesRange(editor, editor.getDocument(), rangeStart, rangeEnd); if (copiedRange != null) { editor.getSelectionModel().setSelection(copiedRange.first, copiedRange.second); } } else { VisualPosition caretPos = editor.getCaretModel().getVisualPosition(); DuplicateAction.duplicateLinesRange(editor, editor.getDocument(), caretPos, caretPos); } }
/** * This method is executed just after the <code>toString</code> method is created or updated. * * @param method the newly created/updated <code>toString</code> method. * @param params additional parameters stored with key/value in the map. * @param template the template to use * @throws IncorrectOperationException is thrown by IDEA */ private void afterCreateToStringMethod(PsiMethod method, Map<String, String> params, TemplateResource template) { PsiFile containingFile = clazz.getContainingFile(); if (containingFile instanceof PsiJavaFile) { final PsiJavaFile javaFile = (PsiJavaFile)containingFile; if (params.get("autoImportPackages") != null) { // keep this for old user templates autoImportPackages(javaFile, params.get("autoImportPackages")); } method = (PsiMethod)JavaCodeStyleManager.getInstance(clazz.getProject()).shortenClassReferences(method); } // jump to method if (!config.isJumpToMethod() || editor == null) { return; } int offset = method.getTextOffset(); if (offset <= 2) { return; } VisualPosition vp = editor.offsetToVisualPosition(offset); if (logger.isDebugEnabled()) logger.debug("Moving/Scrolling caret to " + vp + " (offset=" + offset + ")"); editor.getCaretModel().moveToVisualPosition(vp); editor.getScrollingModel().scrollToCaret(ScrollType.CENTER_DOWN); }
private <T extends JBPopup> T showPopup(DataContext data, T popup, int offset) { if ( editor != null ) { VisualPosition visualPosition = editor.offsetToVisualPosition(offset); Point p = editor.visualPositionToXY(new VisualPosition(visualPosition.line + 1, visualPosition.column)); final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); if ( !visibleArea.contains(p) ) { p = new Point((visibleArea.x + visibleArea.width) / 2, (visibleArea.y + visibleArea.height) / 2); } popups.add(popup); popup.show(new RelativePoint(editor.getContentComponent(), p)); //((ListPopup)popup).handleSelect(false); } else if ( position != null ) { popup.show(position); } else { popup.show(popupFactory.guessBestPopupLocation(component)); } return popup; }
@RequiredWriteAction @Override public void executeWriteAction(Editor editor, DataContext dataContext) { if (editor.getSelectionModel().hasSelection()) { int selStart = editor.getSelectionModel().getSelectionStart(); int selEnd = editor.getSelectionModel().getSelectionEnd(); VisualPosition rangeStart = editor.offsetToVisualPosition(Math.min(selStart, selEnd)); VisualPosition rangeEnd = editor.offsetToVisualPosition(Math.max(selStart, selEnd)); final Pair<Integer,Integer> copiedRange = DuplicateAction.duplicateLinesRange(editor, editor.getDocument(), rangeStart, rangeEnd); if (copiedRange != null) { editor.getSelectionModel().setSelection(copiedRange.first, copiedRange.second); } } else { VisualPosition caretPos = editor.getCaretModel().getVisualPosition(); DuplicateAction.duplicateLinesRange(editor, editor.getDocument(), caretPos, caretPos); } }
@Nullable @Override public Inlay getElementAt(@Nonnull Point point) { if (myInlayTree.size() == 0) return null; int offset = myEditor.logicalPositionToOffset(myEditor.xyToLogicalPosition(point)); List<Inlay> inlays = getInlineElementsInRange(offset, offset); if (inlays.isEmpty()) return null; VisualPosition startVisualPosition = myEditor.offsetToVisualPosition(offset); int x = myEditor.visualPositionToXY(startVisualPosition).x; for (Inlay inlay : inlays) { int endX = x + inlay.getWidthInPixels(); if (point.x >= x && point.x < endX) return inlay; x = endX; } return null; }
@Nullable private static Point getVisibleBestPopupLocation(@Nonnull Editor editor) { VisualPosition visualPosition = editor.getUserData(ANCHOR_POPUP_POSITION); if (visualPosition == null) { CaretModel caretModel = editor.getCaretModel(); if (caretModel.isUpToDate()) { visualPosition = caretModel.getVisualPosition(); } else { visualPosition = editor.offsetToVisualPosition(caretModel.getOffset()); } } final int lineHeight = editor.getLineHeight(); Point p = editor.visualPositionToXY(visualPosition); p.y += lineHeight; final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); return !visibleArea.contains(p) && !visibleArea.contains(p.x, p.y - lineHeight) ? null : p; }
@RequiredWriteAction @Override public void executeWriteAction(Editor editor, DataContext dataContext) { Project project = editor.getProject(); if (project != null && !editor.getSelectionModel().hasSelection()) { PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file != null) { VisualPosition caret = editor.getCaretModel().getVisualPosition(); Pair<LogicalPosition, LogicalPosition> lines = EditorUtil.calcSurroundingRange(editor, caret, caret); TextRange toDuplicate = new TextRange(editor.logicalPositionToOffset(lines.first), editor.logicalPositionToOffset(lines.second)); PsiElement name = findNameIdentifier(editor, file, toDuplicate); if (name != null && !name.getTextRange().containsOffset(editor.getCaretModel().getOffset())) { editor.getCaretModel().moveToOffset(name.getTextOffset()); } } } myOriginal.execute(editor, dataContext); }
/** * Adds a caret that selects the given interval. * * @param fromOffset the start of the selected interval * @param toOffset the end of the selected interval */ private void addSelection(final int fromOffset, final int toOffset) { final VisualPosition fromVisualPosition = myFixture.getEditor().offsetToVisualPosition(fromOffset); caretModel.addCaret(fromVisualPosition); final int caretCount = caretModel.getCaretCount(); caretModel.getAllCarets().get(caretCount - 1).setSelection(fromOffset, toOffset); }
/** * Creates new <code>IncrementalCacheUpdateEvent</code> object that is configured to perform whole reparse of the given * document. * * @param document target document to reparse */ IncrementalCacheUpdateEvent(@NotNull Document document) { myStartOffset = 0; myMandatoryEndOffset = document.getTextLength(); myLengthDiff = 0; myStartLogicalPosition = new LogicalPosition(0, 0, 0, 0, 0, 0, 0); myStartVisualPosition = new VisualPosition(0, 0); myOldEndLogicalLine = myNewEndLogicalLine = Math.max(0, document.getLineCount() - 1); }
@Override public int paint(@NotNull Graphics g, @NotNull SoftWrapDrawingType drawingType, int x, int y, int lineHeight) { initDelegateIfNecessary(); if (!myEditor.getSettings().isAllSoftWrapsShown()) { int visualLine = y / lineHeight; LogicalPosition position = myEditor.visualToLogicalPosition(new VisualPosition(visualLine, 0)); if (position.line != myEditor.getCaretModel().getLogicalPosition().line) { return myDelegate.getDrawingHorizontalOffset(g, drawingType, x, y, lineHeight); } } return myDelegate.paint(g, drawingType, x, y, lineHeight); }
public void testPositionCalculationOnEmptyLine() throws Exception { initText("text with\n" + "\n" + "empty line"); VisualPosition pos = new VisualPosition(1, 0); VisualPosition recalculatedPos = myEditor.xyToVisualPosition(myEditor.visualPositionToXY(pos)); assertEquals(pos, recalculatedPos); }
public void testPositionCalculationForOneCharacterFolds() throws Exception { initText("something"); addCollapsedFoldRegion(1, 2, "..."); addCollapsedFoldRegion(3, 4, "..."); assertEquals(new VisualPosition(0, 5), myEditor.logicalToVisualPosition(new LogicalPosition(0, 3))); }
public void testNavigationIntoFoldedRegionWithSoftWrapsEnabled() throws Exception { initText("something"); addCollapsedFoldRegion(4, 8, "..."); configureSoftWraps(1000); myEditor.getCaretModel().moveToOffset(5); assertEquals(new VisualPosition(0, 5), myEditor.getCaretModel().getVisualPosition()); }
public void testPositionCalculationForMultilineFoldingWithEmptyPlaceholder() throws Exception { initText("line1\n" + "line2\n" + "line3\n" + "line4"); addCollapsedFoldRegion(6, 17, ""); configureSoftWraps(1000); assertEquals(new LogicalPosition(3, 0), myEditor.visualToLogicalPosition(new VisualPosition(2, 0))); }
public void testNavigationInsideNonNormalizedLineTerminator() throws Exception { initText(""); ((DocumentImpl)myEditor.getDocument()).setAcceptSlashR(true); myEditor.getDocument().insertString(0, "abc\r\ndef"); myEditor.getCaretModel().moveToOffset(4); assertEquals(new LogicalPosition(0, 3), myEditor.getCaretModel().getLogicalPosition()); assertEquals(new VisualPosition(0, 3), myEditor.getCaretModel().getVisualPosition()); }
public void testSoftWrapModeUpdateDuringBulkModeChange() throws Exception { initText("long long line<caret>"); configureSoftWraps(12); DocumentEx document = (DocumentEx)myEditor.getDocument(); document.setInBulkUpdate(true); document.replaceString(4, 5, "-"); document.setInBulkUpdate(false); assertEquals(new VisualPosition(1, 5), myEditor.getCaretModel().getVisualPosition()); }
private static void checkOffsetConversions(int offset, LogicalPosition logicalPosition, VisualPosition visualPositionTowardsSmallerOffsets, VisualPosition visualPositionTowardsLargerOffsets, Point xy) { checkOffsetConversions(offset, logicalPosition, visualPositionTowardsSmallerOffsets, visualPositionTowardsLargerOffsets, xy, xy); }
private static boolean canPlaceBulbOnTheSameLine(Editor editor) { if (ApplicationManager.getApplication().isUnitTestMode() || editor.isOneLineMode()) return false; final int offset = editor.getCaretModel().getOffset(); final VisualPosition pos = editor.offsetToVisualPosition(offset); int line = pos.line; final int firstNonSpaceColumnOnTheLine = EditorActionUtil.findFirstNonSpaceColumnOnTheLine(editor, line); if (firstNonSpaceColumnOnTheLine == -1) return false; final Point point = editor.visualPositionToXY(new VisualPosition(line, firstNonSpaceColumnOnTheLine)); return point.x > AllIcons.Actions.RealIntentionBulb.getIconWidth() + (editor.isOneLineMode() ? SMALL_BORDER_SIZE : NORMAL_BORDER_SIZE) * 2; }
@Override protected String expand(Editor editor) { VisualPosition selectionEndPosition = editor.getSelectionModel().getSelectionEndPosition(); if (selectionEndPosition == null) { return null; } return getColumnNumber(editor, editor.visualToLogicalPosition(selectionEndPosition)); }
@Override protected String expand(Editor editor) { VisualPosition selectionEndPosition = editor.getSelectionModel().getSelectionEndPosition(); if (selectionEndPosition == null) { return null; } return String.valueOf(editor.visualToLogicalPosition(selectionEndPosition).line + 1); }
@Override protected String expand(Editor editor) { VisualPosition selectionStartPosition = editor.getSelectionModel().getSelectionStartPosition(); if (selectionStartPosition == null) { return null; } return String.valueOf(editor.visualToLogicalPosition(selectionStartPosition).line + 1); }
@Override protected String expand(Editor editor) { VisualPosition selectionStartPosition = editor.getSelectionModel().getSelectionStartPosition(); if (selectionStartPosition == null) { return null; } return getColumnNumber(editor, editor.visualToLogicalPosition(selectionStartPosition)); }
private VisualPosition getMaxColumnInsideRange(int startOffset, int endOffset) { int firstLine = myDocument.getLineNumber(startOffset); int lastLine = myDocument.getLineNumber(endOffset); VisualPosition positionWithMaxColumn = new VisualPosition(0, 0); for (int currentLine = firstLine; currentLine <= lastLine; currentLine++) { int offset = myDocument.getLineEndOffset(currentLine); VisualPosition position = myEditor.offsetToVisualPosition(offset); if (position.getColumn() > positionWithMaxColumn.getColumn()) { positionWithMaxColumn = position; } } return positionWithMaxColumn; }