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

Function drawForLine

static/mergely/lib/codemirror.js:2356–2390  ·  view source on GitHub ↗
(line, fromArg, toArg)

Source from the content-addressed store, hash-verified

2354 }
2355
2356 function drawForLine(line, fromArg, toArg) {
2357 var lineObj = getLine(doc, line);
2358 var lineLen = lineObj.text.length;
2359 var start, end;
2360 function coords(ch, bias) {
2361 return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
2362 }
2363
2364 iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
2365 var leftPos = coords(from, "left"), rightPos, left, right;
2366 if (from == to) {
2367 rightPos = leftPos;
2368 left = right = leftPos.left;
2369 } else {
2370 rightPos = coords(to - 1, "right");
2371 if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
2372 left = leftPos.left;
2373 right = rightPos.right;
2374 }
2375 if (fromArg == null && from == 0) left = leftSide;
2376 if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
2377 add(left, leftPos.top, null, leftPos.bottom);
2378 left = leftSide;
2379 if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
2380 }
2381 if (toArg == null && to == lineLen) right = rightSide;
2382 if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
2383 start = leftPos;
2384 if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
2385 end = rightPos;
2386 if (left < leftSide + 1) left = leftSide;
2387 add(left, rightPos.top, right - left, rightPos.bottom);
2388 });
2389 return {start: start, end: end};
2390 }
2391
2392 var sFrom = range.from(), sTo = range.to();
2393 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