code
import {...} from "@revideo/2d/lib/code";
Classes
Interfaces
CodeFragment
CodeFragmentDrawingInfo
CodeHighlighter
CodeScope
CodeSignalHelpers
HighlightResult
RawCodeFragment
Type Aliases
CodeDiffer
CodePoint
type CodePoint = numbernumber
CodeRange
CodeSelection
type CodeSelection = CodeRange[]
CodeSignal
Type Parameters
CodeTag
type CodeTag = SignalValuePossibleCodeFragmentCodeScopeCodeTag[]
CodeTokenizer
type CodeTokenizer = input: string => string[]
PossibleCodeFragment
type PossibleCodeFragment = CodeFragmentCodeMetricsRawCodeFragmentstring
PossibleCodeScope
PossibleCodeSelection
Variables
DefaultHighlightStyle
const DefaultHighlightStyle: HighlightStyle = ...
Functions
CODE
Parameters
codeSignal
public codeSignal(): PropertyDecorator
consolidateCodeRanges
Parameters
defaultDiffer
Default diffing function utilizing patienceDiff
.
Parameters
from: CodeScope
The original code scope.
to: CodeScope
The new code scope.
tokenize: CodeTokenizer
The inherited tokenizer to use.
defaultTokenize
public defaultTokenizeinput: string: string[]
Default tokenizer function used by ownerless code signals.
Parameters
input: string
The code to tokenize.
extractRange
Transform the fragments to isolate the given range into its own fragment.
This function will try to preserve the original fragments, resolving them only if they overlap with the range.
Parameters
findAllCodeRanges
Find all code ranges that match the given pattern.
Parameters
code: string
The code to search in.
pattern: stringRegExp
Either a string or a regular expression to search for.
limit: number = Infinity
An optional limit on the number of ranges to find.
insert
public insertcode: string: RawCodeFragment
Create a code fragment that represents an insertion of code.
Can be used in conjunction with edit
.
Parameters
code: string
The code to insert.
inverseCodeRange
Parameters
isCodeRange
Parameters
value: unknown
isCodeScope
Parameters
value: any
isPointInCodeRange
Parameters
isPointInCodeSelection
public isPointInCodeSelectionpoint: CodePointselection: CodeSelection: boolean
Parameters
lines
Create a code range that spans the given lines.
Parameters
from: number
The line from which the range starts.
to?: number
The line at which the range ends. If omitted, the range will cover only one line.
metricsToFragment
public metricsToFragmentvalue: CodeMetrics: CodeFragment
Parameters
value: CodeMetrics
parseCodeFragment
public parseCodeFragmentvalue: PossibleCodeFragmentcontext: CanvasRenderingContext2DmonoWidth: number: CodeFragment
Parameters
parseCodeScope
public parseCodeScopevalue: PossibleCodeScope: CodeScope
Parameters
parseCodeSelection
public parseCodeSelectionvalue: PossibleCodeSelection: CodeSelection
Parameters
patienceDiff
public patienceDiffaLines: string[]bLines: string[]: lineCountDeleted: numberlineCountInserted: numberlines: aIndex: numberbIndex: numberline: string[]
Performs a patience diff on two arrays of strings, returning an object containing the lines that were deleted, inserted, and potentially moved lines. The plus parameter can result in a significant performance hit due to additional Longest Common Substring searches.
Parameters
pointToPoint
public pointToPointstartLine: numberstartColumn: numberendLine: numberendColumn: number: CodeRange
Create a custom selection range.
Parameters
startLine: number
The line at which the selection starts.
startColumn: number
The column at which the selection starts.
endLine: number
The line at which the selection ends.
endColumn: number
The column at which the selection ends.
remove
public removecode: string: RawCodeFragment
Create a code fragment that represents a removal of code.
Can be used in conjunction with edit
.
Parameters
code: string
The code to remove.
replace
public replacebefore: stringafter: string: RawCodeFragment
Create a code fragment that represents a change from one piece of code to another.
Can be used in conjunction with edit
.
Parameters
resolveCodeTag
Parameters
resolveScope
Parameters
word
Create a code range that highlights the given word.