Skip to content

Commit 334ca07

Browse files
authored
Merge branch 'master' into add-pyTermTk-sandbox-project
2 parents 932b65e + 7e01dc1 commit 334ca07

36 files changed

+393
-184
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ jobs:
167167
strategy:
168168
matrix:
169169
node-version: [18] # just one as integration tests are about testing in browser
170-
runs-on: [ubuntu] # macos is flaky
170+
runs-on: [ubuntu-22.04] # macos is flaky
171171
browser: [chromium, firefox, webkit]
172-
runs-on: ${{ matrix.runs-on }}-latest
172+
runs-on: ${{ matrix.runs-on }}
173173
steps:
174174
- uses: actions/checkout@v3
175175
- name: Use Node.js ${{ matrix.node-version }}.x

.vscode/settings.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22
"files.associations": {
33
".eslintrc.json.typings": "jsonc"
44
},
5-
// Hide output files from the file explorer, comment this out to see the build output
65
"files.exclude": {
7-
"**/.nyc_output": true,
8-
"**/lib": true,
9-
"**/dist": true,
10-
"**/out": true,
11-
"**/out-*": true,
6+
"**/.nyc_output": true
127
},
138
"typescript.preferences.importModuleSpecifier": "non-relative",
149
"typescript.preferences.quoteStyle": "single",

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ Xterm.js is used in several world-class applications to provide great terminal e
227227
- [**balena**](https://www.balena.io/): Balena is a full-stack solution for developing, deploying, updating, and troubleshooting IoT Edge devices. We use xterm.js to manage & debug devices on [balenaCloud](https://www.balena.io/cloud).
228228
- [**Filet Cloud**](https://github.com/fuglaro/filet-cloud): The lean and powerful personal cloud ⛅.
229229
- [**pyTermTk**](https://github.com/ceccopierangiolieugenio/pyTermTk): Python Terminal Toolkit - a Spiced Up Cross Compatible TUI Library 🌶️, use xterm.js for the [HTML5 exporter](https://ceccopierangiolieugenio.github.io/pyTermTk/sandbox/sandbox.html).
230+
- [**ecmaOS**](https://ecmaos.sh): A kernel and suite of applications tying modern web technologies into a browser-based operating system.
231+
- [**LabEx**](https://labex.io): Interactive learning platform with hands-on labs and xterm.js-based online terminals, focused on learn-by-doing approach.
230232
- [And much more...](https://github.com/xtermjs/xterm.js/network/dependents?package_id=UGFja2FnZS0xNjYzMjc4OQ%3D%3D)
231233

232234
Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Note: Please add any new contributions to the end of the list only.

addons/addon-ligatures/src/LigaturesAddon.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,40 @@ export interface ITerminalAddon {
1515

1616
export class LigaturesAddon implements ITerminalAddon , ILigaturesApi {
1717
private readonly _fallbackLigatures: string[];
18+
private readonly _fontFeatureSettings?: string;
1819

1920
private _terminal: Terminal | undefined;
2021
private _characterJoinerId: number | undefined;
2122

2223
constructor(options?: Partial<ILigatureOptions>) {
24+
// Source: calt set from https://github.com/be5invis/Iosevka?tab=readme-ov-file#ligations
2325
this._fallbackLigatures = (options?.fallbackLigatures || [
2426
'<--', '<---', '<<-', '<-', '->', '->>', '-->', '--->',
2527
'<==', '<===', '<<=', '<=', '=>', '=>>', '==>', '===>', '>=', '>>=',
26-
'<->', '<-->', '<--->', '<---->', '<=>', '<==>', '<===>', '<====>', '-------->',
27-
'<~~', '<~', '~>', '~~>', '::', ':::', '==', '!=', '===', '!==',
28-
':=', ':-', ':+', '<*', '<*>', '*>', '<|', '<|>', '|>', '+:', '-:', '=:', ':>',
29-
'++', '+++', '<!--', '<!---', '<***>'
28+
'<->', '<-->', '<--->', '<---->', '<=>', '<==>', '<===>', '<====>', '::', ':::',
29+
'<~~', '</', '</>', '/>', '~~>', '==', '!=', '/=', '~=', '<>', '===', '!==', '!===',
30+
'<:', ':=', '*=', '*+', '<*', '<*>', '*>', '<|', '<|>', '|>', '+*', '=*', '=:', ':>',
31+
'/*', '*/', '+++', '<!--', '<!---'
3032
]).sort((a, b) => b.length - a.length);
33+
this._fontFeatureSettings = options?.fontFeatureSettings;
3134
}
3235

3336
public activate(terminal: Terminal): void {
37+
if (!terminal.element) {
38+
throw new Error('Cannot activate LigaturesAddon before open is called');
39+
}
3440
this._terminal = terminal;
3541
this._characterJoinerId = enableLigatures(terminal, this._fallbackLigatures);
42+
terminal.element.style.fontFeatureSettings = this._fontFeatureSettings ?? '"calt" on';
3643
}
3744

3845
public dispose(): void {
3946
if (this._characterJoinerId !== undefined) {
4047
this._terminal?.deregisterCharacterJoiner(this._characterJoinerId);
4148
this._characterJoinerId = undefined;
4249
}
50+
if (this._terminal?.element) {
51+
this._terminal.element.style.fontFeatureSettings = '';
52+
}
4353
}
4454
}

addons/addon-ligatures/src/Types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
export interface ILigatureOptions {
77
fallbackLigatures: string[];
8+
fontFeatureSettings: string;
89
}

addons/addon-ligatures/typings/addon-ligatures.d.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ declare module '@xterm/addon-ligatures' {
2323
constructor(options?: Partial<ILigatureOptions>);
2424

2525
/**
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+
*
2730
*
2831
* @param terminal The terminal the addon is being loaded in.
2932
*/
@@ -40,19 +43,28 @@ declare module '@xterm/addon-ligatures' {
4043
*/
4144
export interface ILigatureOptions {
4245
/**
43-
* Fallback ligatures to use when the font access API is either not supported by the browser or
44-
* access is denied. The default set of ligatures is taken from Iosevka's default "calt"
45-
* ligation set: https://typeof.net/Iosevka/
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/
4650
*
4751
* ```
4852
* <-- <--- <<- <- -> ->> --> --->
4953
* <== <=== <<= <= => =>> ==> ===> >= >>=
50-
* <-> <--> <---> <----> <=> <==> <===> <====> -------->
51-
* <~~ <~ ~> ~~> :: ::: == != === !==
52-
* := :- :+ <* <*> *> <| <|> |> +: -: =: :>
53-
* ++ +++ <!-- <!--- <***>
54-
* ```
54+
* <-> <--> <---> <----> <=> <==> <===> <====> :: :::
55+
* <~~ </ </> /> ~~> == != /= ~= <> === !== !===
56+
* <: := *= *+ <* <*> *> <| <|> |> +* =* =: :>
57+
* /* <close block comment> +++ <!-- <!---
5558
*/
5659
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;
5769
}
5870
}

addons/addon-ligatures/webpack.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ module.exports = {
3131
},
3232
mode: 'production',
3333
externals: {
34-
'fs': 'fs',
35-
'path': 'path',
36-
'stream': 'stream',
37-
'util': 'util'
34+
'fs': 'commonjs fs',
35+
'path': 'commonjs path',
36+
'stream': 'commonjs stream',
37+
'util': 'commonjs util'
3838
},
3939
resolve: {
4040
// The ligature modules contains fallbacks for node environments, we never want to browserify them

addons/addon-search/src/SearchAddon.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,16 @@ export class SearchAddon extends Disposable implements ITerminalAddon , ISearchA
499499
const [stringLine, offsets] = cache;
500500

501501
const offset = this._bufferColsToStringOffset(row, col);
502-
const searchTerm = searchOptions.caseSensitive ? term : term.toLowerCase();
503-
const searchStringLine = searchOptions.caseSensitive ? stringLine : stringLine.toLowerCase();
502+
let searchTerm = term;
503+
let searchStringLine = stringLine;
504+
if (!searchOptions.regex) {
505+
searchTerm = searchOptions.caseSensitive ? term : term.toLowerCase();
506+
searchStringLine = searchOptions.caseSensitive ? stringLine : stringLine.toLowerCase();
507+
}
504508

505509
let resultIndex = -1;
506510
if (searchOptions.regex) {
507-
const searchRegex = RegExp(searchTerm, 'g');
511+
const searchRegex = RegExp(searchTerm, searchOptions.caseSensitive ? 'g' : 'gi');
508512
let foundTerm: RegExpExecArray | null;
509513
if (isReverseSearch) {
510514
// This loop will get the resultIndex of the _last_ regex match in the range 0..offset

addons/addon-serialize/src/SerializeAddon.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ describe('SerializeAddon', () => {
222222

223223
it('empty terminal with default options', async () => {
224224
const output = serializeAddon.serializeAsHTML();
225-
assert.equal((output.match(/color: #000000; background-color: #ffffff; font-family: courier-new, courier, monospace; font-size: 15px;/g) || []).length, 1, output);
225+
assert.equal((output.match(/color: #000000; background-color: #ffffff; font-family: monospace; font-size: 15px;/g) || []).length, 1, output);
226226
});
227227

228228
it('empty terminal with custom options', async () => {
@@ -242,7 +242,7 @@ describe('SerializeAddon', () => {
242242
const output = serializeAddon.serializeAsHTML({
243243
includeGlobalBackground: true
244244
});
245-
assert.equal((output.match(/color: #ffffff; background-color: #000000; font-family: courier-new, courier, monospace; font-size: 15px;/g) || []).length, 1, output);
245+
assert.equal((output.match(/color: #ffffff; background-color: #000000; font-family: monospace; font-size: 15px;/g) || []).length, 1, output);
246246
});
247247

248248
it('cells with custom color styling', async () => {

addons/addon-webgl/src/GlyphRenderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ export class GlyphRenderer extends Disposable {
238238

239239
// Get the glyph
240240
if (chars && chars.length > 1) {
241-
$glyph = this._atlas.getRasterizedGlyphCombinedChar(chars, bg, fg, ext, false);
241+
$glyph = this._atlas.getRasterizedGlyphCombinedChar(chars, bg, fg, ext, false, this._terminal.element);
242242
} else {
243-
$glyph = this._atlas.getRasterizedGlyph(code, bg, fg, ext, false);
243+
$glyph = this._atlas.getRasterizedGlyph(code, bg, fg, ext, false, this._terminal.element);
244244
}
245245

246246
$leftCellPadding = Math.floor((this._dimensions.device.cell.width - this._dimensions.device.char.width) / 2);

0 commit comments

Comments
 (0)