Skip to content

code/editor/useRevealLine

import { … } from 'zidane-ui/code/editor'ui/src/code/editor/useRevealLine.ts

Functions#

useRevealLineFunction#

Scrolls a CodeEditor to reveal, selects its line and, when caret, places the caret there; see the module comment.

TypeScript
function useRevealLine(
  editor: RefObject<CodeEditorHandle | null>,
  reveal: RevealTarget | null | undefined,
  select: (line: number) => void,
  caret: boolean,
): void
Parameters
NameTypeDescription
editorRefObject<CodeEditorHandle | null>

The editor's handle.

revealRevealTarget | null | undefined

Where to go, once per nonce.

select(line: number) => void

Selects the line (the owner's selection state).

caretboolean

Whether to place the caret (an editable view).

ui/src/code/editor/useRevealLine.ts:36

Interfaces#

RevealTargetInterface#

A 1-based position to reveal; a new nonce reveals the same one again.

TypeScript
interface RevealTarget
RevealTarget properties
NameTypeDescription
columnnumber

1-based column where the caret lands.

linenumber

1-based line to select and centre.

noncenumber

Bump it to reveal the same position again.

ui/src/code/editor/useRevealLine.ts:16