當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。