Skip to content

Commit

Permalink
reset default palette from XTSMGRAPHICS, fixes jerch#12
Browse files Browse the repository at this point in the history
  • Loading branch information
jerch committed May 3, 2022
1 parent c659267 commit 673f9e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ terminal.loadAddon(imageAddon);

The default palette is a mixture of VT340 colors (lower 16 registers), xterm colors (up to 256) and zeros (up to 4096).
There is no private/shared palette distinction, palette colors are always carried over from a previous.
Restoring the default palette is currently only possible by RIS and DECSTR, which are quite intrusive.
If you need to change palette colors before loading the next image, consider doing this by loading a sixel image
with your custom color definitions instead.
Restoring the default palette size and colors is possible with `XTSMGRAPHICS 1 ; 2` (binary: `\x1b[?1;2S`),
the default palette is only restored on RIS nd DECSTR.

Other than on older terminals, the underlying SIXEL library applies colors immediately to individual pixels
(*printer mode*), thus it is technically possible to use more colors in one image than the palette has color slots.
Expand Down
2 changes: 2 additions & 0 deletions src/ImageAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ 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();
return true;
case GaAction.SET:
if (params.length > 2 && !(params[2] instanceof Array) && params[2] <= MAX_SIXEL_PALETTE_SIZE) {
Expand Down

0 comments on commit 673f9e5

Please sign in to comment.