public void doClick(final MouseEvent e, final int width) { RangeHighlighter marker = getNearestRangeHighlighter(e, width); if (marker == null) return; int offset = marker.getStartOffset(); final Document doc = myEditor.getDocument(); if (doc.getLineCount() > 0) { // Necessary to expand folded block even if navigating just before one // Very useful when navigating to first unused import statement. int lineEnd = doc.getLineEndOffset(doc.getLineNumber(offset)); myEditor.getCaretModel().moveToOffset(lineEnd); } myEditor.getCaretModel().moveToOffset(offset); myEditor.getSelectionModel().removeSelection(); ScrollingModel scrollingModel = myEditor.getScrollingModel(); scrollingModel.disableAnimation(); scrollingModel.scrollToCaret(ScrollType.CENTER); scrollingModel.enableAnimation(); fireErrorMarkerClicked(marker, e); }
private Map<Integer, Couple<Integer>> createVirtualSelectionMap( int startVisualLine, int endVisualLine) { HashMap<Integer, Couple<Integer>> map = new HashMap<Integer, Couple<Integer>>(); for (Caret caret : myEditor.getCaretModel().getAllCarets()) { if (caret.hasSelection()) { VisualPosition selectionStart = caret.getSelectionStartPosition(); VisualPosition selectionEnd = caret.getSelectionEndPosition(); if (selectionStart.line == selectionEnd.line) { int line = selectionStart.line; if (line >= startVisualLine && line <= endVisualLine) { map.put(line, Couple.of(selectionStart.column, selectionEnd.column)); } } } } return map; }