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


TypeScript viewLineRenderer.renderLine函数代码示例

本文整理汇总了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('');
}
开发者ID:fs814,项目名称:vscode,代码行数:27,代码来源:colorizer.ts

示例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('');
}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:27,代码来源:colorizer.ts

示例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">&rarr;&nbsp;&nbsp;&nbsp;&middot;&middot;&middot;&middot;</span>',
			'<span class="token block declaration meta modifier object storage ts">export</span>',
			'<span class="token block declaration meta object ts">&nbsp;</span>',
			'<span class="token block declaration meta object storage type ts">class</span>',
			'<span class="token block declaration meta object ts">&nbsp;</span>',
			'<span class="token block class declaration entity meta name object ts">Game</span>',
			'<span class="token block declaration meta object ts">&nbsp;</span>',
			'<span class="token delimiter curly typescript">{</span>',
			'<span class="token block body declaration meta object ts">&nbsp;</span>',
			'<span class="token block body comment declaration line meta object ts">//&nbsp;</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">&middot;&middot;&middot;&middot;&middot;</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);
	});
开发者ID:elemongw,项目名称:vscode,代码行数:59,代码来源:viewLineRenderer.test.ts

示例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);
		};
	}
开发者ID:asotog,项目名称:vscode,代码行数:8,代码来源:viewLineParts.test.ts

示例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">&rarr;&nbsp;&nbsp;&nbsp;&middot;&middot;&middot;&middot;</span>',
			'<span class="token block declaration meta modifier object storage ts">export</span>',
			'<span class="token block declaration meta object ts">&nbsp;</span>',
			'<span class="token block declaration meta object storage type ts">class</span>',
			'<span class="token block declaration meta object ts">&nbsp;</span>',
			'<span class="token block class declaration entity meta name object ts">Game</span>',
			'<span class="token block declaration meta object ts">&nbsp;</span>',
			'<span class="token delimiter curly typescript">{</span>',
			'<span class="token block body declaration meta object ts">&nbsp;</span>',
			'<span class="token block body comment declaration line meta object ts">//&nbsp;</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">&middot;&middot;&middot;&middot;&middot;</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);
	});
开发者ID:ErickWendel,项目名称:vscode,代码行数:57,代码来源:viewLineRenderer.test.ts

示例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('');
}
开发者ID:ErickWendel,项目名称:vscode,代码行数:10,代码来源:colorizer.ts

示例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('');
	}
开发者ID:1424667164,项目名称:vscode,代码行数:10,代码来源:colorizer.ts

示例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;
	}
开发者ID:13572293130,项目名称:vscode,代码行数:11,代码来源:colorizer.ts

示例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);
	}
开发者ID:ErickWendel,项目名称:vscode,代码行数:12,代码来源:viewLineRenderer.test.ts


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