Render one split-view cell as prefix + gutter + content spans.
(
cell: SplitLineCell,
width: number,
lineNumberDigits: number,
showLineNumbers: boolean,
theme: AppTheme,
keyPrefix: string,
contentOffset = 0,
prefix?: {
text: string;
fg: string;
bg: string;
},
selected = false,
selectionColRange?: CopySelectedRowRange,
paneOffset = 0,
)
| 851 | |
| 852 | /** Render one split-view cell as prefix + gutter + content spans. */ |
| 853 | function renderSplitCell( |
| 854 | cell: SplitLineCell, |
| 855 | width: number, |
| 856 | lineNumberDigits: number, |
| 857 | showLineNumbers: boolean, |
| 858 | theme: AppTheme, |
| 859 | keyPrefix: string, |
| 860 | contentOffset = 0, |
| 861 | prefix?: { |
| 862 | text: string; |
| 863 | fg: string; |
| 864 | bg: string; |
| 865 | }, |
| 866 | selected = false, |
| 867 | selectionColRange?: CopySelectedRowRange, |
| 868 | paneOffset = 0, |
| 869 | ) { |
| 870 | const basePalette = splitCellPalette(cell.kind, theme, cell.moveKind); |
| 871 | const palette = selected ? applySelectionPalette(basePalette, theme) : basePalette; |
| 872 | const resolvedPrefix = selected && prefix ? applySelectionPrefix(prefix, theme) : prefix; |
| 873 | const prefixWidth = resolvedPrefix?.text.length ?? 0; |
| 874 | const { gutterWidth, contentWidth } = resolveSplitCellGeometry( |
| 875 | width, |
| 876 | lineNumberDigits, |
| 877 | showLineNumbers, |
| 878 | prefixWidth, |
| 879 | ); |
| 880 | const gutterText = splitGutterText(cell, lineNumberDigits, showLineNumbers).padEnd(gutterWidth); |
| 881 | |
| 882 | // Convert global selection column range to content-local range. |
| 883 | const globalContentStart = paneOffset + prefixWidth + gutterWidth; |
| 884 | const localColRange = |
| 885 | selectionColRange && globalContentStart < selectionColRange.endCol |
| 886 | ? { |
| 887 | start: Math.max(0, selectionColRange.startCol - globalContentStart), |
| 888 | end: Math.min( |
| 889 | contentWidth, |
| 890 | Math.max(0, selectionColRange.endCol - globalContentStart + 1), |
| 891 | ), |
| 892 | } |
| 893 | : undefined; |
| 894 | |
| 895 | return ( |
| 896 | <> |
| 897 | {resolvedPrefix ? ( |
| 898 | <span key={`${keyPrefix}:prefix`} fg={resolvedPrefix.fg} bg={resolvedPrefix.bg}> |
| 899 | {resolvedPrefix.text} |
| 900 | </span> |
| 901 | ) : null} |
| 902 | <span key={`${keyPrefix}:gutter`} fg={palette.numberColor} bg={palette.gutterBg}> |
| 903 | {gutterText} |
| 904 | </span> |
| 905 | {renderInlineSpans( |
| 906 | cell.spans, |
| 907 | contentWidth, |
| 908 | theme.syntaxColors.default, |
| 909 | palette.contentBg, |
| 910 | `${keyPrefix}:content`, |
no test coverage detected