MCPcopy Index your code
hub / github.com/csev/py4e / findPosV

Function findPosV

tools/pythonauto/static/codemirrorepl/codemirror.js:3753–3768  ·  view source on GitHub ↗
(cm, pos, dir, unit)

Source from the content-addressed store, hash-verified

3751 // "page" or "line". The resulting position will have a hitSide=true
3752 // property if it reached the end of the document.
3753 function findPosV(cm, pos, dir, unit) {
3754 var doc = cm.doc, x = pos.left, y;
3755 if (unit == "page") {
3756 var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
3757 y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
3758 } else if (unit == "line") {
3759 y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
3760 }
3761 for (;;) {
3762 var target = coordsChar(cm, x, y);
3763 if (!target.outside) break;
3764 if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
3765 y += dir * 5;
3766 }
3767 return target;
3768 }
3769
3770 // Find the word at the given position (as returned by coordsChar).
3771 function findWordAt(doc, pos) {

Callers 1

codemirror.jsFile · 0.70

Calls 2

textHeightFunction · 0.70
coordsCharFunction · 0.70

Tested by

no test coverage detected