@@ -216,28 +216,14 @@ export class ImageStorage implements IDisposable {
216216 this . _fullyCleared = false ;
217217 }
218218
219- /**
220- * Only advance text cursor.
221- * This is an edge case from empty sixels carrying only a height but no pixels.
222- * Partially fixes https://github.com/jerch/xterm-addon-image/issues/37.
223- */
224- public advanceCursor ( height : number ) : void {
225- if ( this . _opts . sixelScrolling ) {
226- let cellSize = this . _renderer . cellSize ;
227- if ( cellSize . width === - 1 || cellSize . height === - 1 ) {
228- cellSize = CELL_SIZE_DEFAULT ;
229- }
230- const rows = Math . ceil ( height / cellSize . height ) ;
231- for ( let i = 1 ; i < rows ; ++ i ) {
232- this . _terminal . _core . _inputHandler . lineFeed ( ) ;
233- }
234- }
235- }
236-
237219 /**
238220 * Method to add an image to the storage.
221+ * @param img - The image to add (canvas or bitmap).
222+ * @param scrolling - When true, cursor advances with the image (lineFeed per row).
223+ * When false, image is placed at (0,0) and cursor is restored (DECSET 80 / sixel origin mode).
224+ * @returns The internal image ID assigned to the stored image.
239225 */
240- public addImage ( img : HTMLCanvasElement | ImageBitmap ) : void {
226+ public addImage ( img : HTMLCanvasElement | ImageBitmap , scrolling : boolean ) : number {
241227 // never allow storage to exceed memory limit
242228 this . _evictOldest ( img . width * img . height ) ;
243229
@@ -259,7 +245,7 @@ export class ImageStorage implements IDisposable {
259245 let offset = originX ;
260246 let tileCount = 0 ;
261247
262- if ( ! this . _opts . sixelScrolling ) {
248+ if ( ! scrolling ) {
263249 buffer . x = 0 ;
264250 buffer . y = 0 ;
265251 offset = 0 ;
@@ -273,7 +259,7 @@ export class ImageStorage implements IDisposable {
273259 this . _writeToCell ( line as IBufferLineExt , offset + col , imageId , row * cols + col ) ;
274260 tileCount ++ ;
275261 }
276- if ( this . _opts . sixelScrolling ) {
262+ if ( scrolling ) {
277263 if ( row < rows - 1 ) this . _terminal . _core . _inputHandler . lineFeed ( ) ;
278264 } else {
279265 if ( ++ buffer . y >= termRows ) break ;
@@ -283,7 +269,7 @@ export class ImageStorage implements IDisposable {
283269 this . _terminal . _core . _inputHandler . _dirtyRowTracker . markDirty ( buffer . y ) ;
284270
285271 // cursor positioning modes
286- if ( this . _opts . sixelScrolling ) {
272+ if ( scrolling ) {
287273 buffer . x = offset ;
288274 } else {
289275 buffer . x = originX ;
@@ -331,6 +317,7 @@ export class ImageStorage implements IDisposable {
331317
332318 // finally add the image
333319 this . _images . set ( imageId , imgSpec ) ;
320+ return imageId ;
334321 }
335322
336323
0 commit comments