本文整理汇总了TypeScript中vs/editor/common/viewLayout/viewLineRenderer.renderLine函数的典型用法代码示例。如果您正苦于以下问题:TypeScript renderLine函数的具体用法?TypeScript renderLine怎么用?TypeScript renderLine使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了renderLine函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _actualColorize
function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): string {
let html: string[] = [];
let state = tokenizationSupport.getInitialState();
let colorMap = TokenizationRegistry.getColorMap();
for (let i = 0, length = lines.length; i < length; i++) {
let line = lines[i];
let tokenizeResult = tokenizationSupport.tokenize2(line, state, 0);
let lineTokens = new LineTokens(colorMap, tokenizeResult.tokens, line);
let renderResult = renderLine(new RenderLineInput(
line,
tabSize,
0,
-1,
'none',
false,
new LineParts(lineTokens.inflate(), line.length + 1)
));
html = html.concat(renderResult.output);
html.push('<br/>');
state = tokenizeResult.endState;
}
return html.join('');
}
示例2: _actualColorize
function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): string {
let html: string[] = [];
let state = tokenizationSupport.getInitialState();
for (let i = 0, length = lines.length; i < length; i++) {
let line = lines[i];
let tokenizeResult = tokenizationSupport.tokenize(line, state);
let renderResult = renderLine(new RenderLineInput(
line,
tabSize,
0,
-1,
'none',
false,
new LineParts(tokenizeResult.tokens.map(t => new ViewLineToken(t.startIndex, t.type)), line.length + 1)
));
html = html.concat(renderResult.output);
html.push('<br/>');
state = tokenizeResult.endState;
}
return html.join('');
}
示例3: test
test('typical line', () => {
let lineText = '\t export class Game { // http://test.com ';
let lineParts = [
createPart(0, 'block meta ts leading whitespace'),
createPart(5, 'block declaration meta modifier object storage ts'),
createPart(11, 'block declaration meta object ts'),
createPart(12, 'block declaration meta object storage type ts'),
createPart(17, 'block declaration meta object ts'),
createPart(18, 'block class declaration entity meta name object ts'),
createPart(22, 'block declaration meta object ts'),
createPart(23, 'delimiter curly typescript'),
createPart(24, 'block body declaration meta object ts'),
createPart(25, 'block body comment declaration line meta object ts'),
createPart(28, 'block body comment declaration line meta object ts detected-link'),
createPart(43, 'block body comment declaration line meta object ts trailing whitespace'),
];
let expectedOutput = [
'<span class="token block meta ts leading whitespace" style="width:80px">→ ····</span>',
'<span class="token block declaration meta modifier object storage ts">export</span>',
'<span class="token block declaration meta object ts"> </span>',
'<span class="token block declaration meta object storage type ts">class</span>',
'<span class="token block declaration meta object ts"> </span>',
'<span class="token block class declaration entity meta name object ts">Game</span>',
'<span class="token block declaration meta object ts"> </span>',
'<span class="token delimiter curly typescript">{</span>',
'<span class="token block body declaration meta object ts"> </span>',
'<span class="token block body comment declaration line meta object ts">// </span>',
'<span class="token block body comment declaration line meta object ts detected-link">http://test.com</span>',
'<span class="token block body comment declaration line meta object ts trailing whitespace" style="width:50px">·····</span>'
].join('');
let expectedOffsetsArr = [
[0, 4, 5, 6, 7],
[0, 1, 2, 3, 4, 5],
[0],
[0, 1, 2, 3, 4],
[0],
[0, 1, 2, 3],
[0],
[0],
[0],
[0, 1, 2],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
[0, 1, 2, 3, 4, 5],
];
let expectedOffsets = expectedOffsetsArr.reduce((prev, curr) => prev.concat(curr), []);
let _actual = renderLine(new RenderLineInput(
lineText,
4,
10,
-1,
'boundary',
false,
new LineParts(lineParts, lineText.length + 1)
));
assert.equal(_actual.output, '<span>' + expectedOutput + '</span>');
assert.deepEqual(_actual.charOffsetInPart, expectedOffsets);
});
示例4: createTestGetColumnOfLinePartOffset
function createTestGetColumnOfLinePartOffset(lineContent: string, tabSize: number, parts: ViewLineToken[]): (partIndex: number, partLength: number, offset: number, expected: number) => void {
let renderLineOutput = renderLine(new RenderLineInput(lineContent, tabSize, 10, -1, 'none', false, parts));
return (partIndex: number, partLength: number, offset: number, expected: number) => {
let actual = getColumnOfLinePartOffset(-1, parts, lineContent.length + 1, renderLineOutput.charOffsetInPart, partIndex, partLength, offset);
assert.equal(actual, expected, 'getColumnOfLinePartOffset for ' + partIndex + ' @ ' + offset);
};
}
示例5: test
test('typical line', () => {
let lineText = '\t export class Game { // http://test.com ';
let lineParts = [
createPart( 0, 'block meta ts leading whitespace'),
createPart( 5, 'block declaration meta modifier object storage ts'),
createPart(11, 'block declaration meta object ts'),
createPart(12, 'block declaration meta object storage type ts'),
createPart(17, 'block declaration meta object ts'),
createPart(18, 'block class declaration entity meta name object ts'),
createPart(22, 'block declaration meta object ts'),
createPart(23, 'delimiter curly typescript'),
createPart(24, 'block body declaration meta object ts'),
createPart(25, 'block body comment declaration line meta object ts'),
createPart(28, 'block body comment declaration line meta object ts detected-link'),
createPart(43, 'block body comment declaration line meta object ts trailing whitespace'),
];
let expectedOutput = [
'<span class="token block meta ts leading whitespace">→ ····</span>',
'<span class="token block declaration meta modifier object storage ts">export</span>',
'<span class="token block declaration meta object ts"> </span>',
'<span class="token block declaration meta object storage type ts">class</span>',
'<span class="token block declaration meta object ts"> </span>',
'<span class="token block class declaration entity meta name object ts">Game</span>',
'<span class="token block declaration meta object ts"> </span>',
'<span class="token delimiter curly typescript">{</span>',
'<span class="token block body declaration meta object ts"> </span>',
'<span class="token block body comment declaration line meta object ts">// </span>',
'<span class="token block body comment declaration line meta object ts detected-link">http://test.com</span>',
'<span class="token block body comment declaration line meta object ts trailing whitespace">·····</span>'
].join('');
let expectedOffsetsArr = [
[0, 4, 5, 6, 7],
[0, 1, 2, 3, 4, 5],
[0],
[0, 1, 2, 3, 4],
[0],
[0, 1, 2, 3],
[0],
[0],
[0],
[0, 1, 2],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
[0, 1, 2, 3, 4, 5],
];
let expectedOffsets = expectedOffsetsArr.reduce((prev, curr) => prev.concat(curr), []);
let _actual = renderLine({
lineContent: lineText,
tabSize: 4,
stopRenderingLineAfter: -1,
renderWhitespace: true,
parts: lineParts
});
assert.equal(_actual.output.join(''), '<span>' + expectedOutput + '</span>');
assert.deepEqual(_actual.charOffsetInPart, expectedOffsets);
});
示例6: colorizeLine
export function colorizeLine(line:string, tokens:EditorCommon.ILineToken[], tabSize:number = 4): string {
var renderResult = renderLine({
lineContent: line,
parts: tokens,
stopRenderingLineAfter: -1,
renderWhitespace: false,
tabSize: tabSize
});
return renderResult.output.join('');
}
示例7: colorizeLine
public static colorizeLine(line:string, tokens:ILineToken[], tabSize:number = 4): string {
var renderResult = renderLine({
lineContent: line,
parts: tokens,
stopRenderingLineAfter: -1,
renderWhitespace: false,
tabSize: tabSize
});
return renderResult.output.join('');
}
示例8: colorizeLine
public static colorizeLine(line:string, tokens:ViewLineToken[], tabSize:number = 4): string {
var renderResult = renderLine(new RenderLineInput(
line,
tabSize,
0,
-1,
false,
tokens
));
return renderResult.output;
}
示例9: assertCharacterReplacement
function assertCharacterReplacement(lineContent:string, tabSize:number, expected:string, expectedCharOffsetInPart: number[]): void {
let _actual = renderLine({
lineContent: lineContent,
tabSize: tabSize,
stopRenderingLineAfter: -1,
renderWhitespace: false,
parts: [createPart(0, '')]
});
assert.equal(_actual.output.join(''), '<span><span class="token ">' + expected + '</span></span>');
assert.deepEqual(_actual.charOffsetInPart, expectedCharOffsetInPart);
}