Tabnine Logo
LogicalPosition.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.intellij.openapi.editor.LogicalPosition
constructor

Best Java code snippets using com.intellij.openapi.editor.LogicalPosition.<init> (Showing top 17 results out of 315)

origin: JetBrains/ideavim

public static int getOffset(@NotNull final Editor editor, final int line, final int column) {
 return editor.logicalPositionToOffset(new LogicalPosition(line, column));
}
origin: JetBrains/ideavim

public int moveCaretToColumn(@NotNull Editor editor, @NotNull Caret caret, int count, boolean allowEnd) {
 int line = caret.getLogicalPosition().line;
 int pos = EditorHelper.normalizeColumn(editor, line, count, allowEnd);
 return editor.logicalPositionToOffset(new LogicalPosition(line, pos));
}
origin: JetBrains/ideavim

/**
 * Converts a logical line number to a visual line number. Several logical lines can map to the same
 * visual line when there are collapsed fold regions.
 *
 * @param editor The editor
 * @param line   The logical line number to convert
 * @return The visual line number
 */
public static int logicalLineToVisualLine(@NotNull final Editor editor, final int line) {
 if (editor instanceof EditorImpl) {
  // This is faster than simply calling Editor#logicalToVisualPosition
  return ((EditorImpl) editor).offsetToVisualLine(editor.getDocument().getLineStartOffset(line));
 }
 return editor.logicalToVisualPosition(new LogicalPosition(line, 0)).line;
}
origin: JetBrains/ideavim

public int moveCaretToFileMark(@NotNull Editor editor, char ch, boolean toLineStart) {
 final Mark mark = VimPlugin.getMark().getFileMark(editor, ch);
 if (mark == null) return -1;
 final int line = mark.getLogicalLine();
 return toLineStart ? moveCaretToLineStartSkipLeading(editor, line)
           : editor.logicalPositionToOffset(new LogicalPosition(line, mark.getCol()));
}
origin: JetBrains/ideavim

public int moveCaretToLine(@NotNull Editor editor, int logicalLine) {
 int col = CaretData.getLastColumn(editor.getCaretModel().getPrimaryCaret());
 int line = logicalLine;
 if (logicalLine < 0) {
  line = 0;
  col = 0;
 }
 else if (logicalLine >= EditorHelper.getLineCount(editor)) {
  line = EditorHelper.normalizeLine(editor, EditorHelper.getLineCount(editor) - 1);
  col = EditorHelper.getLineLength(editor, line);
 }
 LogicalPosition newPos = new LogicalPosition(line, EditorHelper.normalizeColumn(editor, line, col, false));
 return editor.logicalPositionToOffset(newPos);
}
origin: JetBrains/ideavim

public int moveCaretToMark(@NotNull Editor editor, char ch, boolean toLineStart) {
 final Mark mark = VimPlugin.getMark().getMark(editor, ch);
 if (mark == null) return -1;
 final VirtualFile vf = EditorData.getVirtualFile(editor);
 if (vf == null) return -1;
 final int line = mark.getLogicalLine();
 if (vf.getPath().equals(mark.getFilename())) {
  return toLineStart ? moveCaretToLineStartSkipLeading(editor, line)
            : editor.logicalPositionToOffset(new LogicalPosition(line, mark.getCol()));
 }
 final Editor selectedEditor = selectEditor(editor, mark);
 if (selectedEditor != null) {
  for (Caret caret : selectedEditor.getCaretModel().getAllCarets()) {
   moveCaret(selectedEditor, caret, toLineStart ? moveCaretToLineStartSkipLeading(selectedEditor, line)
                          : selectedEditor.logicalPositionToOffset(
                            new LogicalPosition(line, mark.getCol())));
  }
 }
 return -2;
}
origin: JetBrains/ideavim

final int insertOffset = editor.logicalPositionToOffset(new LogicalPosition(currentLine, currentColumn));
MotionGroup.moveCaret(editor, caret, insertOffset);
final String insertedText = origSegment + StringUtil.repeat(segment, count - 1);
origin: JetBrains/ideavim

res = editor.logicalPositionToOffset(new LogicalPosition(endLine, endColumn));
origin: JetBrains/ideavim

final LogicalPosition lp = new LogicalPosition(jump.getLogicalLine(), jump.getCol());
final String fileName = jump.getFilename();
if (!vf.getPath().equals(fileName) && fileName != null) {
origin: ballerina-platform/ballerina-lang

@Override
public Result postProcessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull DataContext dataContext) {
  if (!file.getLanguage().is(BallerinaLanguage.INSTANCE)) {
    return Result.Continue;
  }
  // We need to save the file before checking. Otherwise issues can occur when we press enter in a string.
  Project project = file.getProject();
  PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
  // Checks whether the previous line starts with "#".
  LogicalPosition caretPos = editor.getCaretModel().getLogicalPosition();
  int prevLine = caretPos.line - 1;
  String lineString = editor.getDocument().getText(
      new TextRange(editor.getDocument().getLineStartOffset(prevLine),
          editor.getDocument().getLineEndOffset(prevLine)));
  if (lineString.trim().startsWith("#")) {
    int newCol = lineString.indexOf("#");
    String enteredText = editor.getDocument().getText(
        new TextRange(editor.getDocument().getLineStartOffset(caretPos.line),
            editor.getDocument().getLineEndOffset(caretPos.line))).trim();
    editor.getDocument().deleteString(editor.getDocument().getLineStartOffset(caretPos.line),
        editor.getDocument().getLineEndOffset(caretPos.line));
    editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(caretPos.line, 1));
    enterNewLine(editor, enteredText, newCol);
    // Commit the document.
    PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
  }
  return Result.Continue;
}
origin: JetBrains/ideavim

private void updateBlockSelection(@NotNull Editor editor, int offset) {
 EditorData.setVisualBlockEnd(editor, offset);
 EditorData.setVisualBlockOffset(editor, offset);
 int start = EditorData.getVisualBlockStart(editor);
 int end = EditorData.getVisualBlockEnd(editor);
 LogicalPosition blockStart = editor.offsetToLogicalPosition(start);
 LogicalPosition blockEnd = editor.offsetToLogicalPosition(end);
 if (blockStart.column < blockEnd.column) {
  blockEnd = new LogicalPosition(blockEnd.line, blockEnd.column + 1);
 }
 else {
  blockStart = new LogicalPosition(blockStart.line, blockStart.column + 1);
 }
 editor.getSelectionModel().setBlockSelection(blockStart, blockEnd);
 for (Caret caret : editor.getCaretModel().getAllCarets()) {
  int line = caret.getLogicalPosition().line;
  int lineEndOffset = EditorHelper.getLineEndOffset(editor, line, true);
  if (CaretData.getLastColumn(editor.getCaretModel().getPrimaryCaret()) >= MotionGroup.LAST_COLUMN) {
   caret.setSelection(caret.getSelectionStart(), lineEndOffset);
  }
  if (!EditorHelper.isLineEmpty(editor, line, false)) {
   caret.moveToOffset(caret.getSelectionEnd() - 1);
  }
 }
 editor.getCaretModel().getPrimaryCaret().moveToOffset(end);
 VimPlugin.getMark().setVisualSelectionMarks(editor, new TextRange(start, end));
}
origin: JetBrains/ideavim

caret.moveToOffset(editor.logicalPositionToOffset(new LogicalPosition(line, column)));
origin: JetBrains/ideavim

final int visualLine = caret.getVisualPosition().line;
final int logicalLine = caret.getLogicalPosition().line;
final int position = editor.logicalPositionToOffset(new LogicalPosition(logicalLine, repeatColumn));
origin: JetBrains/ideavim

int len = EditorHelper.getLineLength(editor, l);
if (len > from) {
 LogicalPosition spos = new LogicalPosition(l, from);
 caret.moveToOffset(editor.logicalPositionToOffset(spos));
 insertText(editor, caret, indent);
int len = EditorHelper.getLineLength(editor, l);
if (len > from) {
 LogicalPosition spos = new LogicalPosition(l, from);
 LogicalPosition epos = new LogicalPosition(l, from + size - 1);
 int wsoff = editor.logicalPositionToOffset(spos);
 int weoff = editor.logicalPositionToOffset(epos);
origin: jshiell/checkstyle-idea

/**
 * Scroll to the error specified by the given tree path, or do nothing
 * if no error is specified.
 *
 * @param treePath the tree path to scroll to.
 */
private void scrollToError(final TreePath treePath) {
  final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
  if (treeNode == null || !(treeNode.getUserObject() instanceof ResultTreeNode)) {
    return;
  }
  final ResultTreeNode nodeInfo = (ResultTreeNode) treeNode.getUserObject();
  if (nodeInfo.getFile() == null || nodeInfo.getProblem() == null) {
    return; // no problem here :-)
  }
  final VirtualFile virtualFile = nodeInfo.getFile().getVirtualFile();
  if (virtualFile == null || !virtualFile.exists()) {
    return;
  }
  final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
  final FileEditor[] editor = fileEditorManager.openFile(
      virtualFile, true);
  if (editor.length > 0 && editor[0] instanceof TextEditor) {
    final LogicalPosition problemPos = new LogicalPosition(
        Math.max(lineFor(nodeInfo) - 1, 0), Math.max(columnFor(nodeInfo), 0));
    final Editor textEditor = ((TextEditor) editor[0]).getEditor();
    textEditor.getCaretModel().moveToLogicalPosition(problemPos);
    textEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
  }
}
origin: Camelcade/Perl5-IDEA

public void testEnterTyping() {
 initWithPerlTidy();
 myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(65, 0));
 final int iterations = 30;
 for (int i = 0; i < iterations; i++) {
  myFixture.type("\n");
 }
 final int time = 1000;
 PlatformTestUtil.startPerformanceTest("PerlTidy enter typing", iterations * time, () -> {
  long start = System.currentTimeMillis();
  for (int i = 0; i < iterations; i++) {
   myFixture.type("\n");
  }
  long length = System.currentTimeMillis() - start;
  System.err.println("Typing enter done in " + length / iterations + " ms per iteration  of " + time);
 }).assertTiming();
}
origin: zhengjunbase/codehelper.generator

if (pojo != null) {
  request.setPojoName(pojo.getClassName());
  LogicalPosition newStatementPos = new LogicalPosition(pojo.getLineNumber() , pojo.getLineStartPos() + 1);
  LogicalPosition insertPos = new LogicalPosition(pojo.getLineNumber() + 1 , 0 );
  caretModel.moveToLogicalPosition(newStatementPos);
  PsiElement currentFileElement = event.getData(LangDataKeys.PSI_ELEMENT);
com.intellij.openapi.editorLogicalPosition<init>

Popular methods of LogicalPosition

    Popular in Java

    • Making http requests using okhttp
    • setContentView (Activity)
    • getSupportFragmentManager (FragmentActivity)
    • setScale (BigDecimal)
    • BufferedWriter (java.io)
      Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
    • System (java.lang)
      Provides access to system-related information and resources including standard input and output. Ena
    • Stack (java.util)
      Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
    • AtomicInteger (java.util.concurrent.atomic)
      An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
    • Base64 (org.apache.commons.codec.binary)
      Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
    • Join (org.hibernate.mapping)
    • Top plugins for Android Studio
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now