General.Web/wwwroot/lib/codemirror-5.31.0/src/line/highlight.js
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
import { countColumn } from "../util/misc"
import { copyState, innerMode, startState } from "../modes"
import StringStream from "../util/StringStream"
import { getLine, lineNo } from "./utils_line"
import { clipPos } from "./pos"
class SavedContext {
constructor(state, lookAhead) {
this.state = state
this.lookAhead = lookAhead
}
}
class Context {
constructor(doc, state, line, lookAhead) {
this.state = state
this.doc = doc
this.line = line
this.maxLookAhead = lookAhead || 0
this.baseTokens = null
this.baseTokenPos = 1
}
lookAhead(n) {
let line = this.doc.getLine(this.line + n)
if (line != null && n > this.maxLookAhead) this.maxLookAhead = n
return line
}
baseToken(n) {
if (!this.baseTokens) return null
while (this.baseTokens[this.baseTokenPos] <= n)
this.baseTokenPos += 2
let type = this.baseTokens[this.baseTokenPos + 1]
return {type: type && type.replace(/( |^)overlay .*/, ""),
size: this.baseTokens[this.baseTokenPos] - n}
}
nextLine() {
this.line++
if (this.maxLookAhead > 0) this.maxLookAhead--
}
static fromSaved(doc, saved, line) {
if (saved instanceof SavedContext)
return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead)
else
return new Context(doc, copyState(doc.mode, saved), line)
}
save(copy) {
let state = copy !== false ? copyState(this.doc.mode, this.state) : this.state
return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state
}
}
// Compute a style array (an array starting with a mode generation
// -- for invalidation -- followed by pairs of end positions and
后面还有 224 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
