@xterm/addon-image 0.10.0-beta.28 → 0.10.0-beta.281
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/README.md +33 -42
- package/lib/addon-image.js +1 -1
- package/lib/addon-image.js.map +1 -1
- package/lib/addon-image.mjs +1 -22
- package/lib/addon-image.mjs.map +4 -4
- package/package.json +5 -5
- package/src/IIPHandler.ts +109 -41
- package/src/IIPHeaderParser.ts +89 -13
- package/src/IIPImageStorage.ts +28 -0
- package/src/IIPMetrics.ts +9 -1
- package/src/ImageAddon.ts +74 -13
- package/src/ImageRenderer.ts +99 -53
- package/src/ImageStorage.ts +138 -65
- package/src/SixelHandler.ts +4 -4
- package/src/SixelImageStorage.ts +52 -0
- package/src/Types.ts +18 -3
- package/src/kitty/KittyGraphicsHandler.ts +819 -0
- package/src/kitty/KittyGraphicsTypes.ts +195 -0
- package/src/kitty/KittyImageStorage.ts +155 -0
- package/typings/addon-image.d.ts +15 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ImageStorage, CELL_SIZE_DEFAULT } from './ImageStorage';
|
|
7
|
+
import { IImageAddonOptions, ITerminalExt, IAddImageOpts } from './Types';
|
|
8
|
+
import { ImageRenderer } from './ImageRenderer';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Sixel-specific image storage controller.
|
|
12
|
+
*
|
|
13
|
+
* Wraps the shared ImageStorage with sixel protocol semantics:
|
|
14
|
+
* - Cursor behavior governed by DECSET 80 (sixelScrolling option)
|
|
15
|
+
* - advanceCursor for empty sixels carrying only height
|
|
16
|
+
*/
|
|
17
|
+
export class SixelImageStorage {
|
|
18
|
+
private _addImageOpts: IAddImageOpts = { scrolling: true, layer: 'top', zIndex: 0, cursorPos: 'vt340' };
|
|
19
|
+
constructor(
|
|
20
|
+
private readonly _storage: ImageStorage,
|
|
21
|
+
private readonly _opts: IImageAddonOptions,
|
|
22
|
+
private readonly _renderer: ImageRenderer,
|
|
23
|
+
private readonly _terminal: ITerminalExt
|
|
24
|
+
) {}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Add a sixel image to storage.
|
|
28
|
+
* Cursor behavior depends on the sixelScrolling option (DECSET 80).
|
|
29
|
+
*/
|
|
30
|
+
public addImage(img: HTMLCanvasElement | ImageBitmap): void {
|
|
31
|
+
this._addImageOpts.scrolling = this._opts.sixelScrolling;
|
|
32
|
+
this._storage.addImage(img, this._addImageOpts);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Only advance text cursor.
|
|
37
|
+
* This is an edge case from empty sixels carrying only a height but no pixels.
|
|
38
|
+
* Partially fixes https://github.com/jerch/xterm-addon-image/issues/37.
|
|
39
|
+
*/
|
|
40
|
+
public advanceCursor(height: number): void {
|
|
41
|
+
if (this._opts.sixelScrolling) {
|
|
42
|
+
let cellSize = this._renderer.cellSize;
|
|
43
|
+
if (cellSize.width === -1 || cellSize.height === -1) {
|
|
44
|
+
cellSize = CELL_SIZE_DEFAULT;
|
|
45
|
+
}
|
|
46
|
+
const rows = Math.ceil(height / cellSize.height);
|
|
47
|
+
for (let i = 1; i < rows; ++i) {
|
|
48
|
+
this._terminal._core._inputHandler.lineFeed();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/Types.ts
CHANGED
|
@@ -8,8 +8,9 @@ import { IDisposable, IMarker, Terminal } from '@xterm/xterm';
|
|
|
8
8
|
// private imports from base repo we build against
|
|
9
9
|
import { Attributes, BgFlags, Content, ExtFlags, UnderlineStyle } from 'common/buffer/Constants';
|
|
10
10
|
import type { AttributeData } from 'common/buffer/AttributeData';
|
|
11
|
-
import type { IParams, IDcsHandler, IOscHandler, IEscapeSequenceParser } from 'common/parser/Types';
|
|
12
|
-
import type {
|
|
11
|
+
import type { IParams, IDcsHandler, IOscHandler, IApcHandler, IEscapeSequenceParser } from 'common/parser/Types';
|
|
12
|
+
import type { IInputHandler } from 'common/Types';
|
|
13
|
+
import type { IBufferLine, IExtendedAttrs } from 'common/buffer/Types';
|
|
13
14
|
import type { ITerminal, ReadonlyColorSet } from 'browser/Types';
|
|
14
15
|
import type { IRenderDimensions } from 'browser/renderer/shared/Types';
|
|
15
16
|
import type { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
|
@@ -22,7 +23,7 @@ export const enum Cell {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
// export some privates for local usage
|
|
25
|
-
export { AttributeData, IParams, IDcsHandler, IOscHandler, BgFlags, IRenderDimensions, IRenderService, Content, ExtFlags, Attributes, UnderlineStyle, ReadonlyColorSet };
|
|
26
|
+
export { AttributeData, IParams, IDcsHandler, IOscHandler, IApcHandler, BgFlags, IRenderDimensions, IRenderService, Content, ExtFlags, Attributes, UnderlineStyle, ReadonlyColorSet };
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Plugin ctor options.
|
|
@@ -38,6 +39,8 @@ export interface IImageAddonOptions {
|
|
|
38
39
|
sixelSizeLimit: number;
|
|
39
40
|
iipSupport: boolean;
|
|
40
41
|
iipSizeLimit: number;
|
|
42
|
+
kittySupport: boolean;
|
|
43
|
+
kittySizeLimit: number;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export interface IResetHandler {
|
|
@@ -97,6 +100,16 @@ export interface ICellSize {
|
|
|
97
100
|
height: number;
|
|
98
101
|
}
|
|
99
102
|
|
|
103
|
+
export type ImageLayer = 'top' | 'bottom';
|
|
104
|
+
export type CursorPos = 'vt340' | 'iip';
|
|
105
|
+
|
|
106
|
+
export interface IAddImageOpts {
|
|
107
|
+
scrolling: boolean;
|
|
108
|
+
layer: ImageLayer;
|
|
109
|
+
zIndex: number;
|
|
110
|
+
cursorPos: CursorPos;
|
|
111
|
+
}
|
|
112
|
+
|
|
100
113
|
export interface IImageSpec {
|
|
101
114
|
orig: HTMLCanvasElement | ImageBitmap | undefined;
|
|
102
115
|
origCellSize: ICellSize;
|
|
@@ -105,4 +118,6 @@ export interface IImageSpec {
|
|
|
105
118
|
marker: IMarker | undefined;
|
|
106
119
|
tileCount: number;
|
|
107
120
|
bufferType: 'alternate' | 'normal';
|
|
121
|
+
layer: ImageLayer;
|
|
122
|
+
zIndex: number;
|
|
108
123
|
}
|