MCPcopy Create free account
hub / github.com/sql-js/sql.js / buildToken

Function buildToken

GUI/codemirror/lib/codemirror.js:5763–5811  ·  view source on GitHub ↗
(builder, text, style, startStyle, endStyle, title)

Source from the content-addressed store, hash-verified

5761 // Build up the DOM representation for a single token, and add it to
5762 // the line map. Takes care to render special characters separately.
5763 function buildToken(builder, text, style, startStyle, endStyle, title) {
5764 if (!text) return;
5765 var special = builder.cm.options.specialChars, mustWrap = false;
5766 if (!special.test(text)) {
5767 builder.col += text.length;
5768 var content = document.createTextNode(text);
5769 builder.map.push(builder.pos, builder.pos + text.length, content);
5770 if (ie_upto8) mustWrap = true;
5771 builder.pos += text.length;
5772 } else {
5773 var content = document.createDocumentFragment(), pos = 0;
5774 while (true) {
5775 special.lastIndex = pos;
5776 var m = special.exec(text);
5777 var skipped = m ? m.index - pos : text.length - pos;
5778 if (skipped) {
5779 var txt = document.createTextNode(text.slice(pos, pos + skipped));
5780 if (ie_upto8) content.appendChild(elt("span", [txt]));
5781 else content.appendChild(txt);
5782 builder.map.push(builder.pos, builder.pos + skipped, txt);
5783 builder.col += skipped;
5784 builder.pos += skipped;
5785 }
5786 if (!m) break;
5787 pos += skipped + 1;
5788 if (m[0] == "\t") {
5789 var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
5790 var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
5791 builder.col += tabWidth;
5792 } else {
5793 var txt = builder.cm.options.specialCharPlaceholder(m[0]);
5794 if (ie_upto8) content.appendChild(elt("span", [txt]));
5795 else content.appendChild(txt);
5796 builder.col += 1;
5797 }
5798 builder.map.push(builder.pos, builder.pos + 1, txt);
5799 builder.pos++;
5800 }
5801 }
5802 if (style || startStyle || endStyle || mustWrap) {
5803 var fullStyle = style || "";
5804 if (startStyle) fullStyle += startStyle;
5805 if (endStyle) fullStyle += endStyle;
5806 var token = elt("span", [content], fullStyle);
5807 if (title) token.title = title;
5808 return builder.content.appendChild(token);
5809 }
5810 builder.content.appendChild(content);
5811 }
5812
5813 function buildTokenSplitSpaces(inner) {
5814 function split(old) {

Callers

nothing calls this directly

Calls 2

eltFunction · 0.85
spaceStrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…