本文整理汇总了TypeScript中vs/editor/common/core/uint.toUint32Array函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toUint32Array函数的具体用法?TypeScript toUint32Array怎么用?TypeScript toUint32Array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toUint32Array函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: createLineMapping
//.........这里部分代码省略.........
}
}
let charColumnSize = 1;
if (strings.isFullWidthCharacter(charCode)) {
charColumnSize = columnsForFullWidthChar;
}
// Advance visibleColumn with character at `i`
visibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(visibleColumn, tabSize, charCodeIsTab, charColumnSize);
if (visibleColumn > breakingColumn && i !== 0) {
// We need to break at least before character at `i`:
// - break before niceBreakLastOffset if it exists (and re-establish a correct visibleColumn by using niceBreakVisibleColumn + charAt(i))
// - otherwise, break before obtrusiveBreakLastOffset if it exists (and re-establish a correct visibleColumn by using obtrusiveBreakVisibleColumn + charAt(i))
// - otherwise, break before i (and re-establish a correct visibleColumn by charAt(i))
let breakBeforeOffset: number;
let restoreVisibleColumnFrom: number;
if (niceBreakOffset !== -1 && niceBreakVisibleColumn <= breakingColumn) {
// We will break before `niceBreakLastOffset`
breakBeforeOffset = niceBreakOffset;
restoreVisibleColumnFrom = niceBreakVisibleColumn;
} else if (obtrusiveBreakOffset !== -1 && obtrusiveBreakVisibleColumn <= breakingColumn) {
// We will break before `obtrusiveBreakLastOffset`
breakBeforeOffset = obtrusiveBreakOffset;
restoreVisibleColumnFrom = obtrusiveBreakVisibleColumn;
} else {
// We will break before `i`
breakBeforeOffset = i;
restoreVisibleColumnFrom = wrappedTextIndentVisibleColumn;
}
// Break before character at `breakBeforeOffset`
breakingLengths[breakingLengthsIndex++] = breakBeforeOffset - lastBreakingOffset;
lastBreakingOffset = breakBeforeOffset;
// Re-establish visibleColumn by taking character at `i` into account
visibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(restoreVisibleColumnFrom, tabSize, charCodeIsTab, charColumnSize);
// Reset markers
niceBreakOffset = -1;
niceBreakVisibleColumn = 0;
obtrusiveBreakOffset = -1;
obtrusiveBreakVisibleColumn = 0;
}
// At this point, there is a certainty that the character at `i` fits on the current line
if (niceBreakOffset !== -1) {
// Advance niceBreakVisibleColumn
niceBreakVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(niceBreakVisibleColumn, tabSize, charCodeIsTab, charColumnSize);
}
if (obtrusiveBreakOffset !== -1) {
// Advance obtrusiveBreakVisibleColumn
obtrusiveBreakVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(obtrusiveBreakVisibleColumn, tabSize, charCodeIsTab, charColumnSize);
}
if (charCodeClass === CharacterClass.BREAK_AFTER && (hardWrappingIndent === WrappingIndent.None || i >= firstNonWhitespaceIndex)) {
// This is a character that indicates that a break should happen after it
niceBreakOffset = i + 1;
niceBreakVisibleColumn = wrappedTextIndentVisibleColumn;
}
// CJK breaking : after break
if (charCodeClass === CharacterClass.BREAK_IDEOGRAPHIC && i < len - 1) {
let nextCode = lineText.charCodeAt(i + 1);
let nextClass = classifier.get(nextCode);
if (nextClass !== CharacterClass.BREAK_AFTER) { // Kinsoku Shori: Don't break before a trailing character, like a period
niceBreakOffset = i + 1;
niceBreakVisibleColumn = wrappedTextIndentVisibleColumn;
}
}
if (charCodeClass === CharacterClass.BREAK_OBTRUSIVE) {
// This is an obtrusive character that indicates that a break should happen after it
obtrusiveBreakOffset = i + 1;
obtrusiveBreakVisibleColumn = wrappedTextIndentVisibleColumn;
}
}
if (breakingLengthsIndex === 0) {
return null;
}
// Add last segment
breakingLengths[breakingLengthsIndex++] = len - lastBreakingOffset;
return new CharacterHardWrappingLineMapping(
new PrefixSumComputer(toUint32Array(breakingLengths)),
wrappedTextIndent
);
}
开发者ID:Chan-PH,项目名称:vscode,代码行数:101,代码来源:characterHardWrappingLineMapper.ts
示例2: createLineMapping
function createLineMapping(breakingLengths: number[], wrappedLinesPrefix: string): ILineMapping {
return new CharacterHardWrappingLineMapping(
new PrefixSumComputer(toUint32Array(breakingLengths)),
wrappedLinesPrefix
);
}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:6,代码来源:splitLinesCollection.test.ts
示例3: test
test('PrefixSumComputer', () => {
let indexOfResult: PrefixSumIndexOfResult;
let psc = new PrefixSumComputer(toUint32Array([1, 1, 2, 1, 3]));
assert.equal(psc.getTotalValue(), 8);
assert.equal(psc.getAccumulatedValue(-1), 0);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 2);
assert.equal(psc.getAccumulatedValue(2), 4);
assert.equal(psc.getAccumulatedValue(3), 5);
assert.equal(psc.getAccumulatedValue(4), 8);
indexOfResult = psc.getIndexOf(0);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(1);
assert.equal(indexOfResult.index, 1);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(2);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(3);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 1);
indexOfResult = psc.getIndexOf(4);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(5);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(6);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 1);
indexOfResult = psc.getIndexOf(7);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 2);
indexOfResult = psc.getIndexOf(8);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 3);
// [1, 2, 2, 1, 3]
psc.changeValue(1, 2);
assert.equal(psc.getTotalValue(), 9);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 3);
assert.equal(psc.getAccumulatedValue(2), 5);
assert.equal(psc.getAccumulatedValue(3), 6);
assert.equal(psc.getAccumulatedValue(4), 9);
// [1, 0, 2, 1, 3]
psc.changeValue(1, 0);
assert.equal(psc.getTotalValue(), 7);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 1);
assert.equal(psc.getAccumulatedValue(2), 3);
assert.equal(psc.getAccumulatedValue(3), 4);
assert.equal(psc.getAccumulatedValue(4), 7);
indexOfResult = psc.getIndexOf(0);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(1);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(2);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 1);
indexOfResult = psc.getIndexOf(3);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(4);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(5);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 1);
indexOfResult = psc.getIndexOf(6);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 2);
indexOfResult = psc.getIndexOf(7);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 3);
// [1, 0, 0, 1, 3]
psc.changeValue(2, 0);
assert.equal(psc.getTotalValue(), 5);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 1);
assert.equal(psc.getAccumulatedValue(2), 1);
assert.equal(psc.getAccumulatedValue(3), 2);
assert.equal(psc.getAccumulatedValue(4), 5);
indexOfResult = psc.getIndexOf(0);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(1);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(2);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(3);
assert.equal(indexOfResult.index, 4);
//.........这里部分代码省略.........
开发者ID:DonJayamanne,项目名称:vscode,代码行数:101,代码来源:prefixSumComputer.test.ts
注:本文中的vs/editor/common/core/uint.toUint32Array函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论