Dimension getPreferredSize() {
   int width = getPreferredWidth();
   if (!myDocument.isInBulkUpdate()) {
     for (Caret caret : myEditor.getCaretModel().getAllCarets()) {
       if (caret.isUpToDate()) {
         int caretX = myView.visualPositionToXY(caret.getVisualPosition()).x;
         width = Math.max(caretX, width);
       }
     }
   }
   width += myEditor.getSettings().getAdditionalColumnsCount() * myView.getPlainSpaceWidth();
   return new Dimension(width, myEditor.getPreferredHeight());
 }
Exemplo n.º 2
0
 private EditorWindow(
     @NotNull DocumentWindowImpl documentWindow,
     @NotNull final EditorImpl delegate,
     @NotNull PsiFile injectedFile,
     boolean oneLine) {
   myDocumentWindow = documentWindow;
   myDelegate = delegate;
   myInjectedFile = injectedFile;
   myOneLine = oneLine;
   myCaretModelDelegate = new CaretModelWindow(myDelegate.getCaretModel(), this);
   mySelectionModelDelegate = new SelectionModelWindow(myDelegate, myDocumentWindow, this);
   myMarkupModelDelegate =
       new MarkupModelWindow((MarkupModelEx) myDelegate.getMarkupModel(), myDocumentWindow);
   myFoldingModelWindow = new FoldingModelWindow(delegate.getFoldingModel(), documentWindow, this);
 }
 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;
 }
Exemplo n.º 4
0
 Dimension getPreferredSize() {
   int widthWithoutCaret = getPreferredWidth();
   int width = widthWithoutCaret;
   if (!myDocument.isInBulkUpdate()) {
     for (Caret caret : myEditor.getCaretModel().getAllCarets()) {
       if (caret.isUpToDate()) {
         int caretX = myView.visualPositionToXY(caret.getVisualPosition()).x;
         width = Math.max(caretX, width);
       }
     }
   }
   if (shouldRespectAdditionalColumns(widthWithoutCaret)) {
     width += myEditor.getSettings().getAdditionalColumnsCount() * myView.getPlainSpaceWidth();
   }
   Insets insets = myView.getInsets();
   return new Dimension(width + insets.left + insets.right, getPreferredHeight());
 }