本文整理汇总了Java中com.intellij.openapi.editor.SoftWrapModel类的典型用法代码示例。如果您正苦于以下问题:Java SoftWrapModel类的具体用法?Java SoftWrapModel怎么用?Java SoftWrapModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoftWrapModel类属于com.intellij.openapi.editor包,在下文中一共展示了SoftWrapModel类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCaretAfterSoftWrap
import com.intellij.openapi.editor.SoftWrapModel; //导入依赖的package包/类
/**
* 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;
}
}
示例2: isCaretAfterSoftWrap
import com.intellij.openapi.editor.SoftWrapModel; //导入依赖的package包/类
/**
* 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;
}
VisualPosition afterWrapPosition = editor.offsetToVisualPosition(offset, false, false);
VisualPosition caretPosition = caret.getVisualPosition();
return caretPosition.line == afterWrapPosition.line && caretPosition.column <= afterWrapPosition.column;
}
示例3: isCaretAfterSoftWrap
import com.intellij.openapi.editor.SoftWrapModel; //导入依赖的package包/类
/**
* 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(EditorImpl editor) {
CaretModel caretModel = editor.getCaretModel();
if (!caretModel.isUpToDate()) {
return false;
}
SoftWrapModel softWrapModel = editor.getSoftWrapModel();
int offset = caretModel.getOffset();
SoftWrap softWrap = softWrapModel.getSoftWrap(offset);
if (softWrap == null) {
return false;
}
return editor.offsetToVisualLine(offset) == caretModel.getVisualPosition().line;
}