MCPcopy Create free account
hub / github.com/Noumena-Network/code / rowFitsWithinWidth

Function rowFitsWithinWidth

src/ink/log-update.ts:898–940  ·  view source on GitHub ↗
(
  frame: Frame,
  row: number,
  widthLimit: number,
)

Source from the content-addressed store, hash-verified

896}
897
898function rowFitsWithinWidth(
899 frame: Frame,
900 row: number,
901 widthLimit: number,
902): boolean {
903 if (row < 0 || row >= frame.screen.height) {
904 return true
905 }
906
907 const { width, cells, charPool, hyperlinkPool } = frame.screen
908 const scanWidth = Math.min(width, frame.viewport.width)
909 const rowStart = row * width
910 let lastRenderedStyleId = -1
911 const scratchCell: Cell = {
912 char: ' ',
913 styleId: 0,
914 width: CellWidth.Narrow,
915 hyperlink: undefined,
916 }
917
918 for (let x = 0; x < scanWidth; x += 1) {
919 if (
920 !visibleCellAtIndexInto(
921 cells,
922 charPool,
923 hyperlinkPool,
924 rowStart + x,
925 lastRenderedStyleId,
926 scratchCell,
927 )
928 ) {
929 continue
930 }
931 const cell = scratchCell
932 const cellWidth = cell.width === CellWidth.Wide ? 2 : 1
933 if (x + cellWidth > widthLimit) {
934 return false
935 }
936 lastRenderedStyleId = cell.styleId
937 }
938
939 return true
940}
941
942function rowLeavesRightMargin(
943 frame: Frame,

Callers 1

Calls 1

visibleCellAtIndexIntoFunction · 0.85

Tested by

no test coverage detected