MCPcopy
hub / github.com/csev/py4e / buildLineContent

Function buildLineContent

tools/pythonauto/static/codemirrorepl/codemirror.js:5659–5703  ·  view source on GitHub ↗
(cm, lineView)

Source from the content-addressed store, hash-verified

5657 // The returned object contains the DOM node, this map, and
5658 // information about line-wide styles that were set by the mode.
5659 function buildLineContent(cm, lineView) {
5660 // The padding-right forces the element to have a 'border', which
5661 // is needed on Webkit to be able to get line-level bounding
5662 // rectangles for it (in measureChar).
5663 var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
5664 var builder = {pre: elt("pre", [content]), content: content, col: 0, pos: 0, cm: cm};
5665 lineView.measure = {};
5666
5667 // Iterate over the logical lines that make up this visual line.
5668 for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
5669 var line = i ? lineView.rest[i - 1] : lineView.line, order;
5670 builder.pos = 0;
5671 builder.addToken = buildToken;
5672 // Optionally wire in some hacks into the token-rendering
5673 // algorithm, to deal with browser quirks.
5674 if ((ie || webkit) && cm.getOption("lineWrapping"))
5675 builder.addToken = buildTokenSplitSpaces(builder.addToken);
5676 if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
5677 builder.addToken = buildTokenBadBidi(builder.addToken, order);
5678 builder.map = [];
5679 insertLineContent(line, builder, getLineStyles(cm, line));
5680 if (line.styleClasses) {
5681 if (line.styleClasses.bgClass)
5682 builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
5683 if (line.styleClasses.textClass)
5684 builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
5685 }
5686
5687 // Ensure at least a single node is present, for measuring.
5688 if (builder.map.length == 0)
5689 builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
5690
5691 // Store the map and a cache object for the current logical line
5692 if (i == 0) {
5693 lineView.measure.map = builder.map;
5694 lineView.measure.cache = {};
5695 } else {
5696 (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
5697 (lineView.measure.caches || (lineView.measure.caches = [])).push({});
5698 }
5699 }
5700
5701 signal(cm, "renderLine", cm, lineView.line, builder.pre);
5702 return builder;
5703 }
5704
5705 function defaultSpecialCharPlaceholder(ch) {
5706 var token = elt("span", "\u2022", "cm-invalidchar");

Callers 2

getLineContentFunction · 0.70

Calls 11

hasBadBidiRectsFunction · 0.85
buildTokenBadBidiFunction · 0.85
joinClassesFunction · 0.85
signalFunction · 0.85
eltFunction · 0.70
buildTokenSplitSpacesFunction · 0.70
getOrderFunction · 0.70
insertLineContentFunction · 0.70
getLineStylesFunction · 0.70
zeroWidthElementFunction · 0.70
appendChildMethod · 0.45

Tested by

no test coverage detected