Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.onMouseDown = function(e) {
// if this click caused the editor to be focused ignore the click
// for selection and cursor placement
if (
!this.browserFocus.isFocused()
|| new Date().getTime() - this.browserFocus.lastFocus < 20
|| !this.editor.isFocused()
)
return;
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
var pos = this.$getEventPosition(e);
var editor = this.editor;
var self = this;
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
var state = STATE_UNKNOWN;
var inSelection = false;
var button = event.getButton(e);
if (button !== 0) {
if (selectionEmpty) {
editor.moveCursorToPosition(pos);
}
if(button == 2) {
editor.textInput.onContextMenu({x: pageX, y: pageY}, selectionEmpty);
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
this.onMouseDown = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
var pos = this.$getEventPosition(e);
var editor = this.editor;
var self = this;
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
var inSelection = !editor.getReadOnly()
&& !selectionEmpty
&& selectionRange.contains(pos.row, pos.column);
var state = STATE_UNKNOWN;
// if this click caused the editor to be focused should not clear the
// selection
if (
this.$onGutterClick = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
this._dispatchEvent("gutter" + e.type, {
row: this.screenToTextCoordinates(pageX, pageY).row,
htmlEvent: e
});
};
this.$onGutterClick = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
this._dispatchEvent("gutter" + e.type, {
row: this.screenToTextCoordinates(pageX, pageY).row,
htmlEvent: e
});
};
var onMouseSelection = function(e) {
mousePageX = event.getDocumentX(e);
mousePageY = event.getDocumentY(e);
};
this.$getEventPosition = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
var pos = this.editor.renderer.screenToTextCoordinates(pageX, pageY);
pos.row = Math.max(0, Math.min(pos.row, this.editor.session.getLength()-1));
return pos;
};
this.$getEventPosition = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
var pos = this.editor.renderer.screenToTextCoordinates(pageX, pageY);
pos.row = Math.max(0, Math.min(pos.row, this.editor.session.getLength()-1));
return pos;
};
this.$onGutterClick = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
this._dispatchEvent("gutter" + e.type, {
row: this.screenToTextCoordinates(pageX, pageY).row,
htmlEvent: e
});
};
var onMouseSelection = function(e) {
mousePageX = event.getDocumentX(e);
mousePageY = event.getDocumentY(e);
};
this.onMouseDown = function(e) {
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
var pos = this.$getEventPosition(e);
var editor = this.editor;
var self = this;
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
var state = STATE_UNKNOWN;
var inSelection = false;
var button = event.getButton(e);
if (button !== 0) {
if (selectionEmpty) {
editor.moveCursorToPosition(pos);
}
if(button == 2) {
editor.textInput.onContextMenu({x: pageX, y: pageY}, selectionEmpty);
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);