当前位置: 首页>>代码示例>>Java>>正文


Java EditorImpl.getSoftWrapModel方法代码示例

本文整理汇总了Java中com.intellij.openapi.editor.impl.EditorImpl.getSoftWrapModel方法的典型用法代码示例。如果您正苦于以下问题:Java EditorImpl.getSoftWrapModel方法的具体用法?Java EditorImpl.getSoftWrapModel怎么用?Java EditorImpl.getSoftWrapModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.editor.impl.EditorImpl的用法示例。


在下文中一共展示了EditorImpl.getSoftWrapModel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visualLineStartOffset

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private int visualLineStartOffset(int offset, boolean leanForward) {
  EditorImpl editor = myView.getEditor();
  int result = EditorUtil.getNotFoldedLineStartOffset(editor, offset);

  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  List<? extends SoftWrap> softWraps = softWrapModel.getRegisteredSoftWraps();
  int currentOrPrevWrapIndex = softWrapModel.getSoftWrapIndex(offset);
  SoftWrap currentOrPrevWrap;
  if (currentOrPrevWrapIndex < 0) {
    currentOrPrevWrapIndex = - currentOrPrevWrapIndex - 2;
    currentOrPrevWrap = currentOrPrevWrapIndex < 0 || currentOrPrevWrapIndex >= softWraps.size() ? null :
                        softWraps.get(currentOrPrevWrapIndex);
  }
  else {
    currentOrPrevWrap = leanForward ? softWraps.get(currentOrPrevWrapIndex) : null;
  }
  if (currentOrPrevWrap != null && currentOrPrevWrap.getStart() > result) {
    result = currentOrPrevWrap.getStart();
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:EditorCoordinateMapper.java

示例2: isCaretAfterSoftWrap

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:SoftWrapHelper.java

示例3: visualLineStartOffset

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private int visualLineStartOffset(int offset, boolean leanForward) {
  EditorImpl editor = myView.getEditor();
  offset = DocumentUtil.alignToCodePointBoundary(myDocument, offset);
  int result = EditorUtil.getNotFoldedLineStartOffset(editor, offset);

  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  List<? extends SoftWrap> softWraps = softWrapModel.getRegisteredSoftWraps();
  int currentOrPrevWrapIndex = softWrapModel.getSoftWrapIndex(offset);
  SoftWrap currentOrPrevWrap;
  if (currentOrPrevWrapIndex < 0) {
    currentOrPrevWrapIndex = - currentOrPrevWrapIndex - 2;
    currentOrPrevWrap = currentOrPrevWrapIndex < 0 || currentOrPrevWrapIndex >= softWraps.size() ? null :
                        softWraps.get(currentOrPrevWrapIndex);
  }
  else {
    currentOrPrevWrap = leanForward ? softWraps.get(currentOrPrevWrapIndex) : null;
  }
  if (currentOrPrevWrap != null && currentOrPrevWrap.getStart() > result) {
    result = currentOrPrevWrap.getStart();
  }
  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:EditorCoordinateMapper.java

示例4: getVisualLineInfo

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private static VisualLineInfo getVisualLineInfo(@Nonnull EditorImpl editor, int offset, boolean beforeSoftWrap) {
  Document document = editor.getDocument();
  int textLength = document.getTextLength();
  if (offset <= 0 || textLength == 0) return new VisualLineInfo(0, false);
  offset = Math.min(offset, textLength);

  int startOffset = EditorUtil.getNotFoldedLineStartOffset(editor, offset);

  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  int wrapIndex = softWrapModel.getSoftWrapIndex(offset);
  int prevSoftWrapIndex = wrapIndex < 0 ? (- wrapIndex - 2) : wrapIndex - (beforeSoftWrap ? 1 : 0);
  SoftWrap prevSoftWrap = prevSoftWrapIndex < 0 ? null : softWrapModel.getRegisteredSoftWraps().get(prevSoftWrapIndex);

  int visualLineStartOffset = prevSoftWrap == null ? startOffset : Math.max(startOffset, prevSoftWrap.getStart());
  return new VisualLineInfo(visualLineStartOffset, prevSoftWrap != null && prevSoftWrap.getStart() == visualLineStartOffset);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:IncrementalCacheUpdateEvent.java

示例5: VisualLineFragmentsIterator

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private VisualLineFragmentsIterator(EditorView view, int offset, boolean beforeSoftWrap, @Nullable Runnable quickEvaluationListener) {
  EditorImpl editor = view.getEditor();
  int visualLineStartOffset = EditorUtil.getNotFoldedLineStartOffset(editor, offset);

  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  List<? extends SoftWrap> softWraps = softWrapModel.getRegisteredSoftWraps();
  int currentOrPrevWrapIndex = softWrapModel.getSoftWrapIndex(offset);
  if (currentOrPrevWrapIndex < 0) {
    currentOrPrevWrapIndex = - currentOrPrevWrapIndex - 2;
  }
  else if (beforeSoftWrap) {
    currentOrPrevWrapIndex--;
  }
  SoftWrap currentOrPrevWrap = currentOrPrevWrapIndex < 0 || currentOrPrevWrapIndex >= softWraps.size() ? null :
                               softWraps.get(currentOrPrevWrapIndex);
  if (currentOrPrevWrap != null && currentOrPrevWrap.getStart() > visualLineStartOffset) {
    visualLineStartOffset = currentOrPrevWrap.getStart();
  }

  int nextFoldingIndex = editor.getFoldingModel().getLastCollapsedRegionBefore(visualLineStartOffset) + 1;

  init(view,
       visualLineStartOffset,
       editor.getDocument().getLineNumber(visualLineStartOffset),
       currentOrPrevWrapIndex,
       nextFoldingIndex,
       quickEvaluationListener);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:29,代码来源:VisualLineFragmentsIterator.java

示例6: init

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private void init(EditorView view, int startOffset, int startLogicalLine, int currentOrPrevWrapIndex, int nextFoldingIndex,
                  @Nullable Runnable quickEvaluationListener) {
  myQuickEvaluationListener = quickEvaluationListener;
  myView = view;
  EditorImpl editor = view.getEditor();
  myDocument = editor.getDocument();
  FoldingModelEx foldingModel = editor.getFoldingModel();
  FoldRegion[] regions = foldingModel.fetchTopLevel();
  myRegions = regions == null ? FoldRegion.EMPTY_ARRAY : regions;
  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  List<? extends SoftWrap> softWraps = softWrapModel.getRegisteredSoftWraps();
  SoftWrap currentOrPrevWrap = currentOrPrevWrapIndex < 0 || currentOrPrevWrapIndex >= softWraps.size() ? null :
                               softWraps.get(currentOrPrevWrapIndex);
  SoftWrap followingWrap = (currentOrPrevWrapIndex + 1) < 0 || (currentOrPrevWrapIndex + 1) >= softWraps.size() ? null :
                           softWraps.get(currentOrPrevWrapIndex + 1);

  myVisualLineStartOffset = mySegmentStartOffset = startOffset;

  myCurrentFoldRegionIndex = nextFoldingIndex;
  myCurrentEndLogicalLine = startLogicalLine;
  myCurrentX = myView.getInsets().left;
  if (mySegmentStartOffset == 0) {
    myCurrentX += myView.getPrefixTextWidthInPixels();
  }
  else if (currentOrPrevWrap != null && mySegmentStartOffset == currentOrPrevWrap.getStart()) {
    myCurrentX += currentOrPrevWrap.getIndentInPixels();
    myCurrentVisualColumn = currentOrPrevWrap.getIndentInColumns();
  }
  myNextWrapOffset = followingWrap == null ? Integer.MAX_VALUE : followingWrap.getStart();
  setInlaysAndFragmentIterator();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:32,代码来源:VisualLineFragmentsIterator.java

示例7: VisualLineFragmentsIterator

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的package包/类
private VisualLineFragmentsIterator(EditorView view, int offset, boolean beforeSoftWrap, @Nullable Runnable quickEvaluationListener) {
  myQuickEvaluationListener = quickEvaluationListener;
  myView = view;
  EditorImpl editor = view.getEditor();
  myDocument = editor.getDocument();
  FoldingModelEx foldingModel = editor.getFoldingModel();
  FoldRegion[] regions = foldingModel.fetchTopLevel();
  myRegions = regions == null ? FoldRegion.EMPTY_ARRAY : regions;
  int visualLineStartOffset = EditorUtil.getNotFoldedLineStartOffset(editor, offset);

  SoftWrapModelImpl softWrapModel = editor.getSoftWrapModel();
  List<? extends SoftWrap> softWraps = softWrapModel.getRegisteredSoftWraps();
  int currentOrPrevWrapIndex = softWrapModel.getSoftWrapIndex(offset);
  if (currentOrPrevWrapIndex < 0) {
    currentOrPrevWrapIndex = - currentOrPrevWrapIndex - 2;
  }
  else if (beforeSoftWrap) {
    currentOrPrevWrapIndex--;
  }
  SoftWrap currentOrPrevWrap = currentOrPrevWrapIndex < 0 || currentOrPrevWrapIndex >= softWraps.size() ? null :
                               softWraps.get(currentOrPrevWrapIndex);
  SoftWrap followingWrap = (currentOrPrevWrapIndex + 1) >= softWraps.size() ? null : softWraps.get(currentOrPrevWrapIndex + 1);

  if (currentOrPrevWrap != null && currentOrPrevWrap.getStart() > visualLineStartOffset) {
    visualLineStartOffset = currentOrPrevWrap.getStart();
  }
  
  myVisualLineStartOffset = mySegmentStartOffset = visualLineStartOffset;

  myCurrentFoldRegionIndex = foldingModel.getLastCollapsedRegionBefore(mySegmentStartOffset) + 1;
  myCurrentEndLogicalLine = myDocument.getLineNumber(mySegmentStartOffset);
  if (mySegmentStartOffset == 0) {
    myCurrentX = myView.getPrefixTextWidthInPixels();
  }
  else if (currentOrPrevWrap != null && mySegmentStartOffset == currentOrPrevWrap.getStart()) {
    myCurrentX = currentOrPrevWrap.getIndentInPixels();
    myCurrentVisualColumn = currentOrPrevWrap.getIndentInColumns();
  }
  myNextWrapOffset = followingWrap == null ? Integer.MAX_VALUE : followingWrap.getStart();
  setFragmentIterator();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:VisualLineFragmentsIterator.java

示例8: isCaretAfterSoftWrap

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:34,代码来源:SoftWrapHelper.java

示例9: isCaretAfterSoftWrap

import com.intellij.openapi.editor.impl.EditorImpl; //导入方法依赖的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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:SoftWrapHelper.java


注:本文中的com.intellij.openapi.editor.impl.EditorImpl.getSoftWrapModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。