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


Java EditorUtil.charWidth方法代码示例

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


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

示例1: setPrefixTextAndAttributes

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
@Override
public void setPrefixTextAndAttributes(@Nullable String prefixText, @Nullable TextAttributes attributes) {
  myPrefixText = prefixText == null ? null : prefixText.toCharArray();
  myPrefixAttributes = attributes;
  myPrefixWidthInPixels = 0;
  if (myPrefixText != null) {
    for (char c : myPrefixText) {
      LOG.assertTrue(myPrefixAttributes != null);
      if (myPrefixAttributes != null) {
        myPrefixWidthInPixels += EditorUtil.charWidth(c, myPrefixAttributes.getFontType(), this);
      }
    }
  }
  mySoftWrapModel.recalculate();
  if (myUseNewRendering) myView.setPrefix(prefixText, attributes);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:bigFile.java

示例2: getTextSegmentWidth

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
private int getTextSegmentWidth(@NotNull CharSequence text,
                                int start,
                                int end,
                                int xStart,
                                @JdkConstants.FontStyle int fontType,
                                @NotNull Rectangle clip) {
  int x = xStart;

  for (int i = start; i < end && xStart < clip.x + clip.width; i++) {
    char c = text.charAt(i);
    if (c == '\t') {
      x = EditorUtil.nextTabStop(x, this);
    }
    else {
      x += EditorUtil.charWidth(c, fontType, this);
    }
    if (x > clip.x + clip.width) {
      break;
    }
  }
  return x - xStart;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:bigFile.java

示例3: charToVisibleWidth

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
/**
 * Allows to answer how much width requires given char to be represented on a screen.
 *
 * @param c        target character
 * @param fontType font type to use for representation of the given character
 * @param currentX current <code>'x'</code> position on a line where given character should be displayed
 * @return width required to represent given char with the given settings on a screen;
 *         <code>'0'</code> if given char is a line break
 */
private int charToVisibleWidth(char c, @JdkConstants.FontStyle int fontType, int currentX) {
  if (c == '\n') {
    return 0;
  }

  if (c == '\t') {
    return EditorUtil.nextTabStop(currentX, this) - currentX;
  }
  return EditorUtil.charWidth(c, fontType, this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:bigFile.java

示例4: charToVisibleWidth

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
/**
 * Allows to answer how much width requires given char to be represented on a screen.
 *
 * @param c        target character
 * @param fontType font type to use for representation of the given character
 * @param currentX current <code>'x'</code> position on a line where given character should be displayed
 * @return width required to represent given char with the given settings on a screen;
 * <code>'0'</code> if given char is a line break
 */
private int charToVisibleWidth(char c, @JdkConstants.FontStyle int fontType, int currentX) {
  if (c == '\n') {
    return 0;
  }

  if (c == '\t') {
    return EditorUtil.nextTabStop(currentX, this) - currentX;
  }
  return EditorUtil.charWidth(c, fontType, this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:bigFile.java

示例5: getMinDrawingWidth

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
@Override
public int getMinDrawingWidth(@NotNull SoftWrapDrawingType drawingType) {
  if (myMinWidth < 0) {
    // We need to reserve a minimal space required for representing arrow before soft wrap-introduced line feed.
    myMinWidth = EditorUtil.charWidth('a', Font.PLAIN, myEditor);
  }
  return myMinWidth;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ArrowSoftWrapPainter.java

示例6: wrapPositionForTabbedTextWithoutOptimization

import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
private int wrapPositionForTabbedTextWithoutOptimization(@NotNull Editor editor,
                                                         @NotNull CharSequence text,
                                                         int spaceSize,
                                                         int startLineOffset,
                                                         int endLineOffset,
                                                         int targetRangeEndOffset)
{
  int width = 0;
  int x = 0;
  int newX;
  int symbolWidth;
  int result = Integer.MAX_VALUE;
  boolean wrapLine = false;
  for (int i = startLineOffset; i < Math.min(endLineOffset, targetRangeEndOffset); i++) {
    char c = text.charAt(i);
    switch (c) {
      case '\t':
        newX = EditorUtil.nextTabStop(x, editor);
        int diffInPixels = newX - x;
        symbolWidth = diffInPixels / spaceSize;
        if (diffInPixels % spaceSize > 0) {
          symbolWidth++;
        }
        break;
      default: newX = x + EditorUtil.charWidth(c, Font.PLAIN, editor); symbolWidth = 1;
    }
    if (width + symbolWidth + FormatConstants.RESERVED_LINE_WRAP_WIDTH_IN_COLUMNS >= myRightMargin
        && (Math.min(endLineOffset, targetRangeEndOffset) - i) >= FormatConstants.RESERVED_LINE_WRAP_WIDTH_IN_COLUMNS)
    {
      result = i - 1;
    }
    if (width + symbolWidth >= myRightMargin) {
      wrapLine = true;
      break;
    }
    x = newX;
    width += symbolWidth;
  }
  return wrapLine ? result : -1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:CodeFormatterFacade.java


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