MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / drawForLine

Function drawForLine

static/js/codemirror/codemirror.js:775–798  ·  view source on GitHub ↗
(line, fromArg, toArg, retTop)

Source from the content-addressed store, hash-verified

773 }
774
775 function drawForLine(line, fromArg, toArg, retTop) {
776 var lineObj = getLine(doc, line);
777 var lineLen = lineObj.text.length, rVal = retTop ? Infinity : -Infinity;
778 function coords(ch) {
779 return charCoords(cm, Pos(line, ch), "div", lineObj);
780 }
781
782 iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
783 var leftPos = coords(dir == "rtl" ? to - 1 : from);
784 var rightPos = coords(dir == "rtl" ? from : to - 1);
785 var left = leftPos.left, right = rightPos.right;
786 if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
787 add(left, leftPos.top, null, leftPos.bottom);
788 left = pl;
789 if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
790 }
791 if (toArg == null && to == lineLen) right = clientWidth;
792 if (fromArg == null && from == 0) left = pl;
793 rVal = retTop ? Math.min(rightPos.top, rVal) : Math.max(rightPos.bottom, rVal);
794 if (left < pl + 1) left = pl;
795 add(left, rightPos.top, right - left, rightPos.bottom);
796 });
797 return rVal;
798 }
799
800 if (sel.from.line == sel.to.line) {
801 drawForLine(sel.from.line, sel.from.ch, sel.to.ch);

Callers 1

updateSelectionRangeFunction · 0.85

Calls 5

getLineFunction · 0.85
iterateBidiSectionsFunction · 0.85
getOrderFunction · 0.85
coordsFunction · 0.85
addFunction · 0.85

Tested by

no test coverage detected