MCPcopy Create free account
hub / github.com/anomalyco/opencode / _nextCell

Method _nextCell

packages/app/src/addons/serialize.ts:411–458  ·  view source on GitHub ↗
(cell: IBufferCell, _oldCell: IBufferCell, row: number, col: number)

Source from the content-addressed store, hash-verified

409 }
410
411 protected _nextCell(cell: IBufferCell, _oldCell: IBufferCell, row: number, col: number): void {
412 const isPlaceHolderCell = cell.getWidth() === 0
413
414 if (isPlaceHolderCell) {
415 return
416 }
417
418 const codepoint = cell.getCode()
419 const isInvalidCodepoint = codepoint > 0x10ffff || (codepoint >= 0xd800 && codepoint <= 0xdfff)
420 const isGarbage = isInvalidCodepoint || (codepoint >= 0xf000 && cell.getWidth() === 1)
421 const isEmptyCell = codepoint === 0 || cell.getChars() === "" || isGarbage
422
423 const sgrSeq = this._diffStyle(cell, this._cursorStyle)
424
425 const styleChanged = sgrSeq.length > 0
426
427 if (styleChanged) {
428 if (this._nullCellCount > 0) {
429 this._currentRow += " ".repeat(this._nullCellCount)
430 this._nullCellCount = 0
431 }
432
433 this._lastContentCursorRow = this._lastCursorRow = row
434 this._lastContentCursorCol = this._lastCursorCol = col
435
436 this._currentRow += `\u001b[${sgrSeq.join(";")}m`
437
438 const line = this._buffer.getLine(row)
439 const cellFromLine = line?.getCell(col)
440 if (cellFromLine) {
441 this._cursorStyle = cellFromLine
442 }
443 }
444
445 if (isEmptyCell) {
446 this._nullCellCount += cell.getWidth()
447 } else {
448 if (this._nullCellCount > 0) {
449 this._currentRow += " ".repeat(this._nullCellCount)
450 this._nullCellCount = 0
451 }
452
453 this._currentRow += cell.getChars()
454
455 this._lastContentCursorRow = this._lastCursorRow = row
456 this._lastContentCursorCol = this._lastCursorCol = col + cell.getWidth()
457 }
458 }
459
460 protected _serializeString(excludeFinalCursorPosition?: boolean): string {
461 let rowEnd = this._allRows.length

Callers 1

serializeFunction · 0.80

Calls 6

_diffStyleMethod · 0.95
getWidthMethod · 0.80
getCodeMethod · 0.80
getCharsMethod · 0.80
getLineMethod · 0.80
getCellMethod · 0.80

Tested by

no test coverage detected