本文整理汇总了TypeScript中vs/editor/common/core/stringBuilder.IStringBuilder.appendASCII方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IStringBuilder.appendASCII方法的具体用法?TypeScript IStringBuilder.appendASCII怎么用?TypeScript IStringBuilder.appendASCII使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/core/stringBuilder.IStringBuilder
的用法示例。
在下文中一共展示了IStringBuilder.appendASCII方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _renderLine
/**
* This function is on purpose not split up into multiple functions to allow runtime type inference (i.e. performance reasons).
* Notice how all the needed data is fully resolved and passed in (i.e. no other calls).
*/
function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): RenderLineOutput {
const fontIsMonospace = input.fontIsMonospace;
const containsForeignElements = input.containsForeignElements;
const lineContent = input.lineContent;
const len = input.len;
const isOverflowing = input.isOverflowing;
const parts = input.parts;
const tabSize = input.tabSize;
const containsRTL = input.containsRTL;
const spaceWidth = input.spaceWidth;
const renderWhitespace = input.renderWhitespace;
const renderControlCharacters = input.renderControlCharacters;
const characterMapping = new CharacterMapping(len + 1, parts.length);
let charIndex = 0;
let tabsCharDelta = 0;
let charOffsetInPart = 0;
let prevPartContentCnt = 0;
let partAbsoluteOffset = 0;
sb.appendASCIIString('<span>');
for (let partIndex = 0, tokensLen = parts.length; partIndex < tokensLen; partIndex++) {
partAbsoluteOffset += prevPartContentCnt;
const part = parts[partIndex];
const partEndIndex = part.endIndex;
const partType = part.type;
const partRendersWhitespace = (renderWhitespace !== RenderWhitespace.None && (partType.indexOf('vs-whitespace') >= 0));
charOffsetInPart = 0;
sb.appendASCIIString('<span class="');
sb.appendASCIIString(partType);
sb.appendASCII(CharCode.DoubleQuote);
if (partRendersWhitespace) {
let partContentCnt = 0;
{
let _charIndex = charIndex;
let _tabsCharDelta = tabsCharDelta;
let _charOffsetInPart = charOffsetInPart;
for (; _charIndex < partEndIndex; _charIndex++) {
const charCode = lineContent.charCodeAt(_charIndex);
if (charCode === CharCode.Tab) {
let insertSpacesCount = tabSize - (_charIndex + _tabsCharDelta) % tabSize;
_tabsCharDelta += insertSpacesCount - 1;
_charOffsetInPart += insertSpacesCount - 1;
partContentCnt += insertSpacesCount;
} else {
partContentCnt++;
}
_charOffsetInPart++;
}
}
if (!fontIsMonospace) {
const partIsOnlyWhitespace = (partType === 'vs-whitespace');
if (partIsOnlyWhitespace || !containsForeignElements) {
sb.appendASCIIString(' style="width:');
sb.appendASCIIString(String(spaceWidth * partContentCnt));
sb.appendASCIIString('px"');
}
}
sb.appendASCII(CharCode.GreaterThan);
for (; charIndex < partEndIndex; charIndex++) {
characterMapping.setPartData(charIndex, partIndex, charOffsetInPart, partAbsoluteOffset);
const charCode = lineContent.charCodeAt(charIndex);
if (charCode === CharCode.Tab) {
let insertSpacesCount = tabSize - (charIndex + tabsCharDelta) % tabSize;
tabsCharDelta += insertSpacesCount - 1;
charOffsetInPart += insertSpacesCount - 1;
if (insertSpacesCount > 0) {
sb.write1(0x2192); // →
insertSpacesCount--;
}
while (insertSpacesCount > 0) {
sb.write1(0xA0); //
insertSpacesCount--;
}
} else {
// must be CharCode.Space
sb.write1(0xb7); // ·
}
charOffsetInPart++;
}
prevPartContentCnt = partContentCnt;
//.........这里部分代码省略.........