Class CodeShape

    A Shape rendering monospace source code as a list of Parts.

    Hierarchy
    Index

    Accessors

    • get svgRoot(): SVGSVGElement | null

      Nearest enclosing <svg> root, or null if this shape isn't mounted under one. Used by drag helpers that need world-space cursor coords.

      Returns SVGSVGElement | null

    Constructors

    Methods

    • Bind one SVG attribute; static sets once, reactive runs as effect.

      Parameters

      • name: string
      • val: Val<string | number>
      • target: "intrinsic" | "wrapper" = "intrinsic"

      Returns void

    • Bind several attributes at once — this.attrs({ cx, cy, r }).

      Parameters

      • map: Record<string, Val<string | number>>
      • target: "intrinsic" | "wrapper" = "intrinsic"

      Returns void

    • Split part at char offsets into N+1 same-row sub-parts (0 and text.length implicit). Sub-parts inherit part.key; returned left-to-right.

      Parameters

      • part: Part
      • offsets: readonly number[]

      Returns Part[]

    • All parts sharing key. Returns a fresh array.

      Parameters

      • key: string

      Returns Part[]

    • Parameters

      • name: string
      • handler: (e: Event) => void
      • Optionalopts: AddEventListenerOptions

      Returns () => void

    • Paint syntax highlights: tokenise each row's joined text, route each typed token to a Range in its containing part. Re-entrant (clears prior syntax Ranges; leaves other buckets untouched).

      Returns void

    • Wire stroke / fill / dashed for a stroked shape. nativeAttrs binds the shape's native geometry (e.g. {cx, cy, r} for circle); it's skipped when opts.dashed since the intrinsic is then a <path> whose d is driven by segments().

      Parameters

      • opts: CommonOpts
      • closed: boolean
      • OptionalnativeAttrs: Record<string, Val<string | number>>

      Returns void

    • Map client coords into this shape's local frame.

      Parameters

      • evt: { clientX: number; clientY: number }

      Returns V

    • Map client coords into the SVG root's frame; stable under rotation (unlike toLocal). Returns (0, 0) when detached.

      Parameters

      • evt: { clientX: number; clientY: number }

      Returns V

    • Register a disposer to run on dispose().

      Parameters

      • dispose: () => void

      Returns void

    • Merge same-row contiguous parts into one (inherits the leftmost's key). Single part is a no-op; empty throws.

      Parameters

      • parts: readonly Part[]

      Returns Part

    Properties

    aside: boolean
    box: Box

    Local-frame box; reach into .x, .center, .at(u,v), etc.

    charW: number

    Monospace char width and line height in CSS pixels.

    el: SVGGElement
    height: Writable<Cell<number>>
    intrinsic?: SVGElement
    language: string
    lineH: number
    localFrame: Cell<V>

    Composed local-frame matrix: T(t) T(p) R(r) S(s) T(-p).

    opacity: Writable<Num>
    origin: Writable<Vec>
    parent: AnyShape | null = null

    Back-link set by add(); cleared by dispose(). Non-reactive.

    parts: Part[] = []

    Flat parts list; morph re-sorts by (row, col) on completion.

    rotate: Writable<Num>
    scale: Writable<Vec>
    source: Writable<Cell<string>>
    translate: Writable<Vec>
    width: Writable<Cell<number>>
    wrapper: HTMLDivElement

    Host wrapper (position: relative) for the absolute parts.