当前位置: 首页>>代码示例>>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;未经允许,请勿转载。