當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript highlightedLabel.HighlightedLabel類代碼示例

本文整理匯總了TypeScript中vs/base/browser/ui/highlightedlabel/highlightedLabel.HighlightedLabel的典型用法代碼示例。如果您正苦於以下問題:TypeScript HighlightedLabel類的具體用法?TypeScript HighlightedLabel怎麽用?TypeScript HighlightedLabel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HighlightedLabel類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('escapeNewLines', () => {

		let highlights = [{ start: 0, end: 5 }, { start: 7, end: 9 }, { start: 11, end: 12 }];// before,after,after
		let escaped = HighlightedLabel.escapeNewLines('ACTION\r\n_TYPE2', highlights);
		assert.equal(escaped, 'ACTION\u23CE_TYPE2');
		assert.deepEqual(highlights, [{ start: 0, end: 5 }, { start: 6, end: 8 }, { start: 10, end: 11 }]);

		highlights = [{ start: 5, end: 9 }, { start: 11, end: 12 }];//overlap,after
		escaped = HighlightedLabel.escapeNewLines('ACTION\r\n_TYPE2', highlights);
		assert.equal(escaped, 'ACTION\u23CE_TYPE2');
		assert.deepEqual(highlights, [{ start: 5, end: 8 }, { start: 10, end: 11 }]);

	});
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:13,代碼來源:highlightedLabel.test.ts

示例2: suite

suite('HighlightedLabel', () => {
	let label: HighlightedLabel;

	setup(() => {
		label = new HighlightedLabel(document.createElement('div'), true);
	});

	teardown(() => {
		label.dispose();
		label = null;
	});

	test('empty label', function () {
		assert.equal(label.element.innerHTML, '');
	});

	test('no decorations', function () {
		label.set('hello');
		assert.equal(label.element.innerHTML, '<span>hello</span>');
	});

	test('escape html', function () {
		label.set('hel<lo');
		assert.equal(label.element.innerHTML, '<span>hel&lt;lo</span>');
	});

	test('everything highlighted', function () {
		label.set('hello', [{ start: 0, end: 5 }]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span>');
	});

	test('beginning highlighted', function () {
		label.set('hellothere', [{ start: 0, end: 5 }]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span><span>there</span>');
	});

	test('ending highlighted', function () {
		label.set('goodbye', [{ start: 4, end: 7 }]);
		assert.equal(label.element.innerHTML, '<span>good</span><span class="highlight">bye</span>');
	});

	test('middle highlighted', function () {
		label.set('foobarfoo', [{ start: 3, end: 6 }]);
		assert.equal(label.element.innerHTML, '<span>foo</span><span class="highlight">bar</span><span>foo</span>');
	});

	test('escapeNewLines', () => {

		let highlights = [{ start: 0, end: 5 }, { start: 7, end: 9 }, { start: 11, end: 12 }];// before,after,after
		let escaped = HighlightedLabel.escapeNewLines('ACTION\r\n_TYPE2', highlights);
		assert.equal(escaped, 'ACTION\u23CE_TYPE2');
		assert.deepEqual(highlights, [{ start: 0, end: 5 }, { start: 6, end: 8 }, { start: 10, end: 11 }]);

		highlights = [{ start: 5, end: 9 }, { start: 11, end: 12 }];//overlap,after
		escaped = HighlightedLabel.escapeNewLines('ACTION\r\n_TYPE2', highlights);
		assert.equal(escaped, 'ACTION\u23CE_TYPE2');
		assert.deepEqual(highlights, [{ start: 5, end: 8 }, { start: 10, end: 11 }]);

	});
});
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:60,代碼來源:highlightedLabel.test.ts

示例3: suite

suite('HighlightedLabel', () => {
	var label: HighlightedLabel;

	setup(() => {
		label = new HighlightedLabel(document.createElement('div'));
	});

	teardown(() => {
		label.dispose();
		label = null;
	});

	test('empty label', function() {
		assert.equal(label.element.innerHTML, '');
	});

	test('no decorations', function() {
		label.set('hello');
		assert.equal(label.element.innerHTML, '<span>hello</span>');
	});

	test('escape html', function() {
		label.set('hel<lo');
		assert.equal(label.element.innerHTML, '<span>hel&lt;lo</span>');
	});

	test('everything highlighted', function() {
		label.set('hello', [ { start: 0, end: 5 } ]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span>');
	});

	test('beginning highlighted', function() {
		label.set('hellothere', [ { start: 0, end: 5 } ]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span><span>there</span>');
	});

	test('ending highlighted', function() {
		label.set('goodbye', [ { start: 4, end: 7 } ]);
		assert.equal(label.element.innerHTML, '<span>good</span><span class="highlight">bye</span>');
	});

	test('middle highlighted', function() {
		label.set('foobarfoo', [ { start: 3, end: 6 } ]);
		assert.equal(label.element.innerHTML, '<span>foo</span><span class="highlight">bar</span><span>foo</span>');
	});
});
開發者ID:13572293130,項目名稱:vscode,代碼行數:46,代碼來源:highlightedLabel.test.ts

示例4: suite

suite("HighlightedLabel", () => {
	var label: HighlightedLabel;

	setup(() => {
		label = new HighlightedLabel(document.createElement('div'));
	});

	teardown(() => {
		label.dispose();
		label = null;
	});

	test("empty label", function() {
		assert.equal(label.element.innerHTML, "");
	});

	test("no decorations", function() {
		label.set("hello");
		assert.equal(label.element.innerHTML, "<span>hello</span>");
	});

	test("escape html", function() {
		label.set("hel<lo");
		assert.equal(label.element.innerHTML, "<span>hel&lt;lo</span>");
	});

	test("everything highlighted", function() {
		label.set("hello", [ { start: 0, end: 5 } ]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span>');
	});

	test("beginning highlighted", function() {
		label.set("hellothere", [ { start: 0, end: 5 } ]);
		assert.equal(label.element.innerHTML, '<span class="highlight">hello</span><span>there</span>');
	});

	test("ending highlighted", function() {
		label.set("goodbye", [ { start: 4, end: 7 } ]);
		assert.equal(label.element.innerHTML, '<span>good</span><span class="highlight">bye</span>');
	});

	test("middle highlighted", function() {
		label.set("foobarfoo", [ { start: 3, end: 6 } ]);
		assert.equal(label.element.innerHTML, '<span>foo</span><span class="highlight">bar</span><span>foo</span>');
	});
});
開發者ID:amamut,項目名稱:vscode,代碼行數:46,代碼來源:highlightedLabel.test.ts

示例5: function

	test('middle highlighted', function () {
		label.set('foobarfoo', [{ start: 3, end: 6 }]);
		assert.equal(label.element.innerHTML, '<span>foo</span><span class="highlight">bar</span><span>foo</span>');
	});
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:4,代碼來源:highlightedLabel.test.ts

示例6:

	teardown(() => {
		label.dispose();
		label = null;
	});
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:4,代碼來源:highlightedLabel.test.ts


注:本文中的vs/base/browser/ui/highlightedlabel/highlightedLabel.HighlightedLabel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。