@xterm/addon-ligatures 0.10.0-beta.13 → 0.10.0-beta.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/addon-ligatures.js +1 -1
- package/lib/addon-ligatures.js.map +1 -1
- package/lib/addon-ligatures.mjs +19 -0
- package/lib/addon-ligatures.mjs.map +7 -0
- package/package.json +5 -3
- package/src/LigaturesAddon.ts +14 -4
- package/src/{Types.d.ts → Types.ts} +1 -0
- package/typings/addon-ligatures.d.ts +21 -9
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/addon-ligatures",
|
|
3
|
-
"version": "0.10.0-beta.
|
|
3
|
+
"version": "0.10.0-beta.131",
|
|
4
4
|
"description": "Add support for programming ligatures to xterm.js",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "The xterm.js authors",
|
|
7
7
|
"url": "https://xtermjs.org/"
|
|
8
8
|
},
|
|
9
9
|
"main": "lib/addon-ligatures.js",
|
|
10
|
+
"module": "lib/addon-ligatures.mjs",
|
|
10
11
|
"types": "typings/addon-ligatures.d.ts",
|
|
11
12
|
"repository": "https://github.com/xtermjs/xterm.js/tree/master/addons/addon-ligatures",
|
|
12
13
|
"engines": {
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"yauzl": "^2.10.0"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"@xterm/xterm": "^5.0.
|
|
46
|
-
}
|
|
46
|
+
"@xterm/xterm": "^5.6.0-beta.131"
|
|
47
|
+
},
|
|
48
|
+
"commit": "a8fabcfa018173693c9df959fad8cf93a1334281"
|
|
47
49
|
}
|
package/src/LigaturesAddon.ts
CHANGED
|
@@ -15,24 +15,31 @@ export interface ITerminalAddon {
|
|
|
15
15
|
|
|
16
16
|
export class LigaturesAddon implements ITerminalAddon , ILigaturesApi {
|
|
17
17
|
private readonly _fallbackLigatures: string[];
|
|
18
|
+
private readonly _fontFeatureSettings?: string;
|
|
18
19
|
|
|
19
20
|
private _terminal: Terminal | undefined;
|
|
20
21
|
private _characterJoinerId: number | undefined;
|
|
21
22
|
|
|
22
23
|
constructor(options?: Partial<ILigatureOptions>) {
|
|
24
|
+
// Source: calt set from https://github.com/be5invis/Iosevka?tab=readme-ov-file#ligations
|
|
23
25
|
this._fallbackLigatures = (options?.fallbackLigatures || [
|
|
24
26
|
'<--', '<---', '<<-', '<-', '->', '->>', '-->', '--->',
|
|
25
27
|
'<==', '<===', '<<=', '<=', '=>', '=>>', '==>', '===>', '>=', '>>=',
|
|
26
|
-
'<->', '<-->', '<--->', '<---->', '<=>', '<==>', '<===>', '<====>', '
|
|
27
|
-
'<~~', '
|
|
28
|
-
':=', '
|
|
29
|
-
'
|
|
28
|
+
'<->', '<-->', '<--->', '<---->', '<=>', '<==>', '<===>', '<====>', '::', ':::',
|
|
29
|
+
'<~~', '</', '</>', '/>', '~~>', '==', '!=', '/=', '~=', '<>', '===', '!==', '!===',
|
|
30
|
+
'<:', ':=', '*=', '*+', '<*', '<*>', '*>', '<|', '<|>', '|>', '+*', '=*', '=:', ':>',
|
|
31
|
+
'/*', '*/', '+++', '<!--', '<!---'
|
|
30
32
|
]).sort((a, b) => b.length - a.length);
|
|
33
|
+
this._fontFeatureSettings = options?.fontFeatureSettings;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
public activate(terminal: Terminal): void {
|
|
37
|
+
if (!terminal.element) {
|
|
38
|
+
throw new Error('Cannot activate LigaturesAddon before open is called');
|
|
39
|
+
}
|
|
34
40
|
this._terminal = terminal;
|
|
35
41
|
this._characterJoinerId = enableLigatures(terminal, this._fallbackLigatures);
|
|
42
|
+
terminal.element.style.fontFeatureSettings = this._fontFeatureSettings ?? '"calt" on';
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
public dispose(): void {
|
|
@@ -40,5 +47,8 @@ export class LigaturesAddon implements ITerminalAddon , ILigaturesApi {
|
|
|
40
47
|
this._terminal?.deregisterCharacterJoiner(this._characterJoinerId);
|
|
41
48
|
this._characterJoinerId = undefined;
|
|
42
49
|
}
|
|
50
|
+
if (this._terminal?.element) {
|
|
51
|
+
this._terminal.element.style.fontFeatureSettings = '';
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
54
|
}
|
|
@@ -23,7 +23,10 @@ declare module '@xterm/addon-ligatures' {
|
|
|
23
23
|
constructor(options?: Partial<ILigatureOptions>);
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Activates the addon
|
|
26
|
+
* Activates the addon. Note that if webgl is also being used, that addon
|
|
27
|
+
* should be reactivated after ligatures is activated in order to apply
|
|
28
|
+
* {@link ILigatureOptions.fontFeatureSettings} to the texture atlas.
|
|
29
|
+
*
|
|
27
30
|
*
|
|
28
31
|
* @param terminal The terminal the addon is being loaded in.
|
|
29
32
|
*/
|
|
@@ -40,19 +43,28 @@ declare module '@xterm/addon-ligatures' {
|
|
|
40
43
|
*/
|
|
41
44
|
export interface ILigatureOptions {
|
|
42
45
|
/**
|
|
43
|
-
* Fallback ligatures to use when the font access API is either not
|
|
44
|
-
* access is denied. The default set of
|
|
45
|
-
* ligation set:
|
|
46
|
+
* Fallback ligatures to use when the font access API is either not
|
|
47
|
+
* supported by the browser or access is denied. The default set of
|
|
48
|
+
* ligatures is taken from Iosevka's default "calt" ligation set:
|
|
49
|
+
* https://typeof.net/Iosevka/
|
|
46
50
|
*
|
|
47
51
|
* ```
|
|
48
52
|
* <-- <--- <<- <- -> ->> --> --->
|
|
49
53
|
* <== <=== <<= <= => =>> ==> ===> >= >>=
|
|
50
|
-
* <-> <--> <---> <----> <=> <==> <===> <====>
|
|
51
|
-
* <~~
|
|
52
|
-
* :=
|
|
53
|
-
*
|
|
54
|
-
* ```
|
|
54
|
+
* <-> <--> <---> <----> <=> <==> <===> <====> :: :::
|
|
55
|
+
* <~~ </ </> /> ~~> == != /= ~= <> === !== !===
|
|
56
|
+
* <: := *= *+ <* <*> *> <| <|> |> +* =* =: :>
|
|
57
|
+
* /* <close block comment> +++ <!-- <!---
|
|
55
58
|
*/
|
|
56
59
|
fallbackLigatures: string[]
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The CSS `font-feature-settings` value to use for enabling ligatures. This
|
|
63
|
+
* also supports font variants for example with a value like
|
|
64
|
+
* `"calt" on, "ss03"`.
|
|
65
|
+
*
|
|
66
|
+
* The default value is `"calt" on`.
|
|
67
|
+
*/
|
|
68
|
+
fontFeatureSettings: string;
|
|
57
69
|
}
|
|
58
70
|
}
|