本文整理汇总了Java中com.intellij.openapi.editor.ex.util.EditorUtil.nextTabStop方法的典型用法代码示例。如果您正苦于以下问题:Java EditorUtil.nextTabStop方法的具体用法?Java EditorUtil.nextTabStop怎么用?Java EditorUtil.nextTabStop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.ex.util.EditorUtil
的用法示例。
在下文中一共展示了EditorUtil.nextTabStop方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例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);
}
示例4: textWidth
import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
@Override
public int textWidth(int start, int end, int fontType, int x) {
CharSequence text = myEditor.getDocument().getImmutableCharSequence();
int startToUse = start;
for (int i = end - 1; i >= start; i--) {
if (text.charAt(i) == '\n') {
startToUse = i + 1;
break;
}
}
int result = 0;
// Symbol width retrieval is detected to be a bottleneck, hence, we perform a caching here in assumption that every representation
// helper is editor-bound and cache size is not too big.
mySharedKey.fontType = fontType;
for (int i = startToUse; i < end; i++) {
char c = text.charAt(i);
if (c != '\t') {
mySharedKey.c = c;
result += charWidth(c);
continue;
}
result += EditorUtil.nextTabStop(x + result, myEditor) - result - x;
}
return result;
}
示例5: calculateNewX
import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
private int calculateNewX(char c) {
if (c == '\t') {
return EditorUtil.nextTabStop(myContext.currentPosition.x, myEditor);
}
else {
return myContext.currentPosition.x + SoftWrapModelImpl.getEditorTextRepresentationHelper(myEditor).charWidth(c, myContext.fontType);
}
}
示例6: update
import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
public void update(int logicalLine, int spaceWidth, int plainSpaceWidth) {
Document document = myEditor.getDocument();
int startLineOffset;
if (logicalLine >= document.getLineCount()) {
startLineOffset = endLineOffset = document.getTextLength();
}
else {
startLineOffset = document.getLineStartOffset(logicalLine);
endLineOffset = document.getLineEndOffset(logicalLine);
}
CharSequence text = document.getCharsSequence();
indentInColumns = 0;
indentInPixels = 0;
nonWhiteSpaceSymbolOffset = -1;
for (int i = startLineOffset; i < endLineOffset; i++) {
char c = text.charAt(i);
switch (c) {
case ' ': indentInColumns += 1; indentInPixels += spaceWidth; break;
case '\t':
int x = EditorUtil.nextTabStop(indentInPixels, myEditor);
indentInColumns += calculateWidthInColumns(c, x - indentInPixels, plainSpaceWidth);
indentInPixels = x;
break;
default: nonWhiteSpaceSymbolOffset = i; return;
}
}
}
示例7: 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;
}
示例8: drawTabbedString
import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
private int drawTabbedString(@NotNull Graphics g,
CharSequence text,
int start,
int end,
int x,
int y,
@Nullable Color effectColor,
EffectType effectType,
@JdkConstants.FontStyle int fontType,
Color fontColor,
@NotNull final Rectangle clip,
WhitespacePaintingStrategy context) {
int xStart = x;
for (int i = start; i < end; i++) {
if (text.charAt(i) != '\t') continue;
x = drawTablessString(text, start, i, g, x, y, fontType, fontColor, clip, context);
int x1 = EditorUtil.nextTabStop(x, this);
drawTabPlacer(g, y, x, x1, i, context);
x = x1;
start = i + 1;
}
x = drawTablessString(text, start, end, g, x, y, fontType, fontColor, clip, context);
if (effectColor != null) {
final Color savedColor = g.getColor();
// myBorderEffect.flushIfCantProlong(g, this, effectType, effectColor);
int xEnd = x;
if (xStart < clip.x && xEnd < clip.x || xStart > clip.x + clip.width && xEnd > clip.x + clip.width) {
return x;
}
if (xEnd > clip.x + clip.width) {
xEnd = clip.x + clip.width;
}
if (xStart < clip.x) {
xStart = clip.x;
}
if (effectType == EffectType.LINE_UNDERSCORE) {
g.setColor(effectColor);
UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
g.setColor(savedColor);
}
else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
g.setColor(effectColor);
drawBoldLineUnderScore(g, xStart, y, xEnd-xStart);
g.setColor(savedColor);
}
else if (effectType == EffectType.STRIKEOUT) {
g.setColor(effectColor);
int y1 = y - getCharHeight() / 2;
UIUtil.drawLine(g, xStart, y1, xEnd, y1);
g.setColor(savedColor);
}
else if (effectType == EffectType.WAVE_UNDERSCORE) {
g.setColor(effectColor);
UIUtil.drawWave((Graphics2D)g, new Rectangle(xStart, y+1, xEnd - xStart, getDescent() - 1));
g.setColor(savedColor);
}
else if (effectType == EffectType.BOLD_DOTTED_LINE) {
final Color bgColor = getBackgroundColor();
final int dottedAt = SystemInfo.isMac ? y : y + 1;
UIUtil.drawBoldDottedLine((Graphics2D)g, xStart, xEnd, dottedAt, bgColor, effectColor, false);
}
}
return x;
}
示例9: drawTabbedString
import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
private int drawTabbedString(@NotNull Graphics g,
CharSequence text,
int start,
int end,
int x,
int y,
@Nullable Color effectColor,
EffectType effectType,
@JdkConstants.FontStyle int fontType,
Color fontColor,
@NotNull final Rectangle clip,
WhitespacePaintingStrategy context) {
int xStart = x;
for (int i = start; i < end; i++) {
if (text.charAt(i) != '\t') continue;
x = drawTablessString(text, start, i, g, x, y, fontType, fontColor, clip, context);
int x1 = EditorUtil.nextTabStop(x, this);
drawTabPlacer(g, y, x, x1, i, context);
x = x1;
start = i + 1;
}
x = drawTablessString(text, start, end, g, x, y, fontType, fontColor, clip, context);
if (effectColor != null) {
final Color savedColor = g.getColor();
// myBorderEffect.flushIfCantProlong(g, this, effectType, effectColor);
int xEnd = x;
if (xStart < clip.x && xEnd < clip.x || xStart > clip.x + clip.width && xEnd > clip.x + clip.width) {
return x;
}
if (xEnd > clip.x + clip.width) {
xEnd = clip.x + clip.width;
}
if (xStart < clip.x) {
xStart = clip.x;
}
if (effectType == EffectType.LINE_UNDERSCORE) {
g.setColor(effectColor);
UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
g.setColor(savedColor);
}
else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
g.setColor(effectColor);
drawBoldLineUnderScore(g, xStart, y, xEnd - xStart);
g.setColor(savedColor);
}
else if (effectType == EffectType.STRIKEOUT) {
g.setColor(effectColor);
int y1 = y - getCharHeight() / 2;
UIUtil.drawLine(g, xStart, y1, xEnd, y1);
g.setColor(savedColor);
}
else if (effectType == EffectType.WAVE_UNDERSCORE) {
g.setColor(effectColor);
UIUtil.drawWave((Graphics2D)g, new Rectangle(xStart, y + 1, xEnd - xStart, getDescent() - 1));
g.setColor(savedColor);
}
else if (effectType == EffectType.BOLD_DOTTED_LINE) {
final Color bgColor = getBackgroundColor();
final int dottedAt = SystemInfo.isMac ? y : y + 1;
UIUtil.drawBoldDottedLine((Graphics2D)g, xStart, xEnd, dottedAt, bgColor, effectColor, false);
}
}
return x;
}
示例10: getNextTabStop
import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
private float getNextTabStop(float x) {
return EditorUtil.nextTabStop((int)x, myView.getPlainSpaceWidth(), myView.getTabSize());
}
示例11: drawTabbedString
import com.intellij.openapi.editor.ex.util.EditorUtil; //导入方法依赖的package包/类
private int drawTabbedString(@NotNull Graphics g,
CharSequence text,
int start,
int end,
int x,
int y,
@Nullable Color effectColor,
EffectType effectType,
@JdkConstants.FontStyle int fontType,
Color fontColor,
@NotNull final Rectangle clip,
WhitespacePaintingStrategy context) {
int xStart = x;
for (int i = start; i < end; i++) {
if (text.charAt(i) != '\t') continue;
x = drawTablessString(text, start, i, g, x, y, fontType, fontColor, clip, context);
int x1 = EditorUtil.nextTabStop(x, this);
drawTabPlacer(g, y, x, x1, i, context);
x = x1;
start = i + 1;
}
x = drawTablessString(text, start, end, g, x, y, fontType, fontColor, clip, context);
if (effectColor != null) {
final Color savedColor = g.getColor();
// myBorderEffect.flushIfCantProlong(g, this, effectType, effectColor);
int xEnd = x;
if (xStart < clip.x && xEnd < clip.x || xStart > clip.x + clip.width && xEnd > clip.x + clip.width) {
return x;
}
if (xEnd > clip.x + clip.width) {
xEnd = clip.x + clip.width;
}
if (xStart < clip.x) {
xStart = clip.x;
}
if (effectType == EffectType.LINE_UNDERSCORE) {
g.setColor(effectColor);
UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
g.setColor(savedColor);
}
else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
g.setColor(effectColor);
drawBoldLineUnderScore(g, xStart, y, xEnd-xStart);
g.setColor(savedColor);
}
else if (effectType == EffectType.STRIKEOUT) {
g.setColor(effectColor);
int y1 = y - getCharHeight() / 2;
UIUtil.drawLine(g, xStart, y1, xEnd, y1);
g.setColor(savedColor);
}
else if (effectType == EffectType.WAVE_UNDERSCORE) {
g.setColor(effectColor);
UIUtil.drawWave((Graphics2D)g, new Rectangle(xStart, y+1, xEnd - xStart, getDescent() - 1));
g.setColor(savedColor);
}
else if (effectType == EffectType.BOLD_DOTTED_LINE) {
final Color bgColor = getBackgroundColor();
final int dottedAt = SystemInfo.isMac ? y : y + 1;
UIUtil.drawBoldDottedLine((Graphics2D)g, xStart, xEnd, dottedAt, bgColor, effectColor, false);
}
}
return x;
}