MCPcopy Create free account
hub / github.com/breck7/scroll / insertLineContent

Function insertLineContent

external/.scrollLibs.js:3063–3181  ·  view source on GitHub ↗
(line, builder, styles)

Source from the content-addressed store, hash-verified

3061 // Outputs a number of spans to make up a line, taking highlighting
3062 // and marked text into account.
3063 function insertLineContent(line, builder, styles) {
3064 var spans = line.markedSpans,
3065 allText = line.text,
3066 at = 0
3067 if (!spans) {
3068 for (var i$1 = 1; i$1 < styles.length; i$1 += 2) {
3069 builder.addToken(builder, allText.slice(at, (at = styles[i$1])), interpretTokenStyle(styles[i$1 + 1], builder.cm.options))
3070 }
3071 return
3072 }
3073
3074 var len = allText.length,
3075 pos = 0,
3076 i = 1,
3077 text = "",
3078 style,
3079 css
3080 var nextChange = 0,
3081 spanStyle,
3082 spanEndStyle,
3083 spanStartStyle,
3084 collapsed,
3085 attributes
3086 for (;;) {
3087 if (nextChange == pos) {
3088 // Update current marker set
3089 spanStyle = spanEndStyle = spanStartStyle = css = ""
3090 attributes = null
3091 collapsed = null
3092 nextChange = Infinity
3093 var foundBookmarks = [],
3094 endStyles = void 0
3095 for (var j = 0; j < spans.length; ++j) {
3096 var sp = spans[j],
3097 m = sp.marker
3098 if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
3099 foundBookmarks.push(m)
3100 } else if (sp.from <= pos && (sp.to == null || sp.to > pos || (m.collapsed && sp.to == pos && sp.from == pos))) {
3101 if (sp.to != null && sp.to != pos && nextChange > sp.to) {
3102 nextChange = sp.to
3103 spanEndStyle = ""
3104 }
3105 if (m.className) {
3106 spanStyle += " " + m.className
3107 }
3108 if (m.css) {
3109 css = (css ? css + ";" : "") + m.css
3110 }
3111 if (m.startStyle && sp.from == pos) {
3112 spanStartStyle += " " + m.startStyle
3113 }
3114 if (m.endStyle && sp.to == nextChange) {
3115 ;(endStyles || (endStyles = [])).push(m.endStyle, sp.to)
3116 }
3117 // support for the old title property
3118 // https://github.com/codemirror/CodeMirror/pull/5673
3119 if (m.title) {
3120 ;(attributes || (attributes = {})).title = m.title

Callers 1

buildLineContentFunction · 0.85

Calls 5

interpretTokenStyleFunction · 0.85
compareCollapsedMarkersFunction · 0.85
buildCollapsedSpanFunction · 0.85
sliceMethod · 0.80
minMethod · 0.80

Tested by

no test coverage detected