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

Function moveVisually

tools/pythonauto/static/codemirrorepl/codemirror.js:7266–7287  ·  view source on GitHub ↗
(line, start, dir, byUnit)

Source from the content-addressed store, hash-verified

7264 // LTR text touch each other. This often requires the cursor offset
7265 // to move more than one unit, in order to visually move one unit.
7266 function moveVisually(line, start, dir, byUnit) {
7267 var bidi = getOrder(line);
7268 if (!bidi) return moveLogically(line, start, dir, byUnit);
7269 var pos = getBidiPartAt(bidi, start), part = bidi[pos];
7270 var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
7271
7272 for (;;) {
7273 if (target > part.from && target < part.to) return target;
7274 if (target == part.from || target == part.to) {
7275 if (getBidiPartAt(bidi, target) == pos) return target;
7276 part = bidi[pos += dir];
7277 return (dir > 0) == part.level % 2 ? part.to : part.from;
7278 } else {
7279 part = bidi[pos += dir];
7280 if (!part) return null;
7281 if ((dir > 0) == part.level % 2)
7282 target = moveInLine(line, part.to, -1, byUnit);
7283 else
7284 target = moveInLine(line, part.from, 1, byUnit);
7285 }
7286 }
7287 }
7288
7289 function moveLogically(line, start, dir, byUnit) {
7290 var target = start + dir;

Callers 1

coordsCharInnerFunction · 0.70

Calls 4

getOrderFunction · 0.70
moveLogicallyFunction · 0.70
getBidiPartAtFunction · 0.70
moveInLineFunction · 0.70

Tested by

no test coverage detected