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

Function registerEventHandlers

tools/pythonauto/static/codemirror/codemirror.js:1576–1699  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

1574 // EVENT HANDLERS
1575
1576 function registerEventHandlers(cm) {
1577 var d = cm.display;
1578 on(d.scroller, "mousedown", operation(cm, onMouseDown));
1579 if (old_ie)
1580 on(d.scroller, "dblclick", operation(cm, function(e) {
1581 if (signalDOMEvent(cm, e)) return;
1582 var pos = posFromMouse(cm, e);
1583 if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
1584 e_preventDefault(e);
1585 var word = findWordAt(getLine(cm.doc, pos.line).text, pos);
1586 extendSelection(cm.doc, word.from, word.to);
1587 }));
1588 else
1589 on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
1590 on(d.lineSpace, "selectstart", function(e) {
1591 if (!eventInWidget(d, e)) e_preventDefault(e);
1592 });
1593 // Gecko browsers fire contextmenu *after* opening the menu, at
1594 // which point we can't mess with it anymore. Context menu is
1595 // handled in onMouseDown for Gecko.
1596 if (!captureMiddleClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
1597
1598 on(d.scroller, "scroll", function() {
1599 if (d.scroller.clientHeight) {
1600 setScrollTop(cm, d.scroller.scrollTop);
1601 setScrollLeft(cm, d.scroller.scrollLeft, true);
1602 signal(cm, "scroll", cm);
1603 }
1604 });
1605 on(d.scrollbarV, "scroll", function() {
1606 if (d.scroller.clientHeight) setScrollTop(cm, d.scrollbarV.scrollTop);
1607 });
1608 on(d.scrollbarH, "scroll", function() {
1609 if (d.scroller.clientHeight) setScrollLeft(cm, d.scrollbarH.scrollLeft);
1610 });
1611
1612 on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
1613 on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
1614
1615 function reFocus() { if (cm.state.focused) setTimeout(bind(focusInput, cm), 0); }
1616 on(d.scrollbarH, "mousedown", reFocus);
1617 on(d.scrollbarV, "mousedown", reFocus);
1618 // Prevent wrapper from ever scrolling
1619 on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
1620
1621 var resizeTimer;
1622 function onResize() {
1623 if (resizeTimer == null) resizeTimer = setTimeout(function() {
1624 resizeTimer = null;
1625 // Might be a text scaling operation, clear size caches.
1626 d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = knownScrollbarWidth = null;
1627 clearCaches(cm);
1628 runInOp(cm, bind(regChange, cm));
1629 }, 100);
1630 }
1631 on(window, "resize", onResize);
1632 // Above handler holds on to the editor and its data structures.
1633 // Here we poll to unregister it when the editor is no longer in

Callers 1

CodeMirrorFunction · 0.70

Calls 15

onFunction · 0.85
signalFunction · 0.85
operationFunction · 0.70
signalDOMEventFunction · 0.70
posFromMouseFunction · 0.70
clickInGutterFunction · 0.70
eventInWidgetFunction · 0.70
e_preventDefaultFunction · 0.70
findWordAtFunction · 0.70
getLineFunction · 0.70
extendSelectionFunction · 0.70
onContextMenuFunction · 0.70

Tested by

no test coverage detected