({
viewportWidth = 80,
viewportHeight,
screenHeight,
cursorY,
lines = [],
}: {
viewportWidth?: number
viewportHeight: number
screenHeight: number
cursorY: number
lines?: string[]
})
| 29 | } |
| 30 | |
| 31 | function makeFrame({ |
| 32 | viewportWidth = 80, |
| 33 | viewportHeight, |
| 34 | screenHeight, |
| 35 | cursorY, |
| 36 | lines = [], |
| 37 | }: { |
| 38 | viewportWidth?: number |
| 39 | viewportHeight: number |
| 40 | screenHeight: number |
| 41 | cursorY: number |
| 42 | lines?: string[] |
| 43 | }): Frame { |
| 44 | const screen = createScreen( |
| 45 | viewportWidth, |
| 46 | screenHeight, |
| 47 | stylePool, |
| 48 | charPool, |
| 49 | hyperlinkPool, |
| 50 | ) |
| 51 | |
| 52 | for (let y = 0; y < lines.length; y += 1) { |
| 53 | const line = lines[y] ?? '' |
| 54 | for (let x = 0; x < line.length; x += 1) { |
| 55 | setCellAt(screen, x, y, { |
| 56 | char: line[x]!, |
| 57 | styleId: stylePool.none, |
| 58 | width: CellWidth.Narrow, |
| 59 | hyperlink: undefined, |
| 60 | }) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | return { |
| 65 | screen, |
| 66 | viewport: { |
| 67 | width: viewportWidth, |
| 68 | height: viewportHeight, |
| 69 | }, |
| 70 | cursor: { |
| 71 | x: 0, |
| 72 | y: cursorY, |
| 73 | visible: true, |
| 74 | }, |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | describe('shouldResetForResize', () => { |
| 79 | it('skips destructive reset for height-only shrink when prior content and cursor still fit', () => { |
no test coverage detected