cleanup
This commit is contained in:
parent
346ae096b3
commit
6cde5f3b4f
6 changed files with 25 additions and 66 deletions
|
|
@ -20,7 +20,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Harutyun Amirjanyan <amirjanyan AT gmail DOT com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ var Fold = exports.Fold = function(range, placeholder) {
|
|||
};
|
||||
|
||||
this.addSubFold = function(fold) {
|
||||
if (this.range.isEequal(fold))
|
||||
if (this.range.isEqual(fold))
|
||||
return this;
|
||||
|
||||
if (!this.range.containsRange(fold))
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ function FoldHandler(editor) {
|
|||
var position = e.getDocumentPosition();
|
||||
var session = editor.session;
|
||||
|
||||
// If the user dclicked on a fold, then expand it.
|
||||
// If the user clicked on a fold, then expand it.
|
||||
var fold = session.getFoldAt(position.row, position.column, 1);
|
||||
if (fold) {
|
||||
if (e.getAccelKey())
|
||||
|
|
|
|||
|
|
@ -102,30 +102,6 @@ function onMouseDown(e) {
|
|||
editor.updateSelectionMarkers()
|
||||
};
|
||||
|
||||
var normalSelect = function() {
|
||||
var clickSelection
|
||||
if (_self.$clickSelection) {
|
||||
if (_self.$clickSelection.contains(cursor.row, cursor.column)) {
|
||||
editor.selection.setSelectionRange(_self.$clickSelection);
|
||||
}
|
||||
else {
|
||||
if (_self.$clickSelection.compare(cursor.row, cursor.column) == -1) {
|
||||
anchor = _self.$clickSelection.end;
|
||||
}
|
||||
else {
|
||||
anchor = _self.$clickSelection.start;
|
||||
}
|
||||
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
|
||||
editor.selection.selectToPosition(cursor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
editor.selection.selectToPosition(cursor);
|
||||
}
|
||||
|
||||
editor.renderer.scrollCursorIntoView();
|
||||
};
|
||||
|
||||
var session = editor.session;
|
||||
var anchor = selection.getCursor();
|
||||
var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
|
||||
|
|
@ -133,50 +109,33 @@ function onMouseDown(e) {
|
|||
var screenCursor = screenAnchor;
|
||||
|
||||
|
||||
onSelectionInterval = blockSelect;
|
||||
|
||||
if (ctrl && !shift && !alt && button == 0) {
|
||||
if (!isMultiSelect && inSelection)
|
||||
return // dragging
|
||||
|
||||
if (!isMultiSelect) {
|
||||
if (!isMultiSelect)
|
||||
selection.addRange(selection.toOrientedRange());
|
||||
}
|
||||
if (inSelection)
|
||||
selection.clearSelection();
|
||||
|
||||
var helper = selection.toOrientedRange();
|
||||
editor.addSelectionMarker(helper);
|
||||
|
||||
var oldRange = selection.rangeList.rangeAtPoint(pos);
|
||||
|
||||
event.capture(editor.container, function(){}, function() {
|
||||
editor.removeSelectionMarkers([helper]);
|
||||
var tmpSel = selection.toOrientedRange();
|
||||
|
||||
if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor)) {
|
||||
if (selection.rangeCount > 1) {
|
||||
editor.selection.substractPoint(tmpSel.cursor);
|
||||
var range = editor.selection.ranges[0];
|
||||
if (range)
|
||||
editor.selection.addRange(range);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
selection.addRange(tmpSel);
|
||||
if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
|
||||
selection.substractPoint(tmpSel.cursor);
|
||||
else
|
||||
selection.addRange(tmpSel);
|
||||
});
|
||||
|
||||
//e.stop()
|
||||
} else if (!shift && alt && button == 0) {
|
||||
e.stop()
|
||||
|
||||
|
||||
if (isMultiSelect && !ctrl) {
|
||||
if (isMultiSelect && !ctrl)
|
||||
selection.toSingleRange();
|
||||
} else if (!isMultiSelect && ctrl) {
|
||||
else if (!isMultiSelect && ctrl)
|
||||
selection.addRange();
|
||||
}
|
||||
|
||||
selection.moveCursorToPosition(pos);
|
||||
selection.clearSelection();
|
||||
|
|
@ -190,9 +149,7 @@ function onMouseDown(e) {
|
|||
selection.addRange(rectSel[i])
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
onSelectionInterval = blockSelect;
|
||||
|
||||
event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
|
||||
var timerId = setInterval(function() {onSelectionInterval()}, 20);
|
||||
|
|
@ -202,7 +159,6 @@ function onMouseDown(e) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
exports.onMouseDown = onMouseDown;
|
||||
|
||||
});
|
||||
|
|
@ -90,7 +90,6 @@ var EditSession = require("./edit_session").EditSession;
|
|||
|
||||
var removed = this.rangeList.add(range);
|
||||
|
||||
this.fromOrientedRange(range);
|
||||
this.$onAddRange(range);
|
||||
|
||||
if (removed.length)
|
||||
|
|
@ -123,24 +122,24 @@ var EditSession = require("./edit_session").EditSession;
|
|||
|
||||
this.mergeOverlappingRanges = function() {
|
||||
var removed = this.rangeList.merge();
|
||||
var lastRange = this.ranges[0];
|
||||
if (removed.length)
|
||||
this.$onRemoveRange(removed);
|
||||
|
||||
if (lastRange)
|
||||
this.fromOrientedRange(lastRange);
|
||||
else
|
||||
this.fromOrientedRange(this.ranges[0]);
|
||||
};
|
||||
|
||||
this.$onAddRange = function(range) {
|
||||
this.rangeCount = this.rangeList.ranges.length;
|
||||
this.ranges.unshift(range);
|
||||
this.fromOrientedRange(range);
|
||||
this._emit("addRange", {range: range});
|
||||
};
|
||||
|
||||
this.$onRemoveRange = function(removed) {
|
||||
this.rangeCount = this.rangeList.ranges.length;
|
||||
if (this.rangeCount == 1 && this.inMultiSelectMode) {
|
||||
removed.push(this.rangeList.ranges.pop());
|
||||
var lastRange = this.rangeList.ranges.pop()
|
||||
removed.push(lastRange);
|
||||
this.rangeCount = 0;
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +148,6 @@ var EditSession = require("./edit_session").EditSession;
|
|||
this.ranges.splice(index, 1);
|
||||
}
|
||||
|
||||
console.log(this.ranges+'')
|
||||
this._emit("removeRange", {ranges: removed});
|
||||
|
||||
if (this.rangeCount == 0 && this.inMultiSelectMode) {
|
||||
|
|
@ -158,6 +156,10 @@ var EditSession = require("./edit_session").EditSession;
|
|||
this.session.$undoSelect = true;
|
||||
this.rangeList.detach(this.session);
|
||||
}
|
||||
|
||||
lastRange = lastRange || this.ranges[0];
|
||||
if (lastRange && !lastRange.isEqual(this.getRange()))
|
||||
this.fromOrientedRange(lastRange);
|
||||
};
|
||||
|
||||
// adds multicursor support to selection
|
||||
|
|
@ -448,9 +450,9 @@ var Editor = require("./editor").Editor;
|
|||
|
||||
var words = [];
|
||||
for (var i = all.length; i--; ) {
|
||||
var range = all[i]
|
||||
var range = all[i];
|
||||
if (range.isEmpty()) {
|
||||
var tmp = session.getWordRange(range.start.row, range.start.column)
|
||||
var tmp = session.getWordRange(range.start.row, range.start.column);
|
||||
range.start.row = tmp.start.row;
|
||||
range.start.column = tmp.start.column;
|
||||
range.end.row = tmp.end.row;
|
||||
|
|
@ -459,6 +461,7 @@ var Editor = require("./editor").Editor;
|
|||
|
||||
words.unshift(this.session.getTextRange(range));
|
||||
}
|
||||
|
||||
if (dir < 0)
|
||||
words.unshift(words.pop());
|
||||
else
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Harutyun Amirjanyan <amirjanyan AT gmail DOT com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -71,7 +71,7 @@ var RangeList = function(startRow, startColumn, endRow, endColumn) {
|
|||
};
|
||||
|
||||
this.add = function(range) {
|
||||
var startIndex = this.pointIndex(range.start);
|
||||
var startIndex = this.pointIndex(range.start);
|
||||
if (startIndex < 0)
|
||||
startIndex = -startIndex - 1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue