Class: VscodeHatRenderer
ide/vscode/hats/VscodeHatRenderer.VscodeHatRenderer
Maintains the VSCode decoration type objects corresponding to each hat style. This class is responsible for the actual svgs / colors used to render the hats. The decision about which hat styles should be available is up to {@link VscodeEnabledHatStyles}
Constructors
constructor
• new VscodeHatRenderer(extensionContext
, enabledHatStyles
)
Parameters
Name | Type |
---|---|
extensionContext | ExtensionContext |
enabledHatStyles | VscodeEnabledHatStyleManager |
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:49
Properties
decorationMap
• Private
decorationMap: Partial
<Record
<VscodeHatStyleName
, TextEditorDecorationType
>>
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:43
disposables
• Private
disposables: Disposable
[] = []
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:44
fontMeasurements
• Private
fontMeasurements: FontMeasurements
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:45
lastSeenEnabledHatStyles
• Private
lastSeenEnabledHatStyles: Partial
<Record
<VscodeHatStyleName
, ExtendedHatStyleInfo
>> = {}
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:47
notifier
• Private
notifier: Notifier
<[]>
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:46
Methods
constructColoredSvgDataUri
▸ Private
constructColoredSvgDataUri(originalSvg
, color
): Uri
Parameters
Name | Type |
---|---|
originalSvg | string |
color | string |
Returns
Uri
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:201
constructDecorations
▸ Private
constructDecorations(): Promise
<void
>
Returns
Promise
<void
>
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:118
destroyDecorations
▸ Private
destroyDecorations(): void
Returns
void
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:106
dispose
▸ dispose(): void
Returns
void
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:304
getDecorationType
▸ getDecorationType(hatStyle
): undefined
| TextEditorDecorationType
Gets the VSCode decoration type to use for the given hat style
Parameters
Name | Type | Description |
---|---|---|
hatStyle | VscodeHatStyleName | The name of the hat style |
Returns
undefined
| TextEditorDecorationType
A VSCode decoration type used to render the given hat style
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:102
getViewBoxDimensions
▸ Private
getViewBoxDimensions(rawSvg
): Object
Parameters
Name | Type |
---|---|
rawSvg | string |
Returns
Object
Name | Type |
---|---|
originalViewBoxHeight | number |
originalViewBoxWidth | number |
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:288
handleNewStylesIfNecessary
▸ handleNewStylesIfNecessary(): Promise
<void
>
Returns
Promise
<void
>
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:79
init
▸ init(): Promise
<void
>
Returns
Promise
<void
>
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:93
processSvg
▸ Private
processSvg(fontMeasurements
, shape
, scaleFactor
, hatVerticalOffsetEm
): Object
Creates an SVG from the hat SVG that pads, offsets and scales it to end up in the right size / place relative to the character it will be placed over. This image may or may not be helpful.
Parameters
Name | Type | Description |
---|---|---|
fontMeasurements | FontMeasurements | Info about the user's font |
shape | "default" | "ex" | "fox" | "wing" | "hole" | "frame" | "curve" | "eye" | "play" | "bolt" | "crosshairs" | The hat shape to process |
scaleFactor | number | How much to scale the hat |
hatVerticalOffsetEm | number | How far off top of characters should hats be |
Returns
Object
An object with the new SVG and its measurements
Name | Type |
---|---|
svg | string |
svgHeightPx | number |
svgWidthPx | number |
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:229
recomputeDecorations
▸ Private
recomputeDecorations(): Promise
<void
>
Returns
Promise
<void
>
Defined in
ide/vscode/hats/VscodeHatRenderer.ts:112
registerListener
▸ registerListener(listener
): Disposable
Parameters
Name | Type |
---|---|
listener | Listener <[]> |