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


Java CaretModel.isUpToDate方法代码示例

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


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

示例1: getVisibleBestPopupLocation

import com.intellij.openapi.editor.CaretModel; //导入方法依赖的package包/类
@Nullable
private static Point getVisibleBestPopupLocation(@NotNull Editor editor) {
  VisualPosition visualPosition = editor.getUserData(ANCHOR_POPUP_POSITION);

  if (visualPosition == null) {
    CaretModel caretModel = editor.getCaretModel();
    if (caretModel.isUpToDate()) {
      visualPosition = caretModel.getVisualPosition();
    }
    else {
      visualPosition = editor.offsetToVisualPosition(caretModel.getOffset());
    }
  }

  Point p = editor.visualPositionToXY(new VisualPosition(visualPosition.line + 1, visualPosition.column));

  final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
  return visibleArea.contains(p) ? p : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PopupFactoryImpl.java

示例2: getVisibleBestPopupLocation

import com.intellij.openapi.editor.CaretModel; //导入方法依赖的package包/类
@Nullable
private static Point getVisibleBestPopupLocation(@Nonnull Editor editor) {
  VisualPosition visualPosition = editor.getUserData(ANCHOR_POPUP_POSITION);

  if (visualPosition == null) {
    CaretModel caretModel = editor.getCaretModel();
    if (caretModel.isUpToDate()) {
      visualPosition = caretModel.getVisualPosition();
    }
    else {
      visualPosition = editor.offsetToVisualPosition(caretModel.getOffset());
    }
  }

  final int lineHeight = editor.getLineHeight();
  Point p = editor.visualPositionToXY(visualPosition);
  p.y += lineHeight;

  final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
  return !visibleArea.contains(p) && !visibleArea.contains(p.x, p.y - lineHeight)
         ? null : p;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:PopupFactoryImpl.java

示例3: isCaretAfterSoftWrap

import com.intellij.openapi.editor.CaretModel; //导入方法依赖的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.CaretModel.isUpToDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。