(cm, line, state, forceToEnd)
| 6627 | // style strings), which is used to highlight the tokens on the |
| 6628 | // line. |
| 6629 | function highlightLine(cm, line, state, forceToEnd) { |
| 6630 | // A styles array always starts with a number identifying the |
| 6631 | // mode/overlays that it is based on (for easy invalidation). |
| 6632 | var st = [cm.state.modeGen], lineClasses = {}; |
| 6633 | // Compute the base array of styles |
| 6634 | runMode(cm, line.text, cm.doc.mode, state, function(end, style) { |
| 6635 | st.push(end, style); |
| 6636 | }, lineClasses, forceToEnd); |
| 6637 | |
| 6638 | // Run overlays, adjust style array. |
| 6639 | for (var o = 0; o < cm.state.overlays.length; ++o) { |
| 6640 | var overlay = cm.state.overlays[o], i = 1, at = 0; |
| 6641 | runMode(cm, line.text, overlay.mode, true, function(end, style) { |
| 6642 | var start = i; |
| 6643 | // Ensure there's a token end at the current position, and that i points at it |
| 6644 | while (at < end) { |
| 6645 | var i_end = st[i]; |
| 6646 | if (i_end > end) |
| 6647 | st.splice(i, 1, end, st[i+1], i_end); |
| 6648 | i += 2; |
| 6649 | at = Math.min(end, i_end); |
| 6650 | } |
| 6651 | if (!style) return; |
| 6652 | if (overlay.opaque) { |
| 6653 | st.splice(start, i - start, end, "cm-overlay " + style); |
| 6654 | i = start + 2; |
| 6655 | } else { |
| 6656 | for (; start < i; start += 2) { |
| 6657 | var cur = st[start+1]; |
| 6658 | st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style; |
| 6659 | } |
| 6660 | } |
| 6661 | }, lineClasses); |
| 6662 | } |
| 6663 | |
| 6664 | return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}; |
| 6665 | } |
| 6666 | |
| 6667 | function getLineStyles(cm, line, updateFrontier) { |
| 6668 | if (!line.styles || line.styles[0] != cm.state.modeGen) { |
no test coverage detected