MCPcopy Create free account
hub / github.com/TruthHun/BookStack / drawForLine

Function drawForLine

static/editor.md/lib/codemirror/lib/codemirror.js:2253–2287  ·  view source on GitHub ↗
(line, fromArg, toArg)

Source from the content-addressed store, hash-verified

2251 }
2252
2253 function drawForLine(line, fromArg, toArg) {
2254 var lineObj = getLine(doc, line);
2255 var lineLen = lineObj.text.length;
2256 var start, end;
2257 function coords(ch, bias) {
2258 return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
2259 }
2260
2261 iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
2262 var leftPos = coords(from, "left"), rightPos, left, right;
2263 if (from == to) {
2264 rightPos = leftPos;
2265 left = right = leftPos.left;
2266 } else {
2267 rightPos = coords(to - 1, "right");
2268 if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
2269 left = leftPos.left;
2270 right = rightPos.right;
2271 }
2272 if (fromArg == null && from == 0) left = leftSide;
2273 if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
2274 add(left, leftPos.top, null, leftPos.bottom);
2275 left = leftSide;
2276 if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
2277 }
2278 if (toArg == null && to == lineLen) right = rightSide;
2279 if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
2280 start = leftPos;
2281 if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
2282 end = rightPos;
2283 if (left < leftSide + 1) left = leftSide;
2284 add(left, rightPos.top, right - left, rightPos.bottom);
2285 });
2286 return {start: start, end: end};
2287 }
2288
2289 var sFrom = range.from(), sTo = range.to();
2290 if (sFrom.line == sTo.line) {

Callers 1

drawSelectionRangeFunction · 0.70

Calls 5

getLineFunction · 0.70
iterateBidiSectionsFunction · 0.70
getOrderFunction · 0.70
coordsFunction · 0.70
addFunction · 0.70

Tested by

no test coverage detected