MCPcopy Index your code
hub / github.com/codeaashu/claude-code / intern

Method intern

src/ink/screen.ts:129–141  ·  view source on GitHub ↗

* Intern a style and return its ID. Bit 0 of the ID encodes whether the * style has a visible effect on space characters (background, inverse, * underline, etc.). Foreground-only styles get even IDs; styles visible * on spaces get odd IDs. This lets the renderer skip invisible spaces * w

(styles: AnsiCode[])

Source from the content-addressed store, hash-verified

127 * with a single bitmask check on the packed word.
128 */
129 intern(styles: AnsiCode[]): number {
130 const key = styles.length === 0 ? '' : styles.map(s => s.code).join('\0')
131 let id = this.ids.get(key)
132 if (id === undefined) {
133 const rawId = this.styles.length
134 this.styles.push(styles.length === 0 ? [] : styles)
135 id =
136 (rawId << 1) |
137 (styles.length > 0 && hasVisibleSpaceEffect(styles) ? 1 : 0)
138 this.ids.set(key, id)
139 }
140 return id
141 }
142
143 /** Recover styles from an encoded ID. Strips the bit-0 flag via >>> 1. */
144 get(id: number): AnsiCode[] {

Callers 4

constructorMethod · 0.95
withInverseMethod · 0.95
withCurrentMatchMethod · 0.95
withSelectionBgMethod · 0.95

Calls 4

hasVisibleSpaceEffectFunction · 0.85
getMethod · 0.65
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected