"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/edit/mouse_events.js" between
CodeMirror-5.58.2.tar.gz and CodeMirror-5.58.3.tar.gz

About: CodeMirror is a text editor implemented in JavaScript for the browser and specialized for editing code.

mouse_events.js  (CodeMirror-5.58.2):mouse_events.js  (CodeMirror-5.58.3)
skipping to change at line 152 skipping to change at line 152
leftButtonSelect(cm, event, pos, behavior) leftButtonSelect(cm, event, pos, behavior)
} }
// Start a text drag. When it ends, see if any dragging actually // Start a text drag. When it ends, see if any dragging actually
// happen, and treat as a click if it didn't. // happen, and treat as a click if it didn't.
function leftButtonStartDrag(cm, event, pos, behavior) { function leftButtonStartDrag(cm, event, pos, behavior) {
let display = cm.display, moved = false let display = cm.display, moved = false
let dragEnd = operation(cm, e => { let dragEnd = operation(cm, e => {
if (webkit) display.scroller.draggable = false if (webkit) display.scroller.draggable = false
cm.state.draggingText = false cm.state.draggingText = false
if (cm.state.delayingBlurEvent) {
if (cm.hasFocus()) cm.state.delayingBlurEvent = false
else delayBlurEvent(cm)
}
off(display.wrapper.ownerDocument, "mouseup", dragEnd) off(display.wrapper.ownerDocument, "mouseup", dragEnd)
off(display.wrapper.ownerDocument, "mousemove", mouseMove) off(display.wrapper.ownerDocument, "mousemove", mouseMove)
off(display.scroller, "dragstart", dragStart) off(display.scroller, "dragstart", dragStart)
off(display.scroller, "drop", dragEnd) off(display.scroller, "drop", dragEnd)
if (!moved) { if (!moved) {
e_preventDefault(e) e_preventDefault(e)
if (!behavior.addNew) if (!behavior.addNew)
extendSelection(cm.doc, pos, null, null, behavior.extend) extendSelection(cm.doc, pos, null, null, behavior.extend)
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#308 1) // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#308 1)
if ((webkit && !safari) || ie && ie_version == 9) if ((webkit && !safari) || ie && ie_version == 9)
skipping to change at line 175 skipping to change at line 179
} }
}) })
let mouseMove = function(e2) { let mouseMove = function(e2) {
moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clien tY - e2.clientY) >= 10 moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clien tY - e2.clientY) >= 10
} }
let dragStart = () => moved = true let dragStart = () => moved = true
// Let the drag handler handle this. // Let the drag handler handle this.
if (webkit) display.scroller.draggable = true if (webkit) display.scroller.draggable = true
cm.state.draggingText = dragEnd cm.state.draggingText = dragEnd
dragEnd.copy = !behavior.moveOnDrag dragEnd.copy = !behavior.moveOnDrag
// IE's approach to draggable
if (display.scroller.dragDrop) display.scroller.dragDrop()
on(display.wrapper.ownerDocument, "mouseup", dragEnd) on(display.wrapper.ownerDocument, "mouseup", dragEnd)
on(display.wrapper.ownerDocument, "mousemove", mouseMove) on(display.wrapper.ownerDocument, "mousemove", mouseMove)
on(display.scroller, "dragstart", dragStart) on(display.scroller, "dragstart", dragStart)
on(display.scroller, "drop", dragEnd) on(display.scroller, "drop", dragEnd)
delayBlurEvent(cm) cm.state.delayingBlurEvent = true
setTimeout(() => display.input.focus(), 20) setTimeout(() => display.input.focus(), 20)
// IE's approach to draggable
if (display.scroller.dragDrop) display.scroller.dragDrop()
} }
function rangeForUnit(cm, pos, unit) { function rangeForUnit(cm, pos, unit) {
if (unit == "char") return new Range(pos, pos) if (unit == "char") return new Range(pos, pos)
if (unit == "word") return cm.findWordAt(pos) if (unit == "word") return cm.findWordAt(pos)
if (unit == "line") return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos .line + 1, 0))) if (unit == "line") return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos .line + 1, 0)))
let result = unit(cm, pos) let result = unit(cm, pos)
return new Range(result.from, result.to) return new Range(result.from, result.to)
} }
// Normal selection, as opposed to text dragging. // Normal selection, as opposed to text dragging.
function leftButtonSelect(cm, event, start, behavior) { function leftButtonSelect(cm, event, start, behavior) {
if (ie) delayBlurEvent(cm)
let display = cm.display, doc = cm.doc let display = cm.display, doc = cm.doc
e_preventDefault(event) e_preventDefault(event)
let ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges let ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges
if (behavior.addNew && !behavior.extend) { if (behavior.addNew && !behavior.extend) {
ourIndex = doc.sel.contains(start) ourIndex = doc.sel.contains(start)
if (ourIndex > -1) if (ourIndex > -1)
ourRange = ranges[ourIndex] ourRange = ranges[ourIndex]
else else
ourRange = new Range(start, start) ourRange = new Range(start, start)
 End of changes. 5 change blocks. 
3 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)