(cm, line, state, forceToEnd)
| 5579 | // style strings), which is used to highlight the tokens on the |
| 5580 | // line. |
| 5581 | function highlightLine(cm, line, state, forceToEnd) { |
| 5582 | // A styles array always starts with a number identifying the |
| 5583 | // mode/overlays that it is based on (for easy invalidation). |
| 5584 | var st = [cm.state.modeGen], lineClasses = {}; |
| 5585 | // Compute the base array of styles |
| 5586 | runMode(cm, line.text, cm.doc.mode, state, function(end, style) { |
| 5587 | st.push(end, style); |
| 5588 | }, lineClasses, forceToEnd); |
| 5589 | |
| 5590 | // Run overlays, adjust style array. |
| 5591 | for (var o = 0; o < cm.state.overlays.length; ++o) { |
| 5592 | var overlay = cm.state.overlays[o], i = 1, at = 0; |
| 5593 | runMode(cm, line.text, overlay.mode, true, function(end, style) { |
| 5594 | var start = i; |
| 5595 | // Ensure there's a token end at the current position, and that i points at it |
| 5596 | while (at < end) { |
| 5597 | var i_end = st[i]; |
| 5598 | if (i_end > end) |
| 5599 | st.splice(i, 1, end, st[i+1], i_end); |
| 5600 | i += 2; |
| 5601 | at = Math.min(end, i_end); |
| 5602 | } |
| 5603 | if (!style) return; |
| 5604 | if (overlay.opaque) { |
| 5605 | st.splice(start, i - start, end, style); |
| 5606 | i = start + 2; |
| 5607 | } else { |
| 5608 | for (; start < i; start += 2) { |
| 5609 | var cur = st[start+1]; |
| 5610 | st[start+1] = cur ? cur + " " + style : style; |
| 5611 | } |
| 5612 | } |
| 5613 | }, lineClasses); |
| 5614 | } |
| 5615 | |
| 5616 | return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}; |
| 5617 | } |
| 5618 | |
| 5619 | function getLineStyles(cm, line) { |
| 5620 | if (!line.styles || line.styles[0] != cm.state.modeGen) { |
no test coverage detected