use of com.intellij.openapi.editor.LogicalPosition in project android by JetBrains.
the class ConsoleHighlighter method appendToDocument.
private void appendToDocument() {
Document document = myEditor.getDocument();
if (document != null) {
String pendingString = StringUtil.convertLineSeparators(getPendingString());
document.insertString(document.getTextLength(), pendingString);
if (myEditor instanceof Editor) {
Editor editor = (Editor) myEditor;
int lineCount = document.getLineCount();
editor.getScrollingModel().scrollTo(new LogicalPosition(lineCount - 1, 0), ScrollType.MAKE_VISIBLE);
}
}
}
use of com.intellij.openapi.editor.LogicalPosition in project ideavim by JetBrains.
the class FileGroup method displayFileInfo.
public void displayFileInfo(@NotNull Editor editor, boolean fullPath) {
StringBuilder msg = new StringBuilder();
VirtualFile vf = EditorData.getVirtualFile(editor);
if (vf != null) {
msg.append('"');
if (fullPath) {
msg.append(vf.getPath());
} else {
Project project = editor.getProject();
if (project != null) {
VirtualFile root = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(vf);
if (root != null) {
msg.append(vf.getPath().substring(root.getPath().length() + 1));
} else {
msg.append(vf.getPath());
}
}
}
msg.append("\" ");
} else {
msg.append("\"[No File]\" ");
}
Document doc = editor.getDocument();
if (!doc.isWritable()) {
msg.append("[RO] ");
} else if (FileDocumentManager.getInstance().isDocumentUnsaved(doc)) {
msg.append("[+] ");
}
int lline = editor.getCaretModel().getLogicalPosition().line;
int total = EditorHelper.getLineCount(editor);
int pct = (int) ((float) lline / (float) total * 100f + 0.5);
msg.append("line ").append(lline + 1).append(" of ").append(total);
msg.append(" --").append(pct).append("%-- ");
LogicalPosition lp = editor.getCaretModel().getLogicalPosition();
int col = editor.getCaretModel().getOffset() - doc.getLineStartOffset(lline);
msg.append("col ").append(col + 1);
if (col != lp.column) {
msg.append("-").append(lp.column + 1);
}
VimPlugin.showMessage(msg.toString());
}
use of com.intellij.openapi.editor.LogicalPosition in project ideavim by JetBrains.
the class MarkGroup method setMark.
/**
* Sets the specified mark to the specified location.
*
* @param editor The editor the mark is associated with
* @param ch The mark to set
* @param offset The offset to set the mark to
* @return true if able to set the mark, false if not
*/
public boolean setMark(@NotNull Editor editor, char ch, int offset) {
if (ch == '`')
ch = '\'';
LogicalPosition lp = editor.offsetToLogicalPosition(offset);
final VirtualFile vf = EditorData.getVirtualFile(editor);
if (vf == null) {
return false;
}
Mark mark = new Mark(ch, lp.line, lp.column, vf.getPath());
// File specific marks get added to the file
if (FILE_MARKS.indexOf(ch) >= 0) {
HashMap<Character, Mark> fmarks = getFileMarks(editor.getDocument());
if (fmarks == null) {
return false;
}
fmarks.put(ch, mark);
} else // Global marks get set to both the file and the global list of marks
if (GLOBAL_MARKS.indexOf(ch) >= 0) {
HashMap<Character, Mark> fmarks = getFileMarks(editor.getDocument());
if (fmarks == null) {
return false;
}
fmarks.put(ch, mark);
Mark oldMark = globalMarks.put(ch, mark);
if (oldMark != null) {
oldMark.clear();
}
}
return true;
}
use of com.intellij.openapi.editor.LogicalPosition in project ideavim by JetBrains.
the class MarkGroup method getMark.
/**
* Gets the requested mark for the editor
*
* @param editor The editor to get the mark for
* @param ch The desired mark
* @return The requested mark if set, null if not set
*/
@Nullable
public Mark getMark(@NotNull Editor editor, char ch) {
Mark mark = null;
if (ch == '`')
ch = '\'';
// Make sure this is a valid mark
if (VALID_GET_MARKS.indexOf(ch) < 0)
return null;
VirtualFile vf = EditorData.getVirtualFile(editor);
if ("{}".indexOf(ch) >= 0 && vf != null) {
int offset = SearchHelper.findNextParagraph(editor, ch == '{' ? -1 : 1, false);
offset = EditorHelper.normalizeOffset(editor, offset, false);
LogicalPosition lp = editor.offsetToLogicalPosition(offset);
mark = new Mark(ch, lp.line, lp.column, vf.getPath());
} else if ("()".indexOf(ch) >= 0 && vf != null) {
int offset = SearchHelper.findNextSentenceStart(editor, ch == '(' ? -1 : 1, false, true);
offset = EditorHelper.normalizeOffset(editor, offset, false);
LogicalPosition lp = editor.offsetToLogicalPosition(offset);
mark = new Mark(ch, lp.line, lp.column, vf.getPath());
} else // If this is a file mark, get the mark from this file
if (FILE_MARKS.indexOf(ch) >= 0) {
final HashMap fmarks = getFileMarks(editor.getDocument());
if (fmarks != null) {
mark = (Mark) fmarks.get(new Character(ch));
if (mark != null && mark.isClear()) {
fmarks.remove(new Character(ch));
mark = null;
}
}
} else // This is a mark from another file
if (GLOBAL_MARKS.indexOf(ch) >= 0) {
mark = globalMarks.get(new Character(ch));
if (mark != null && mark.isClear()) {
globalMarks.remove(new Character(ch));
mark = null;
}
}
return mark;
}
use of com.intellij.openapi.editor.LogicalPosition in project WebStormRequireJsPlugin by Fedott.
the class CompletionPathWithDotTest method testFileOnRootProjectDir.
public void testFileOnRootProjectDir() {
Settings.getInstance(getProject()).publicPath = "";
myFixture.configureByFile("parentWebPathFile.js");
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(2, 36));
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assert strings != null;
assertCompletionList(Arrays.asList("./parentWebPathFile", "./public/blocks/block", "./public/blocks/childWebPathFile", "./public/blocks/fileWithDotPath", "./public/blocks/fileWithTwoDotPath", "./public/blocks/childBlocks/childBlock", "./public/main", "./public/rootWebPathFile"), strings);
}
Aggregations