Skip to content

Commit 1f68efe

Browse files
committed
remove worker impl
1 parent 1f5156a commit 1f68efe

9 files changed

+139
-493
lines changed

fixture/inspect_palette.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
function print_palette() {
4+
L=$(( LOWER / 256))
5+
U=$(( (UPPER-1) / 256))
6+
for ((p = $L; p <= $U; p++))
7+
do
8+
echo "slot $((p*256))..$((p*256+255)):"
9+
echo -ne "\x1bP;1q"
10+
for i in {0..15}
11+
do
12+
a=$((i * 16 + p * 256))
13+
for j in {0..15}
14+
do
15+
echo -ne "#$((a+j))!6~"
16+
done
17+
echo -ne "\$-"
18+
done
19+
echo -ne "\x1b\\"
20+
done
21+
}
22+
23+
colors=undefined
24+
max_colors=undefined
25+
26+
echo "Terminal Reports (XTSMGRAPHICS):"
27+
IFS=";" read -a REPLY -s -t 1 -d "S" -p $'\e[?1;1;0S'
28+
[[ ${REPLY[1]} == "0" ]] && colors=${REPLY[2]}
29+
echo "active colors: ${colors}"
30+
31+
IFS=";" read -a REPLY -s -t 1 -d "S" -p $'\e[?1;4;0S'
32+
[[ ${REPLY[1]} == "0" ]] && max_colors=${REPLY[2]}
33+
echo "max colors : ${max_colors}"
34+
echo
35+
36+
37+
# query up to colors by default
38+
# if colors is undefined (no XTSMGRAPHICS), assume 256
39+
ARG1=${1:-${colors}}
40+
if [[ $colors == "undefined" ]]
41+
then
42+
ARG1=${1:-256}
43+
fi
44+
LOWER=0
45+
UPPER=$ARG1
46+
ARG2=${2:-undefined}
47+
if [[ $ARG2 != "undefined" ]]
48+
then
49+
LOWER=ARG1
50+
UPPER=ARG2
51+
fi
52+
53+
if [[ $colors != "undefined" ]]
54+
then
55+
if [[ $colors -lt $UPPER ]] || [[ $colors -lt 256 ]]
56+
then
57+
echo -e "\x1b[33mNote: Active colors is smaller than test range."
58+
echo -e "A spec-conform terminal may repeat colors in 'slot mod ${colors}'.\x1b[m"
59+
echo
60+
fi
61+
else
62+
echo -e "\x1b[33mNote: Cannot query active colors."
63+
echo -e "The terminal may repeat colors beyond it max slot (e.g. slot mod 16).\x1b[m"
64+
echo
65+
fi
66+
67+
print_palette

src-worker/main.ts

Lines changed: 0 additions & 94 deletions
This file was deleted.

src-worker/tsconfig.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/ImageAddon.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { ImageRenderer } from './ImageRenderer';
88
import { ImageStorage, CELL_SIZE_DEFAULT } from './ImageStorage';
99
import { SixelHandler } from './SixelHandler';
1010
import { ITerminalExt, IImageAddonOptions, IResetHandler } from './Types';
11-
import { WorkerManager } from './WorkerManager';
1211

1312

1413
// default values of addon ctor options
@@ -53,14 +52,11 @@ export class ImageAddon implements ITerminalAddon {
5352
private _renderer: ImageRenderer | undefined;
5453
private _disposables: IDisposable[] = [];
5554
private _terminal: ITerminalExt | undefined;
56-
private _workerManager: WorkerManager;
5755
private _handlers: Map<String, IResetHandler> = new Map();
5856

5957
constructor(workerPath: string, opts: Partial<IImageAddonOptions>) {
6058
this._opts = Object.assign({}, DEFAULT_OPTIONS, opts);
6159
this._defaultOpts = Object.assign({}, DEFAULT_OPTIONS, opts);
62-
this._workerManager = new WorkerManager(workerPath, this._opts);
63-
this._disposeLater(this._workerManager);
6460
}
6561

6662
public dispose(): void {
@@ -130,7 +126,7 @@ export class ImageAddon implements ITerminalAddon {
130126

131127
// SIXEL handler
132128
if (this._opts.sixelSupport) {
133-
const sixelHandler = new SixelHandler(this._opts, this._storage, terminal, this._workerManager);
129+
const sixelHandler = new SixelHandler(this._opts, this._storage!, terminal);
134130
this._handlers.set('sixel', sixelHandler);
135131
this._disposeLater(
136132
terminal._core._inputHandler._parser.registerDcsHandler({ final: 'q' }, sixelHandler)
@@ -145,10 +141,9 @@ export class ImageAddon implements ITerminalAddon {
145141
this._opts.sixelPaletteLimit = this._defaultOpts.sixelPaletteLimit;
146142
// also clear image storage
147143
this._storage?.reset();
148-
// reset worker and protocol handlers
149-
this._workerManager.reset();
150-
for (const value of this._handlers.values()) {
151-
value.reset();
144+
// reset protocol handlers
145+
for (const handler of this._handlers.values()) {
146+
handler.reset();
152147
}
153148
return false;
154149
}
@@ -222,7 +217,7 @@ export class ImageAddon implements ITerminalAddon {
222217
// 4 - SIXEL support
223218
// 9 - charsets
224219
// 22 - ANSI colors
225-
if (this._opts.sixelSupport && !this._workerManager.failed) {
220+
if (this._opts.sixelSupport) {
226221
this._report(`\x1b[?62;4;9;22c`);
227222
return true;
228223
}
@@ -243,11 +238,6 @@ export class ImageAddon implements ITerminalAddon {
243238
if (params.length < 2) {
244239
return true;
245240
}
246-
if (this._workerManager.failed) {
247-
// on worker error report graphics caps as not supported
248-
this._report(`\x1b[?${params[0]};${GaStatus.ITEM_ERROR}S`);
249-
return true;
250-
}
251241
if (params[0] === GaItem.COLORS) {
252242
switch (params[1]) {
253243
case GaAction.READ:
@@ -256,8 +246,10 @@ export class ImageAddon implements ITerminalAddon {
256246
case GaAction.SET_DEFAULT:
257247
this._opts.sixelPaletteLimit = this._defaultOpts.sixelPaletteLimit;
258248
this._report(`\x1b[?${params[0]};${GaStatus.SUCCESS};${this._opts.sixelPaletteLimit}S`);
259-
// also reset default palette colors for now
260-
this._workerManager.reset();
249+
// also reset protocol handlers for now
250+
for (const handler of this._handlers.values()) {
251+
handler.reset();
252+
}
261253
return true;
262254
case GaAction.SET:
263255
if (params.length > 2 && !(params[2] instanceof Array) && params[2] <= MAX_SIXEL_PALETTE_SIZE) {

0 commit comments

Comments
 (0)