import { createContext } from 'react' import type { DOMElement } from '../dom.js' export type CursorDeclaration = { /** 声明节点内的显示列(终端单元格宽度) */ readonly relativeX: number /** 声明节点内的行号 */ readonly relativeY: number /** 其 yoga 布局提供绝对原点的 ink-box DOMElement */ readonly node: DOMElement } /** * 声明的光标位置的设置器。 * * 可选的第二个参数使 `null` 成为条件清除:声明仅在 * 当前声明的节点匹配 `clearIfNode` 时才被清除。 * 这使得 hook 对于兄弟组件(例如列表项)之间的焦点转移是安全的 * ——如果没有节点检查,新失焦项的清除可能会覆盖 * 新聚焦的兄弟项的设置,取决于布局效果的顺序。 */ export type CursorDeclarationSetter = ( declaration: CursorDeclaration | null, clearIfNode?: DOMElement | null, ) => void const CursorDeclarationContext = createContext( () => {}, ) export default CursorDeclarationContext