Skip to main content

Module: util/allocateHats/allocateHats

Interfaces

Functions

allocateHats

allocateHats(tokenGraphemeSplitter, enabledHatStyles, oldTokenHats, hatStability, activeTextEditor, visibleTextEditors): TokenHat[]

Allocates hats to all the visible tokens. Proceeds by ranking tokens according to desirability (how far they are from the cursor), then assigning a hat to each one in turn, deciding whether to keep old hat, steal a hat from another token, or use a freely available hat.

See hat assignment for more info.

Parameters

NameTypeDescription
tokenGraphemeSplitterTokenGraphemeSplitterSplits tokens into graphemes
enabledHatStylesHatStyleMapA list of all enabled hat styles
oldTokenHatsreadonly TokenHat[]The previous allocation, so that we can try to maintain hat stability
hatStabilityHatStabilityThe user setting indicating how to trade off quality vs stability
activeTextEditorundefined | TextEditorCurrently active text editor
visibleTextEditorsreadonly TextEditor[]All visible text editors

Returns

TokenHat[]

A hat assignment, which is a list where each entry contains a token and the hat that it will wear

Defined in

util/allocateHats/allocateHats.ts:48