MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / gutterEvent

Function gutterEvent

lib/web/CodeMirror/src/edit/mouse_events.js:370–397  ·  view source on GitHub ↗
(cm, e, type, prevent)

Source from the content-addressed store, hash-verified

368// Determines whether an event happened in the gutter, and fires the
369// handlers for the corresponding event.
370function gutterEvent(cm, e, type, prevent) {
371 let mX, mY
372 if (e.touches) {
373 mX = e.touches[0].clientX
374 mY = e.touches[0].clientY
375 } else {
376 try { mX = e.clientX; mY = e.clientY }
377 catch(e) { return false }
378 }
379 if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false
380 if (prevent) e_preventDefault(e)
381
382 let display = cm.display
383 let lineBox = display.lineDiv.getBoundingClientRect()
384
385 if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e)
386 mY -= lineBox.top - display.viewOffset
387
388 for (let i = 0; i < cm.display.gutterSpecs.length; ++i) {
389 let g = display.gutters.childNodes[i]
390 if (g && g.getBoundingClientRect().right >= mX) {
391 let line = lineAtHeight(cm.doc, mY)
392 let gutter = cm.display.gutterSpecs[i]
393 signal(cm, type, cm, line, gutter.className, e)
394 return e_defaultPrevented(e)
395 }
396 }
397}
398
399export function clickInGutter(cm, e) {
400 return gutterEvent(cm, e, "gutterClick", true)

Callers 2

clickInGutterFunction · 0.70
contextMenuInGutterFunction · 0.70

Calls 5

e_preventDefaultFunction · 0.90
hasHandlerFunction · 0.90
e_defaultPreventedFunction · 0.90
lineAtHeightFunction · 0.90
signalFunction · 0.90

Tested by

no test coverage detected