本文整理匯總了TypeScript中vs/editor/common/viewLayout/whitespaceComputer.WhitespaceComputer.changeWhitespace方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript WhitespaceComputer.changeWhitespace方法的具體用法?TypeScript WhitespaceComputer.changeWhitespace怎麽用?TypeScript WhitespaceComputer.changeWhitespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/viewLayout/whitespaceComputer.WhitespaceComputer
的用法示例。
在下文中一共展示了WhitespaceComputer.changeWhitespace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: changeWhitespace
/**
* Change the height of an existing whitespace
*
* @param id The whitespace to change
* @param newHeightInPx The new height of the whitespace, in pixels
* @return Returns true if the whitespace is found and if the new height is different than the old height
*/
public changeWhitespace(id:number, newHeightInPx:number): boolean {
return this.whitespaces.changeWhitespace(id, newHeightInPx);
}
示例2: test
test('WhitespaceComputer', () => {
var whitespaceComputer = new WhitespaceComputer();
// Insert a whitespace after line number 2, of height 10
var a = whitespaceComputer.insertWhitespace(2, 0, 10);
// whitespaces: a(2, 10)
assert.equal(whitespaceComputer.getCount(), 1);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 2);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 10);
assert.equal(whitespaceComputer.getAccumulatedHeight(0), 10);
assert.equal(whitespaceComputer.getTotalHeight(), 10);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 0);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 0);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 10);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 10);
// Insert a whitespace again after line number 2, of height 20
var b = whitespaceComputer.insertWhitespace(2, 0, 20);
// whitespaces: a(2, 10), b(2, 20)
assert.equal(whitespaceComputer.getCount(), 2);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 2);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 10);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 2);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 20);
assert.equal(whitespaceComputer.getAccumulatedHeight(0), 10);
assert.equal(whitespaceComputer.getAccumulatedHeight(1), 30);
assert.equal(whitespaceComputer.getTotalHeight(), 30);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 0);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 0);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 30);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 30);
// Change last inserted whitespace height to 30
whitespaceComputer.changeWhitespace(b, 30);
// whitespaces: a(2, 10), b(2, 30)
assert.equal(whitespaceComputer.getCount(), 2);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 2);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 10);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 2);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 30);
assert.equal(whitespaceComputer.getAccumulatedHeight(0), 10);
assert.equal(whitespaceComputer.getAccumulatedHeight(1), 40);
assert.equal(whitespaceComputer.getTotalHeight(), 40);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 0);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 0);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 40);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 40);
// Remove last inserted whitespace
whitespaceComputer.removeWhitespace(b);
// whitespaces: a(2, 10)
assert.equal(whitespaceComputer.getCount(), 1);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 2);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 10);
assert.equal(whitespaceComputer.getAccumulatedHeight(0), 10);
assert.equal(whitespaceComputer.getTotalHeight(), 10);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 0);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 0);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 10);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 10);
// Add a whitespace before the first line of height 50
b = whitespaceComputer.insertWhitespace(0, 0, 50);
// whitespaces: b(0, 50), a(2, 10)
assert.equal(whitespaceComputer.getCount(), 2);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 0);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 50);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 2);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 10);
assert.equal(whitespaceComputer.getAccumulatedHeight(0), 50);
assert.equal(whitespaceComputer.getAccumulatedHeight(1), 60);
assert.equal(whitespaceComputer.getTotalHeight(), 60);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 50);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 50);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 60);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 60);
// Add a whitespace after line 4 of height 20
whitespaceComputer.insertWhitespace(4, 0, 20);
// whitespaces: b(0, 50), a(2, 10), c(4, 20)
assert.equal(whitespaceComputer.getCount(), 3);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(0), 0);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(0), 50);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(1), 2);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(1), 10);
assert.equal(whitespaceComputer.getAfterLineNumberForWhitespaceIndex(2), 4);
assert.equal(whitespaceComputer.getHeightForWhitespaceIndex(2), 20);
assert.equal(whitespaceComputer.getAccumulatedHeight(0), 50);
assert.equal(whitespaceComputer.getAccumulatedHeight(1), 60);
assert.equal(whitespaceComputer.getAccumulatedHeight(2), 80);
assert.equal(whitespaceComputer.getTotalHeight(), 80);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(1), 50);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(2), 50);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(3), 60);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(4), 60);
assert.equal(whitespaceComputer.getAccumulatedHeightBeforeLineNumber(5), 80);
// Add a whitespace after line 3 of height 30
whitespaceComputer.insertWhitespace(3, 0, 30);
//.........這裏部分代碼省略.........
示例3: changeWhitespace
/**
* Change properties associated with a certain whitespace.
*/
public changeWhitespace(id: number, newAfterLineNumber: number, newHeight: number): boolean {
return this._whitespaces.changeWhitespace(id, newAfterLineNumber, newHeight);
}