(line, builder, styles)
| 1987 | // Outputs a number of spans to make up a line, taking highlighting |
| 1988 | // and marked text into account. |
| 1989 | function insertLineContent(line, builder, styles) { |
| 1990 | var spans = line.markedSpans, allText = line.text, at = 0; |
| 1991 | if (!spans) { |
| 1992 | for (var i$1 = 1; i$1 < styles.length; i$1+=2) |
| 1993 | { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); } |
| 1994 | return |
| 1995 | } |
| 1996 | |
| 1997 | var len = allText.length, pos = 0, i = 1, text = "", style, css; |
| 1998 | var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed; |
| 1999 | for (;;) { |
| 2000 | if (nextChange == pos) { // Update current marker set |
| 2001 | spanStyle = spanEndStyle = spanStartStyle = title = css = ""; |
| 2002 | collapsed = null; nextChange = Infinity; |
| 2003 | var foundBookmarks = [], endStyles = (void 0); |
| 2004 | for (var j = 0; j < spans.length; ++j) { |
| 2005 | var sp = spans[j], m = sp.marker; |
| 2006 | if (m.type == "bookmark" && sp.from == pos && m.widgetNode) { |
| 2007 | foundBookmarks.push(m); |
| 2008 | } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) { |
| 2009 | if (sp.to != null && sp.to != pos && nextChange > sp.to) { |
| 2010 | nextChange = sp.to; |
| 2011 | spanEndStyle = ""; |
| 2012 | } |
| 2013 | if (m.className) { spanStyle += " " + m.className; } |
| 2014 | if (m.css) { css = (css ? css + ";" : "") + m.css; } |
| 2015 | if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; } |
| 2016 | if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); } |
| 2017 | if (m.title && !title) { title = m.title; } |
| 2018 | if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) |
| 2019 | { collapsed = sp; } |
| 2020 | } else if (sp.from > pos && nextChange > sp.from) { |
| 2021 | nextChange = sp.from; |
| 2022 | } |
| 2023 | } |
| 2024 | if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2) |
| 2025 | { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } } |
| 2026 | |
| 2027 | if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2) |
| 2028 | { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } } |
| 2029 | if (collapsed && (collapsed.from || 0) == pos) { |
| 2030 | buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, |
| 2031 | collapsed.marker, collapsed.from == null); |
| 2032 | if (collapsed.to == null) { return } |
| 2033 | if (collapsed.to == pos) { collapsed = false; } |
| 2034 | } |
| 2035 | } |
| 2036 | if (pos >= len) { break } |
| 2037 | |
| 2038 | var upto = Math.min(len, nextChange); |
| 2039 | while (true) { |
| 2040 | if (text) { |
| 2041 | var end = pos + text.length; |
| 2042 | if (!collapsed) { |
| 2043 | var tokenText = end > upto ? text.slice(0, upto - pos) : text; |
| 2044 | builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, |
| 2045 | spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css); |
| 2046 | } |
no test coverage detected