MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / gutterEvent

Function gutterEvent

static/libs/codemirror.js:7537–7564  ·  view source on GitHub ↗
(cm, e, type, prevent)

Source from the content-addressed store, hash-verified

7535// Determines whether an event happened in the gutter, and fires the
7536// handlers for the corresponding event.
7537function gutterEvent(cm, e, type, prevent) {
7538 var mX, mY;
7539 if (e.touches) {
7540 mX = e.touches[0].clientX;
7541 mY = e.touches[0].clientY;
7542 } else {
7543 try { mX = e.clientX; mY = e.clientY; }
7544 catch(e) { return false }
7545 }
7546 if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
7547 if (prevent) { e_preventDefault(e); }
7548
7549 var display = cm.display;
7550 var lineBox = display.lineDiv.getBoundingClientRect();
7551
7552 if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
7553 mY -= lineBox.top - display.viewOffset;
7554
7555 for (var i = 0; i < cm.options.gutters.length; ++i) {
7556 var g = display.gutters.childNodes[i];
7557 if (g && g.getBoundingClientRect().right >= mX) {
7558 var line = lineAtHeight(cm.doc, mY);
7559 var gutter = cm.options.gutters[i];
7560 signal(cm, type, cm, line, gutter, e);
7561 return e_defaultPrevented(e)
7562 }
7563 }
7564}
7565
7566function clickInGutter(cm, e) {
7567 return gutterEvent(cm, e, "gutterClick", true)

Callers 2

clickInGutterFunction · 0.85
contextMenuInGutterFunction · 0.85

Calls 5

e_preventDefaultFunction · 0.85
hasHandlerFunction · 0.85
e_defaultPreventedFunction · 0.85
lineAtHeightFunction · 0.85
signalFunction · 0.85

Tested by

no test coverage detected