(cm, line, state)
| 3878 | } |
| 3879 | |
| 3880 | function highlightLine(cm, line, state) { |
| 3881 | // A styles array always starts with a number identifying the |
| 3882 | // mode/overlays that it is based on (for easy invalidation). |
| 3883 | var st = [cm.state.modeGen]; |
| 3884 | // Compute the base array of styles |
| 3885 | runMode(cm, line.text, cm.doc.mode, state, function(txt, style) {st.push(txt, style);}); |
| 3886 | |
| 3887 | // Run overlays, adjust style array. |
| 3888 | for (var o = 0; o < cm.state.overlays.length; ++o) { |
| 3889 | var overlay = cm.state.overlays[o], i = 1; |
| 3890 | runMode(cm, line.text, overlay.mode, true, function(txt, style) { |
| 3891 | var start = i, len = txt.length; |
| 3892 | // Ensure there's a token end at the current position, and that i points at it |
| 3893 | while (len) { |
| 3894 | var cur = st[i], len_ = cur.length; |
| 3895 | if (len_ <= len) { |
| 3896 | len -= len_; |
| 3897 | } else { |
| 3898 | st.splice(i, 1, cur.slice(0, len), st[i+1], cur.slice(len)); |
| 3899 | len = 0; |
| 3900 | } |
| 3901 | i += 2; |
| 3902 | } |
| 3903 | if (!style) return; |
| 3904 | if (overlay.opaque) { |
| 3905 | st.splice(start, i - start, txt, style); |
| 3906 | i = start + 2; |
| 3907 | } else { |
| 3908 | for (; start < i; start += 2) { |
| 3909 | var cur = st[start+1]; |
| 3910 | st[start+1] = cur ? cur + " " + style : style; |
| 3911 | } |
| 3912 | } |
| 3913 | }); |
| 3914 | } |
| 3915 | |
| 3916 | return st; |
| 3917 | } |
| 3918 | |
| 3919 | function getLineStyles(cm, line) { |
| 3920 | if (!line.styles || line.styles[0] != cm.state.modeGen) |
no test coverage detected