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


TypeScript WhitespaceComputer.getIdForWhitespaceIndex方法代碼示例

本文整理匯總了TypeScript中vs/editor/common/viewLayout/whitespaceComputer.WhitespaceComputer.getIdForWhitespaceIndex方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript WhitespaceComputer.getIdForWhitespaceIndex方法的具體用法?TypeScript WhitespaceComputer.getIdForWhitespaceIndex怎麽用?TypeScript WhitespaceComputer.getIdForWhitespaceIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/editor/common/viewLayout/whitespaceComputer.WhitespaceComputer的用法示例。


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

示例1: getWhitespaceViewportData

	/**
	 * Get a list of whitespaces that are positioned between `verticalOffset1` and `verticalOffset2`.
	 *
	 * @param verticalOffset1 The beginning of the viewport.
	 * @param verticalOffset2 The end of the viewport.
	 * @param deviceLineHeight The height, in pixels, for one rendered line.
	 * @return An array with all the whitespaces in the viewport. If no whitespace is in viewport, the array is empty.
	 */
	public getWhitespaceViewportData(verticalOffset1:number, verticalOffset2:number, deviceLineHeight:number): IViewWhitespaceViewportData[] {

		var startIndex = this.getWhitespaceIndexAtOrAfterVerticallOffset(verticalOffset1, deviceLineHeight);
		var endIndex = this.whitespaces.getCount() - 1;

		if (startIndex < 0) {
			return [];
		}

		var result: IViewWhitespaceViewportData[] = [],
			i:number,
			top:number,
			height:number;

		for (i = startIndex; i <= endIndex; i++) {
			top = this.getVerticalOffsetForWhitespaceIndex(i, deviceLineHeight);
			height = this.whitespaces.getHeightForWhitespaceIndex(i);
			if (top >= verticalOffset2) {
				break;
			}

			result.push({
				id: this.whitespaces.getIdForWhitespaceIndex(i),
				afterLineNumber: this.whitespaces.getAfterLineNumberForWhitespaceIndex(i),
				verticalOffset: top,
				height: height
			});
		}

		return result;
	}
開發者ID:1424667164,項目名稱:vscode,代碼行數:39,代碼來源:verticalObjects.ts

示例2: getWhitespaceAtVerticalOffset

	/**
	 * Get exactly the whitespace that is layouted at `verticalOffset`.
	 *
	 * @param verticalOffset The vertical offset.
	 * @param deviceLineHeight The height, in pixels, for one rendered line.
	 * @return Precisely the whitespace that is layouted at `verticaloffset` or null.
	 */
	public getWhitespaceAtVerticalOffset(verticalOffset:number, deviceLineHeight:number): IViewWhitespaceViewportData {

		var candidateIndex = this.getWhitespaceIndexAtOrAfterVerticallOffset(verticalOffset, deviceLineHeight);

		if (candidateIndex < 0) {
			return null;
		}

		if (candidateIndex >= this.whitespaces.getCount()) {
			return null;
		}

		var candidateTop = this.getVerticalOffsetForWhitespaceIndex(candidateIndex, deviceLineHeight);

		if (candidateTop > verticalOffset) {
			return null;
		}

		var candidateHeight = this.whitespaces.getHeightForWhitespaceIndex(candidateIndex);
		var candidateId = this.whitespaces.getIdForWhitespaceIndex(candidateIndex);
		var candidateAfterLineNumber = this.whitespaces.getAfterLineNumberForWhitespaceIndex(candidateIndex);

		return {
			id: candidateId,
			afterLineNumber: candidateAfterLineNumber,
			verticalOffset: candidateTop,
			height: candidateHeight
		};
	}
開發者ID:1424667164,項目名稱:vscode,代碼行數:36,代碼來源:verticalObjects.ts

示例3: getWhitespaceViewportData

	/**
	 * Get a list of whitespaces that are positioned between `verticalOffset1` and `verticalOffset2`.
	 *
	 * @param verticalOffset1 The beginning of the viewport.
	 * @param verticalOffset2 The end of the viewport.
	 * @return An array with all the whitespaces in the viewport. If no whitespace is in viewport, the array is empty.
	 */
	public getWhitespaceViewportData(verticalOffset1: number, verticalOffset2: number): IViewWhitespaceViewportData[] {
		verticalOffset1 = verticalOffset1 | 0;
		verticalOffset2 = verticalOffset2 | 0;

		let startIndex = this.getWhitespaceIndexAtOrAfterVerticallOffset(verticalOffset1);
		let endIndex = this._whitespaces.getCount() - 1;

		if (startIndex < 0) {
			return [];
		}

		let result: IViewWhitespaceViewportData[] = [];
		for (let i = startIndex; i <= endIndex; i++) {
			let top = this.getVerticalOffsetForWhitespaceIndex(i);
			let height = this._whitespaces.getHeightForWhitespaceIndex(i);
			if (top >= verticalOffset2) {
				break;
			}

			result.push({
				id: this._whitespaces.getIdForWhitespaceIndex(i),
				afterLineNumber: this._whitespaces.getAfterLineNumberForWhitespaceIndex(i),
				verticalOffset: top,
				height: height
			});
		}

		return result;
	}
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:36,代碼來源:linesLayout.ts

示例4: test

	test('WhitespaceComputer Bug', () => {
		var whitespaceComputer = new WhitespaceComputer();

		var a = whitespaceComputer.insertWhitespace(0, 0, 1);
		var b = whitespaceComputer.insertWhitespace(7, 0, 1);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), b); // 7

		var c = whitespaceComputer.insertWhitespace(3, 0, 1);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), b); // 7

		var d = whitespaceComputer.insertWhitespace(2, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7

		var e = whitespaceComputer.insertWhitespace(8, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8

		var f = whitespaceComputer.insertWhitespace(11, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), f); // 11

		var g = whitespaceComputer.insertWhitespace(10, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), g); // 10
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(6), f); // 11

		var h = whitespaceComputer.insertWhitespace(0, 0, 1);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), h); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(6), g); // 10
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(7), f); // 11
	});
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:55,代碼來源:whitespaceComputer.test.ts

示例5: test

	test('WhitespaceComputer Bug', () => {
		let whitespaceComputer = new WhitespaceComputer();

		let a = whitespaceComputer.insertWhitespace(0, 0, 1, 0);
		let b = whitespaceComputer.insertWhitespace(7, 0, 1, 0);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), b); // 7

		let c = whitespaceComputer.insertWhitespace(3, 0, 1, 0);

		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), b); // 7

		let d = whitespaceComputer.insertWhitespace(2, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7

		let e = whitespaceComputer.insertWhitespace(8, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8

		let f = whitespaceComputer.insertWhitespace(11, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), f); // 11

		let g = whitespaceComputer.insertWhitespace(10, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), g); // 10
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(6), f); // 11

		let h = whitespaceComputer.insertWhitespace(0, 0, 1, 0);
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(0), a); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(1), h); // 0
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(2), d); // 2
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(3), c); // 3
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(4), b); // 7
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(5), e); // 8
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(6), g); // 10
		assert.equal(whitespaceComputer.getIdForWhitespaceIndex(7), f); // 11
	});
開發者ID:AllureFer,項目名稱:vscode,代碼行數:55,代碼來源:whitespaceComputer.test.ts


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