Skip to content

Commit

Permalink
remove worker impl
Browse files Browse the repository at this point in the history
  • Loading branch information
jerch committed Sep 17, 2022
1 parent 1f5156a commit 1f68efe
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 493 deletions.
67 changes: 67 additions & 0 deletions fixture/inspect_palette.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

function print_palette() {
L=$(( LOWER / 256))
U=$(( (UPPER-1) / 256))
for ((p = $L; p <= $U; p++))
do
echo "slot $((p*256))..$((p*256+255)):"
echo -ne "\x1bP;1q"
for i in {0..15}
do
a=$((i * 16 + p * 256))
for j in {0..15}
do
echo -ne "#$((a+j))!6~"
done
echo -ne "\$-"
done
echo -ne "\x1b\\"
done
}

colors=undefined
max_colors=undefined

echo "Terminal Reports (XTSMGRAPHICS):"
IFS=";" read -a REPLY -s -t 1 -d "S" -p $'\e[?1;1;0S'
[[ ${REPLY[1]} == "0" ]] && colors=${REPLY[2]}
echo "active colors: ${colors}"

IFS=";" read -a REPLY -s -t 1 -d "S" -p $'\e[?1;4;0S'
[[ ${REPLY[1]} == "0" ]] && max_colors=${REPLY[2]}
echo "max colors : ${max_colors}"
echo


# query up to colors by default
# if colors is undefined (no XTSMGRAPHICS), assume 256
ARG1=${1:-${colors}}
if [[ $colors == "undefined" ]]
then
ARG1=${1:-256}
fi
LOWER=0
UPPER=$ARG1
ARG2=${2:-undefined}
if [[ $ARG2 != "undefined" ]]
then
LOWER=ARG1
UPPER=ARG2
fi

if [[ $colors != "undefined" ]]
then
if [[ $colors -lt $UPPER ]] || [[ $colors -lt 256 ]]
then
echo -e "\x1b[33mNote: Active colors is smaller than test range."
echo -e "A spec-conform terminal may repeat colors in 'slot mod ${colors}'.\x1b[m"
echo
fi
else
echo -e "\x1b[33mNote: Cannot query active colors."
echo -e "The terminal may repeat colors beyond it max slot (e.g. slot mod 16).\x1b[m"
echo
fi

print_palette
94 changes: 0 additions & 94 deletions src-worker/main.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src-worker/tsconfig.json

This file was deleted.

26 changes: 9 additions & 17 deletions src/ImageAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ImageRenderer } from './ImageRenderer';
import { ImageStorage, CELL_SIZE_DEFAULT } from './ImageStorage';
import { SixelHandler } from './SixelHandler';
import { ITerminalExt, IImageAddonOptions, IResetHandler } from './Types';
import { WorkerManager } from './WorkerManager';


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

constructor(workerPath: string, opts: Partial<IImageAddonOptions>) {
this._opts = Object.assign({}, DEFAULT_OPTIONS, opts);
this._defaultOpts = Object.assign({}, DEFAULT_OPTIONS, opts);
this._workerManager = new WorkerManager(workerPath, this._opts);
this._disposeLater(this._workerManager);
}

public dispose(): void {
Expand Down Expand Up @@ -130,7 +126,7 @@ export class ImageAddon implements ITerminalAddon {

// SIXEL handler
if (this._opts.sixelSupport) {
const sixelHandler = new SixelHandler(this._opts, this._storage, terminal, this._workerManager);
const sixelHandler = new SixelHandler(this._opts, this._storage!, terminal);
this._handlers.set('sixel', sixelHandler);
this._disposeLater(
terminal._core._inputHandler._parser.registerDcsHandler({ final: 'q' }, sixelHandler)
Expand All @@ -145,10 +141,9 @@ export class ImageAddon implements ITerminalAddon {
this._opts.sixelPaletteLimit = this._defaultOpts.sixelPaletteLimit;
// also clear image storage
this._storage?.reset();
// reset worker and protocol handlers
this._workerManager.reset();
for (const value of this._handlers.values()) {
value.reset();
// reset protocol handlers
for (const handler of this._handlers.values()) {
handler.reset();
}
return false;
}
Expand Down Expand Up @@ -222,7 +217,7 @@ export class ImageAddon implements ITerminalAddon {
// 4 - SIXEL support
// 9 - charsets
// 22 - ANSI colors
if (this._opts.sixelSupport && !this._workerManager.failed) {
if (this._opts.sixelSupport) {
this._report(`\x1b[?62;4;9;22c`);
return true;
}
Expand All @@ -243,11 +238,6 @@ export class ImageAddon implements ITerminalAddon {
if (params.length < 2) {
return true;
}
if (this._workerManager.failed) {
// on worker error report graphics caps as not supported
this._report(`\x1b[?${params[0]};${GaStatus.ITEM_ERROR}S`);
return true;
}
if (params[0] === GaItem.COLORS) {
switch (params[1]) {
case GaAction.READ:
Expand All @@ -256,8 +246,10 @@ export class ImageAddon implements ITerminalAddon {
case GaAction.SET_DEFAULT:
this._opts.sixelPaletteLimit = this._defaultOpts.sixelPaletteLimit;
this._report(`\x1b[?${params[0]};${GaStatus.SUCCESS};${this._opts.sixelPaletteLimit}S`);
// also reset default palette colors for now
this._workerManager.reset();
// also reset protocol handlers for now
for (const handler of this._handlers.values()) {
handler.reset();
}
return true;
case GaAction.SET:
if (params.length > 2 && !(params[2] instanceof Array) && params[2] <= MAX_SIXEL_PALETTE_SIZE) {
Expand Down
Loading

0 comments on commit 1f68efe

Please sign in to comment.