68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { c as _c } from "react/compiler-runtime";
|
|
import React, { type PropsWithChildren } from 'react';
|
|
import Box, { type Props as BoxProps } from './Box.js';
|
|
|
|
type Props = Omit<BoxProps, 'noSelect'> & {
|
|
/**
|
|
* 将排除区域从第 0 列扩展到此盒子的右边缘,
|
|
* 适用于此盒子占据的每一行。用于在更宽的缩进容器内
|
|
* 呈现的边沟(例如工具消息行内的差异):
|
|
* 没有这个,多行拖动会在前缀以下的行上
|
|
* 拾取容器的领先缩进。
|
|
*
|
|
* @default false
|
|
*/
|
|
fromLeftEdge?: boolean;
|
|
};
|
|
|
|
/**
|
|
* 在全屏文本选择中将其内容标记为不可选择。
|
|
* 此框内的单元格会被选择高亮和复制文本跳过——
|
|
* 用户拖动时边沟保持视觉上不变,
|
|
* 这样可以清楚地知道什么将被复制。
|
|
*
|
|
* 用于隔离边沟(行号、差异 +/- 符号、列表项目符号),
|
|
* 以便点击拖动渲染代码产生干净的可粘贴内容:
|
|
*
|
|
* <Box flexDirection="row">
|
|
* <NoSelect fromLeftEdge><Text dimColor> 42 +</Text></NoSelect>
|
|
* <Text>const x = 1</Text>
|
|
* </Box>
|
|
*
|
|
* 仅影响备用屏幕文本选择(带有鼠标跟踪的 <AlternateScreen>)。
|
|
* 在主屏幕滚动回渲染中无效——那里使用终端的本机选择。
|
|
*/
|
|
export function NoSelect(t0) {
|
|
const $ = _c(8);
|
|
let boxProps;
|
|
let children;
|
|
let fromLeftEdge;
|
|
if ($[0] !== t0) {
|
|
({
|
|
children,
|
|
fromLeftEdge,
|
|
...boxProps
|
|
} = t0);
|
|
$[0] = t0;
|
|
$[1] = boxProps;
|
|
$[2] = children;
|
|
$[3] = fromLeftEdge;
|
|
} else {
|
|
boxProps = $[1];
|
|
children = $[2];
|
|
fromLeftEdge = $[3];
|
|
}
|
|
const t1 = fromLeftEdge ? "from-left-edge" : true;
|
|
let t2;
|
|
if ($[4] !== boxProps || $[5] !== children || $[6] !== t1) {
|
|
t2 = <Box {...boxProps} noSelect={t1}>{children}</Box>;
|
|
$[4] = boxProps;
|
|
$[5] = children;
|
|
$[6] = t1;
|
|
$[7] = t2;
|
|
} else {
|
|
t2 = $[7];
|
|
}
|
|
return t2;
|
|
}
|