本文整理汇总了TypeScript中vs/base/common/strings.isHighSurrogate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isHighSurrogate函数的具体用法?TypeScript isHighSurrogate怎么用?TypeScript isHighSurrogate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isHighSurrogate函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: isHighSurrogate
public static isHighSurrogate(model: ICursorSimpleModel, lineNumber: number, charOffset: number): boolean {
let lineContent = model.getLineContent(lineNumber);
if (charOffset < 0 || charOffset >= lineContent.length) {
return false;
}
return strings.isHighSurrogate(lineContent.charCodeAt(charOffset));
}
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:7,代码来源:cursorCommon.ts
示例2: splitLargeTokens
/**
* See https://github.com/Microsoft/vscode/issues/6885.
* It appears that having very large spans causes very slow reading of character positions.
* So here we try to avoid that.
*/
function splitLargeTokens(lineContent: string, tokens: LinePart[]): LinePart[] {
let lastTokenEndIndex = 0;
let result: LinePart[] = [], resultLen = 0;
for (let i = 0, len = tokens.length; i < len; i++) {
const token = tokens[i];
const tokenEndIndex = token.endIndex;
let diff = (tokenEndIndex - lastTokenEndIndex);
if (diff > Constants.LongToken) {
const tokenType = token.type;
const piecesCount = Math.ceil(diff / Constants.LongToken);
for (let j = 1; j < piecesCount; j++) {
let pieceEndIndex = lastTokenEndIndex + (j * Constants.LongToken);
let lastCharInPiece = lineContent.charCodeAt(pieceEndIndex - 1);
if (strings.isHighSurrogate(lastCharInPiece)) {
// Don't cut in the middle of a surrogate pair
pieceEndIndex--;
}
result[resultLen++] = new LinePart(pieceEndIndex, tokenType);
}
result[resultLen++] = new LinePart(tokenEndIndex, tokenType);
} else {
result[resultLen++] = token;
}
lastTokenEndIndex = tokenEndIndex;
}
return result;
}
开发者ID:elibarzilay,项目名称:vscode,代码行数:33,代码来源:viewLineRenderer.ts
示例3: _prepareRender
private _prepareRender(ctx: RenderingContext): ViewCursorRenderData {
let textContent = '';
let textContentClassName = '';
if (this._cursorStyle === TextEditorCursorStyle.Line || this._cursorStyle === TextEditorCursorStyle.LineThin) {
const visibleRange = ctx.visibleRangeForPosition(this._position);
if (!visibleRange) {
// Outside viewport
return null;
}
let width: number;
if (this._cursorStyle === TextEditorCursorStyle.Line) {
width = dom.computeScreenAwareSize(this._lineCursorWidth > 0 ? this._lineCursorWidth : 2);
if (width > 2) {
const lineContent = this._context.model.getLineContent(this._position.lineNumber);
textContent = lineContent.charAt(this._position.column - 1);
}
} else {
width = dom.computeScreenAwareSize(1);
}
let left = visibleRange.left;
if (width >= 2 && left >= 1) {
// try to center cursor
left -= 1;
}
const top = ctx.getVerticalOffsetForLineNumber(this._position.lineNumber) - ctx.bigNumbersDelta;
return new ViewCursorRenderData(top, left, width, this._lineHeight, textContent, textContentClassName);
}
const visibleRangeForCharacter = ctx.linesVisibleRangesForRange(new Range(this._position.lineNumber, this._position.column, this._position.lineNumber, this._position.column + 1), false);
if (!visibleRangeForCharacter || visibleRangeForCharacter.length === 0 || visibleRangeForCharacter[0].ranges.length === 0) {
// Outside viewport
return null;
}
const range = visibleRangeForCharacter[0].ranges[0];
const width = range.width < 1 ? this._typicalHalfwidthCharacterWidth : range.width;
if (this._cursorStyle === TextEditorCursorStyle.Block) {
const lineData = this._context.model.getViewLineData(this._position.lineNumber);
textContent = lineData.content.charAt(this._position.column - 1);
if (strings.isHighSurrogate(lineData.content.charCodeAt(this._position.column - 1))) {
textContent += lineData.content.charAt(this._position.column);
}
const tokenIndex = lineData.tokens.findTokenIndexAtOffset(this._position.column - 1);
textContentClassName = lineData.tokens.getClassName(tokenIndex);
}
let top = ctx.getVerticalOffsetForLineNumber(this._position.lineNumber) - ctx.bigNumbersDelta;
let height = this._lineHeight;
// Underline might interfere with clicking
if (this._cursorStyle === TextEditorCursorStyle.Underline || this._cursorStyle === TextEditorCursorStyle.UnderlineThin) {
top += this._lineHeight - 2;
height = 2;
}
return new ViewCursorRenderData(top, range.left, width, height, textContent, textContentClassName);
}
开发者ID:ramesius,项目名称:vscode,代码行数:60,代码来源:viewCursor.ts
示例4: normalize
/**
* Normalize line decorations. Overlapping decorations will generate multiple segments
*/
public static normalize(lineContent: string, lineDecorations: LineDecoration[]): DecorationSegment[] {
if (lineDecorations.length === 0) {
return [];
}
let result: DecorationSegment[] = [];
let stack = new Stack();
let nextStartOffset = 0;
for (let i = 0, len = lineDecorations.length; i < len; i++) {
let d = lineDecorations[i];
let startColumn = d.startColumn;
let endColumn = d.endColumn;
let className = d.className;
// If the position would end up in the middle of a high-low surrogate pair, we move it to before the pair
if (startColumn > 1) {
const charCodeBefore = lineContent.charCodeAt(startColumn - 2);
if (strings.isHighSurrogate(charCodeBefore)) {
startColumn--;
}
}
if (endColumn > 1) {
const charCodeBefore = lineContent.charCodeAt(endColumn - 2);
if (strings.isHighSurrogate(charCodeBefore)) {
endColumn--;
}
}
let currentStartOffset = startColumn - 1;
let currentEndOffset = endColumn - 2;
nextStartOffset = stack.consumeLowerThan(currentStartOffset, nextStartOffset, result);
if (stack.count === 0) {
nextStartOffset = currentStartOffset;
}
stack.insert(currentEndOffset, className);
}
stack.consumeLowerThan(Constants.MAX_SAFE_SMALL_INTEGER, nextStartOffset, result);
return result;
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:49,代码来源:lineDecorations.ts
示例5: write1
public write1(charCode: number): void {
const remainingSpace = this._capacity - this._bufferLength;
if (remainingSpace <= 1) {
if (remainingSpace === 0 || strings.isHighSurrogate(charCode)) {
this._flushBuffer();
}
}
this._buffer[this._bufferLength++] = charCode;
}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:11,代码来源:stringBuilder.ts
示例6: positionRightOf
private positionRightOf(start: IPosition, model: ITextModel): Position {
let column = start.column;
let lineNumber = start.lineNumber;
if (column < model.getLineMaxColumn(lineNumber)) {
if (isHighSurrogate(model.getLineContent(lineNumber).charCodeAt(column - 1))) {
// character after column is a high surrogate
column = column + 2;
} else {
column = column + 1;
}
} else if (lineNumber < model.getLineCount()) {
lineNumber = lineNumber + 1;
column = 0;
}
return new Position(lineNumber, column);
}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:18,代码来源:transpose.ts
示例7: isHighSurrogate
function isHighSurrogate(model: ICursorMoveHelperModel, lineNumber: number, column: number) {
return strings.isHighSurrogate(model.getLineContent(lineNumber).charCodeAt(column - 1));
}
开发者ID:asotog,项目名称:vscode,代码行数:3,代码来源:cursorMoveHelper.ts
注:本文中的vs/base/common/strings.isHighSurrogate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论